problem with initrd 93-boot.sh probably due to chroot

Hello,

I have run into a problem with 12.3’s initrd.

I can boot fine with a simple root nfs filesystem after building the initrd with options -d /dev/nfs -f nfs -D eth0
the problems arise in my specific usage where I want a skeleton filesystem for each client with the main system shared and kept separate and mounted via nfs as well.

I have successfully added a script in boot which mounts the nfs filesystem no problem.

The initrd gets all the way to the final script 93-boot.sh before crashing.

If I add shell=1 to my boot options I find that my skeleton filesystem is properly mounted on /root
I have /root/bin, /root/usr and /root/sbin successfully mounted via nfs and can cd into /root/bin and see all the executables no problem. Same goes for everything in /root/usr etc… Everything looks great. I can run /root/bin/sh no problem. I can ls -l /root/sbin/init and it is there.

However as soon as the final line in 93-boot.sh is run (exec run-init -c ./dev/console /root $init $(kernel_cmdline@]}) it dies complaining that /sbin/init cannot be found.

I have done some testing by copying chroot into the initrd and have found that I cannot chroot into root at all even though all the files look fine. It seems like something is different with chroot that is making it drop or ignore mounted filesystems inside the chroot.
If I use the complete system for my nfsroot instead of the skeleton with separate mounts for /usr /bin etc… everything works fine.

The closest thread I could find to my problem is the following unsolved one https://forums.opensuse.org/english/get-technical-help-here/install-boot-login/471684-mystery-11-4-initrd-refuses-chroot-bin-run-init-sbin-init-no-such-file-directory.html
The following separate-usr-is-broken suggests that what I am trying to do is possible. I just can’t make it work in opensuse 12.3 and I think the problem is with chroot.

I have had everything working without problem before (prior to the switch to systemd) but now I am stuck.

To anticipate the inevitable “why are you doing this” question… I run a whole bunch of diskless terminals off a single installation. This way I can easily maintain the terminals and keep file size well down.

Any ideas are greatly appreciated.
Thanks,
Mark

Problem solved.

I have fixed my problem by mounting the entire suse 12.3 installation on /root/base during the initrd and using symlinks to in the skeleton root filesystem to point to the base directories.

I discovered that chroot is doing some sort of checking for /sbin/init (or whatever executable you are trying to run ie /bin/sh) before the actual change root takes place. This was causing fails using my old symlink structure.

The following skeleton system works great now:

drwxr-xr-x 22 root root 4096 2013-10-22 10:13 base
-rw-------  1 root root   21 2013-10-24 10:07 .bash_history
lrwxrwxrwx  1 root root    8 2013-10-24 11:00 bin -> base/bin
lrwxrwxrwx  1 root root    9 2013-10-24 11:00 boot -> base/boot
drwxr-xr-x  4 root root 8192 2013-10-22 10:23 dev
drwxr-xr-x  5 root root 8192 2013-10-24 09:57 etc
drwxr-xr-x  5 root root 4096 2013-10-22 10:28 home
lrwxrwxrwx  1 root root    8 2013-10-24 11:00 lib -> base/lib
drwxr-xr-x  3 root root 4096 2013-10-24 10:28 .local
drwxr-xr-x  2 root root 4096 2013-10-23 08:01 media
drwxr-xr-x  2 root root 4096 2013-10-23 08:01 mnt
drwxr-xr-x  3 root root 4096 2013-10-22 14:44 opt
drwxr-xr-x  2 root root 4096 2013-10-22 14:48 proc
-rw-r--r--  1 root root 2239 2013-10-24 10:55 .readahead
drwx------ 10 root root 4096 2013-10-22 14:36 root
drwxr-xr-x  2 root root 4096 2013-10-22 14:12 run
lrwxrwxrwx  1 root root    9 2013-10-24 11:01 sbin -> base/sbin
drwxr-xr-x  2 root root 4096 2013-10-23 08:01 selinux
drwxr-xr-x  5 root root 4096 2013-10-17 15:00 srv
drwxr-xr-x  2 root root 4096 2013-10-22 14:49 sys
drwxrwxrwt  8 root root 4096 2013-10-24 10:57 tmp
lrwxrwxrwx  1 root root    8 2013-10-24 11:01 usr -> base/usr
drwxr-xr-x 17 root root 4096 2013-10-22 13:25 var

Previously I was using symlinks like


drwxr-xr-x 22 root root 4096 2013-10-22 10:13 base
-rw-------  1 root root   21 2013-10-24 10:07 .bash_history
lrwxrwxrwx  1 root root    9 2013-10-24 10:58 bin -> /base/bin
lrwxrwxrwx  1 root root   10 2013-10-24 10:58 boot -> /base/boot
drwxr-xr-x  4 root root 8192 2013-10-22 10:23 dev
drwxr-xr-x  5 root root 8192 2013-10-24 09:57 etc
drwxr-xr-x  5 root root 4096 2013-10-22 10:28 home
lrwxrwxrwx  1 root root    9 2013-10-24 10:58 lib -> /base/lib
drwxr-xr-x  3 root root 4096 2013-10-24 10:28 .local
drwxr-xr-x  2 root root 4096 2013-10-23 08:01 media
drwxr-xr-x  2 root root 4096 2013-10-23 08:01 mnt
drwxr-xr-x  3 root root 4096 2013-10-22 14:44 opt
drwxr-xr-x  2 root root 4096 2013-10-22 14:48 proc
-rw-r--r--  1 root root 2239 2013-10-24 10:55 .readahead
drwx------ 10 root root 4096 2013-10-22 14:36 root
drwxr-xr-x  2 root root 4096 2013-10-22 14:12 run
lrwxrwxrwx  1 root root   10 2013-10-24 10:58 sbin -> /base/sbin
drwxr-xr-x  2 root root 4096 2013-10-23 08:01 selinux
drwxr-xr-x  5 root root 4096 2013-10-17 15:00 srv
drwxr-xr-x  2 root root 4096 2013-10-22 14:49 sys
drwxrwxrwt  8 root root 4096 2013-10-24 10:57 tmp
lrwxrwxrwx  1 root root    9 2013-10-24 10:57 usr -> /base/usr
drwxr-xr-x 17 root root 4096 2013-10-22 13:25 var

Even though these symlinks would be valid after the chroot they wouldn’t work. Any attempt to chroot into that directory structure would fail.

Anyhow, my system works great now and I can simply copy the skeleton filesystem for new clients.

I am working on a full write up to document my process since all the old documentation on the web like Diskless-root-NFS-other-HOWTO | Linux.com only works with sysvinit and not systemd. Any suggestions on where to host my how-to would be great.