View previous topic :: View next topic |
Author |
Message |
lynix n00b
Joined: 07 Aug 2006 Posts: 2
|
Posted: Sat Jan 16, 2010 6:31 pm Post subject: Help with minimal bootscript: /boot corruption |
|
|
I need some help with the bootscript I use to boot from a minimal boot environment into a LUKS encrypted root. I use the environment to avoid the need of an initrd.
What I basically did is putting some binaries, their needed libs and a statically linked busybox in the appropriate folders under my /boot (separate partition, of course). As an init-replacement I use this small bashscript which unlocks the real root and then hands over to the real init:
Code: | #!/bin/sh
# options
ROOT_DEV="/dev/sda3"
# set the PATH
export PATH=/bin:/sbin
# mount /proc and /sys.
mount -n -t proc none /proc
mount -n -t sysfs none /sys
# udev, optional if /dev is already complete
/bin/udevd --daemon
/bin/udevadm trigger
/bin/udevadm settle --timeout=60
# decrypt, check and mount root
until /bin/cryptsetup luksOpen $ROOT_DEV root; do sleep 1; done
/bin/e2fsck -p /dev/mapper/root
mount -n -t ext4 -o ro,noatime /dev/mapper/root /newroot
# update PATH
export PATH=/newroot/bin:/newroot/sbin:$PATH
# stop all helpers
killall udevd
# unmount /sys and /proc
umount /sys
umount /proc
# switch to new root, kickoff the real init
cd /newroot
pivot_root . boot
exec /bin/chroot . /bin/sh -c 'umount /boot; exec /sbin/init 3' < /dev/console >/dev/console 2>&1 |
(Just to respect the ownership: I did not invent this by myself, I just modified the version I got from a friend of mine, who adapted this from somewhere else)
The script is working fine, the machine unlocks and boots correctly, except one small thing: the partition where /boot lies (ext2) seems to get corrupted on each bootup:
Code: | $ fsck.ext2 -fp /dev/sda1
boot: Entry 'root' in /dev/mapper (4187) has deleted/unused inode 4334. CLEARED. |
If I don't repair this every time the system starts up, it won't boot next time. So the simple workaround now is to put the check in /etc/conf.d/local.start, but I woukd like to understand why this happens and how I can properly fix it.
Any suggestions?
Thanks in advance,
lynix |
|
Back to top |
|
|
Sadako Advocate
Joined: 05 Aug 2004 Posts: 3792 Location: sleeping in the bathtub
|
Posted: Fri Jan 22, 2010 7:14 pm Post subject: |
|
|
Is it possible that the problem isn't when booting, but that the filesystem just isn't unmounted (or remounted read only) properly upon shutdown or restart?
BTW, I'm using something a little similar, our two scripts aren't really comparable, but rather than your last three lines, I simply have this; Code: | exec /bin/switch_root ${NEWROOT} /sbin/init | I believe switch_root is preferred over pivot_root, however it may only be when booting from an initrd/tmpfs/ramdisk.
edit: didn't notice this post was almost a week old, haven't logged in in about a month, sorry for the useless bump if no longer relevant... _________________ "You have to invite me in" |
|
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
|
|