View previous topic :: View next topic |
Author |
Message |
yee n00b
Joined: 16 Sep 2004 Posts: 39
|
Posted: Sun Nov 24, 2013 4:48 pm Post subject: Initramfs question |
|
|
I was reading https://wiki.gentoo.org/wiki/Early_Userspace_Mounting and have a question concerning the init file
Within the subroutine, check_filesystem(), /sbin/fsck is used to avoid the busybox fsck. On my system, it is linked to shared libraries in /lib. OK so far since /sbin and /lib is on the same filesystem.
As far as the script goes, /proc, /dev and /sys are first mounted before the root partition.
Root is mounted on /mnt/root using the uuidlabel_root() subroutine. Thus, /sbin is actually found on /mnt/root/sbin.
After softlinking /etc/fstab, the first step is to check the filesystem in the loop. The check_filesystem() subroutine is called looking for /sbin/fsck which should even exist (it is /mnt/root/sbin/fsck) ! Further, the shared libraries are supposed to be in /lib are actually in /mnt/root/lib.
Why should the initscript actually WORK? What am I missing?
Thanks.
Conway Yee |
|
Back to top |
|
|
frostschutz Advocate
Joined: 22 Feb 2005 Posts: 2977 Location: Germany
|
Posted: Sun Nov 24, 2013 5:07 pm Post subject: |
|
|
You're probably missing that these files are supposed to be included in the Initramfs in this case. So /sbin/fsck is part of the Initramfs, while it may be a copy of /mnt/root/sbin/fsck it's not strictly related anymore at this point.
I still think this is badly done, though. In particular the /forcefsck check - that probably won't work, as there should never be a /forcefsck in the Initramfs really. And although you could craft a boot entry that does create this file, you'd usually go for a custom kernel parameter instead.
The primary function of Initramfs is to mount the root partition in read-only mode. No more, no less. You can leave the entire fsck out of it. fsck will be done by the real system, same way it works in a system that does not use an Initramfs. If your filesystem is that badly off that this breaks, you're probably better off with a real rescue system anyway. Unless you're trying to turn your Initramfs into such, you're probably better off leaving the fsck out of it. |
|
Back to top |
|
|
yee n00b
Joined: 16 Sep 2004 Posts: 39
|
Posted: Sun Nov 24, 2013 5:45 pm Post subject: |
|
|
frostschutz wrote: | The primary function of Initramfs is to mount the root partition in read-only mode. No more, no less. You can leave the entire fsck out of it. fsck will be done by the real system, ... |
Aah! That would be lovely and what I have been doing for years, mainly to allow access the LABEL=ROOT notation in grub. With multiple hard drives in my system, things started getting confusing and I used labels instead.
The problem is that as far I am aware, separately mounted /usr is not OFFICIALLY supported in gentoo anymore. I have been using a /usr mounted read-only to protect my system. The root partition is left read/write.
As such, I am forced to mount /usr in initramfs. There in lies the problem. As I understand it, once mounted in initramfs, fsck can not safely check /usr.
Ideas? My currently preferred option would be to rebuild /sbin/fsck* as a completely static binary and use /mnt/root/fsck*. I use the same cpio archive for BOTH 32 bit and 64 bit systems and deliberately built uclibc busybox as a 32 bit binary. I would prefer to avoid cluttering up initramfs with excess specially built garbage. Complexity does not belong in initramfs.
Conway Yee |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54236 Location: 56N 3W
|
Posted: Sun Nov 24, 2013 7:10 pm Post subject: |
|
|
yee,
There is a patch to the init scripts to start udev after localmount.
The allows the use of a separate /usr without it being mounted in the initrd.
This patch is supported by the user community. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
frostschutz Advocate
Joined: 22 Feb 2005 Posts: 2977 Location: Germany
|
Posted: Sun Nov 24, 2013 7:56 pm Post subject: |
|
|
yee wrote: | As such, I am forced to mount /usr in initramfs. There in lies the problem. As I understand it, once mounted in initramfs, fsck can not safely check /usr. |
There should be no difference. Of course, I don't know how it's implemented in the init scripts.
As for separate /usr, what I did when this started was to get rid of separate /usr altogether. If you have a partition for everything anyway, your / partition will be pretty much empty and therefore useless. So merging it with /usr is no problem at all, and at the same time it solves a bunch of problems.
Something along these lines:
Code: |
mkdir /mnt/root
mkdir /mnt/usr
mount /dev/yourroot /mnt/root
mount /dev/yourusr /mnt/usr
mkdir /mnt/usr/usr
mv /mnt/usr/* /mnt/usr/usr/
rsync -a /mnt/root/. /mnt/usr/.
|
Update any dependencies (grub, fstab, initramfs, ...) along with it and your usr device is your new root device.
No more problems with separate usr, no more patches to initscripts, no initramfs you don't need if you don't encrypt stuff, no downsides. |
|
Back to top |
|
|
yee n00b
Joined: 16 Sep 2004 Posts: 39
|
Posted: Thu Nov 28, 2013 3:31 am Post subject: |
|
|
I wanted to keep the initramfs as lightweight as possible. I see absolutely NO reason why fsck needs to be in the archive since the init script ALREADY knows where root is. Thus, after mounting root, I added a bit of code to place fsck* into /sbin and create the necessary symbolic links for /lib*
This way my initramfs ONLY contains the init script and the busybox binary.
Conway Yee
Code: |
# mount / and other filesystems
mount -o ro "${root}" /mnt || exec sh
ln -s /mnt/etc/fstab /etc/fstab
# allow access to fsck
for i in $(ls /mnt | grep lib ); do
ln -s /mnt/$i /
done
rm /sbin/fsck* # get rid of busybox fsck
for i in $(ls /mnt/sbin/fsck* ); do
ln -s $i /sbin
done
|
|
|
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
|
|