View previous topic :: View next topic |
Author |
Message |
pjp Administrator
Joined: 16 Apr 2002 Posts: 20582
|
Posted: Sat Mar 02, 2024 3:37 am Post subject: clarifications on initramfs requirements |
|
|
My first question is what needs to be in the initramfs /etc/ffstab. I have a separate /usr, so I understand it needs to be mounted. Is that sufficient to let the real system mount other partitions (swap, /var, /home)?
Next is whether or not the following errors are relevant... I'm testing the initramfs with qemu and the actual kernel but on a different physical system. There is no /usr to mount and there is currently not fstab file, so those are obvious.
I'm guessing the tty related errors may be related to using qemu without an appropriate configuration, or the kernel missing something qemu would need: qemu command: | $ qemu-system-x86_64 -kernel <kernel image> -initrd <initrd image> -nographic -no-reboot -append "console=ttyS0 panic=-1" | errors: | [ 5.628318] vgchange (64) used greatest stack depth: 14072 bytes left
Checking local filesystem : /usr
fsck.ext2: Is a directory while trying to open /usr
/usr:
The superblock could not be read or does not describe a valid ext2/ext3/ext4
filesystem. If the device is valid and it really contains an ext2/ext3/ext4
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193 <device>
or
e2fsck -b 32768 <device>
Operational error
Mounting /usr
mount: can't read '/etc/fstab': No such file or directory
Starting rescue subshell: Error while mounting /usr
Exit with code 5 to replace /init with a shell running as pid 1
sh: can't access tty; job control turned off
~ # ls -l /dev/console /dev/tty /dev/ttyS0
crw------- 1 0 0 5, 1 Mar 2 03:21 /dev/console
crw-rw-rw- 1 0 0 5, 0 Mar 2 03:21 /dev/tty
crw------- 1 0 0 4, 64 Mar 2 03:21 /dev/ttyS0
~ # exit
mount: mounting /usr on /mnt/root/usr failed: No such file or directory
Starting rescue subshell: Error while moving /usr
Exit with code 5 to replace /init with a shell running as pid 1
sh: can't access tty; job control turned off
~ # exit
Done. Switching to real root.
BusyBox v1.36.1 (2024-01-25 13:25:47 MST) multi-call binary.
Usage: switch_root [-c CONSOLE_DEV] NEW_ROOT NEW_INIT [ARGS]
Free initramfs and switch to another root fs:
chroot to NEW_ROOT, delete all in /, move NEW_ROOT to /,
execute NEW_INIT. PID must be 1. NEW_ROOT must be a mountpoint.
-c DEV Reopen stdio to DEV after switch
[ 39.069132] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000100 | This shorter snippet of output is from using the first rescue_shell function: Code: | Operational error
Mounting /usr
mount: can't read '/etc/fstab': No such file or directory
Error while mounting /usr
Something went wrong. Dropping to a shell.
sh: can't access tty; job control turned off
~ # exit
[ 11.273595] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000000 | What I'm concerned about is the correct flow of the init script. The first set of errors shows an attempt to switch_root where as the other does not.
The init script is here: https://bpa.st/2BBQ
Thanks for any input. _________________ Quis separabit? Quo animo? |
|
Back to top |
|
|
pietinger Moderator
Joined: 17 Oct 2006 Posts: 5347 Location: Bavaria
|
Posted: Sat Mar 02, 2024 3:18 pm Post subject: Re: clarifications on initramfs requirements |
|
|
pjp,
I see you are using the script from https://wiki.gentoo.org/wiki/Early_Userspace_Mounting with an extension for LVM.
pjp wrote: | My first question is what needs to be in the initramfs /etc/ffstab. [...] |
Nothing ! The original script (and yours because you do the same) LINKS the fstab FROM the root partition (/mnt/root/etc/fstab) INTO your initramfs strucure (/etc/fstab). See below if you want test it on another system.
pjp wrote: | [...] I have a separate /usr, so I understand it needs to be mounted. [...] |
YESSS !
pjp wrote: | [...] Is that sufficient to let the real system mount other partitions (swap, /var, /home)?. [...] |
Yes, it is the job of your init system to mount everything else LATER. The script is searching (*) ONLY for ALL directories defined in mountpoints= ... this is ONLY /usr.
*) Searching is done in this loop - which is not a real loop because you have only 1 tuple:
Code: | for m in $mountpoints ; do |
If you want test your script on another system, then you should comment out:
Code: | /bin/ln -s /mnt/root/etc/fstab /etc/fstab |
AND COPY the fstab from your target system INTO the initramfs directory structure at /etc/fstab (or a crippled fstab where you have only the line with /usr)
AND there is a mountable usr-partition.
P.S.: It is not necessary to set a path in an initramfs: "PATH="/sbin:/bin" and you dont need to specify fully qualified names: "/bin/busybox, /bin/ln, /sbin/switch_root ..." _________________ https://wiki.gentoo.org/wiki/User:Pietinger |
|
Back to top |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20582
|
|
Back to top |
|
|
pietinger Moderator
Joined: 17 Oct 2006 Posts: 5347 Location: Bavaria
|
|
Back to top |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20582
|
Posted: Wed Mar 13, 2024 10:04 pm Post subject: |
|
|
Thanks pietinger. I haven't done any testing yet. :( I'm going to rebuild a couple of initramfs files for tomorrow. Fortunately my broken initramfs will work if I manually mount /usr and exit the rescue shell.
I did see that one. For now I'm building the initrams without involving kernel's make. My kernel works, it's the initramfs that's broken :). Looking again, "External CPIO archive with a directory" might work. I'm not using the find method, I run the gen_init_cpio script directly, not with make.
pietinger wrote: | Ouch ... these are (very) old ... | I don't recall other guides including "new" information, although I skip most of the words and try to go directly to the useful parts. :)
I appreciated the historical "why" in the first link, not that it helps with the current mess of an implementation.
The differences seem trivial. It has a few less fsck error code checks. I copied the line to disable kernel message logging to the screen.
That init, it uses "busybox --install -s" which is "bad" because it might overwrite commands included in the initramfs.
I've added "set -x". I already have the rescue_shell change. happened to see that post when I was creating my init.
pietinger wrote: | For testing you also could change the mounting of the root partition with an "hardcoded" command:
Code: | # mounting rootfs on /mnt/root
uuidlabel_root || rescue_shell "Error with uuidlabel_root" |
=>
Code: | # mounting rootfs on /mnt/root
# uuidlabel_root || rescue_shell "Error with uuidlabel_root"
mount -o ro /dev/sdXY /mnt/root |
so your qemu environment dont need to handover a "root=UUID=..." kernel command line parameter. | The VM exists only as presented by the qemu invocation... there is no configuration, so there's nothing there once the kernel loads.
To be truly useful, I'd have to create a disk image with an LVM volume. _________________ Quis separabit? Quo animo? |
|
Back to top |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20582
|
Posted: Tue Mar 26, 2024 2:22 am Post subject: |
|
|
Well, the first couple of attempts have failed.
The first at least booted to the initramfs rescue shell.The second locks up with a kernel panic.
In the first attempt, I was using busybox -sh with the busybox mount. Other busybox utilities seem to support UUID, so I thought maybe mount had been updated to support UUID.
With the second, I switched to using standalone sh and mount. I also updated paths from lddtree as I didn't include some leading /usr/.. references. For example: Code: | $ lddtree /bin/busybox
busybox => /bin/busybox (interpreter => /lib64/ld-linux-x86-64.so.2)
libpam.so.0 => /usr/lib64/libpam.so.0
libpam_misc.so.0 => /usr/lib64/libpam_misc.so.0
libresolv.so.2 => /lib64/libresolv.so.2
libc.so.6 => /lib64/libc.so.6
ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2 | Instead of /usr/lib64/libpam.so.0, I only had /lib64/libpam.so.0.
*shrug*
dracut seemed more convoluted, but I guess I'll try to figure out how to use it. _________________ Quis separabit? Quo animo? |
|
Back to top |
|
|
pietinger Moderator
Joined: 17 Oct 2006 Posts: 5347 Location: Bavaria
|
Posted: Tue Mar 26, 2024 3:16 am Post subject: |
|
|
pjp wrote: | Code: | $ lddtree /bin/busybox
busybox => /bin/busybox (interpreter => /lib64/ld-linux-x86-64.so.2)
libpam.so.0 => /usr/lib64/libpam.so.0
libpam_misc.so.0 => /usr/lib64/libpam_misc.so.0
libresolv.so.2 => /lib64/libresolv.so.2
libc.so.6 => /lib64/libc.so.6
ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2 |
Instead of /usr/lib64/libpam.so.0, I only had /lib64/libpam.so.0. |
You surely had looked also to them and have seen, they are only softlinks. I have (with a stable system):
Code: | lrwxrwxrwx 1 root root 16 23. Mär 18:23 libpam.so -> libpam.so.0.85.1
lrwxrwxrwx 1 root root 16 23. Mär 18:23 libpam.so.0 -> libpam.so.0.85.1
-rwxr-xr-x 1 root root 67592 23. Mär 18:24 libpam.so.0.85.1 |
and
Code: | lrwxrwxrwx 1 root root 21 23. Mär 18:23 libpam_misc.so -> libpam_misc.so.0.82.1
lrwxrwxrwx 1 root root 21 23. Mär 18:23 libpam_misc.so.0 -> libpam_misc.so.0.82.1
-rwxr-xr-x 1 root root 18392 23. Mär 18:24 libpam_misc.so.0.82.1 |
So you must put all of them into your initramfs_list OR in your directory where you build your initramfs.
P.S.: equery tells me also:
Code: | $ equery f pam
* Searching for pam ...
* Contents of sys-libs/pam-1.5.3-r1:
/etc
/etc/environment
[...]
/usr/lib64
/usr/lib64/libpam.so -> libpam.so.0.85.1
/usr/lib64/libpam.so.0 -> libpam.so.0.85.1
/usr/lib64/libpam.so.0.85.1
/usr/lib64/libpam_misc.so -> libpam_misc.so.0.82.1
/usr/lib64/libpam_misc.so.0 -> libpam_misc.so.0.82.1
/usr/lib64/libpam_misc.so.0.82.1
/usr/lib64/libpamc.so -> libpamc.so.0.82.1
/usr/lib64/libpamc.so.0 -> libpamc.so.0.82.1
/usr/lib64/libpamc.so.0.82.1
/usr/lib64/pkgconfig
[...] |
_________________ https://wiki.gentoo.org/wiki/User:Pietinger |
|
Back to top |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20582
|
Posted: Fri Mar 29, 2024 1:48 am Post subject: |
|
|
Thanks pietinger.
Symlinks didn't even occur to me. Unfortunately, that didn't seem to help... the resultant initramfs still ends with kernel panic.
The dracut version doesn't boot, but it will after I manually mount /usr.
Between failures, I finally caught up on updates, which had been about a month behind. So at least I have that going for me.
I'll live with the dracut thing for now as I've already wasted too much time on this New Way of Doing Things. _________________ Quis separabit? Quo animo? |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|