On Sat, Sep 17, 2011 at 7:13 PM, Dale <[email protected]> wrote:
<SNIP>
>
> Ahhhhh.  I see now.  So, it mounts proc and sys but that is in the init then
> it mounts the real root outside the init.  Then it umounts the proc and sys
> under the init and then switches to the real root and starts init there.
>
> Where does /usr and /var come in here?  Isn't the init supposed to mount
> that too?  Do I add that myself?  If so, when to fsck get ran?
>
> Dale

Hi Dale,
   Let's take a look at the script I sent you yesterday, copied here
again. This system uses a RAID6 for root. This RAID6 is built using
metadata type 1.2. (The newest at the time) Since the kernel only
assembles metadata type 0.9 automatically I had to use the initramfs
to do the assembly and mount.


c2stable / # cat /usr/src/initramfs/init
#!/bin/busybox sh

rescue_shell() {
   echo "Something went wrong. Dropping you to a shell."
   busybox --install -s
   exec /bin/sh
}


# Mount the /proc and /sys filesystems.
mount -t proc none /proc
mount -t sysfs none /sys

# Do your stuff here.
echo "This script mounts rootfs and boots it up, nothing more!"

mdadm --assemble --name=c2stable:3 /dev/md3

# Mount the root filesystem.
mount -o ro /dev/md3 /mnt/root  || rescue_shell

# Clean up.
umount /proc
umount /sys

# Boot the real thing.
exec switch_root /mnt/root /sbin/init
c2stable / #


There are really just 3 interesting parts to this:

1) The rescue_shell function
2) The assembly command
3) The mount command

When you read through the script you see I do the assembly and then
the mount. If the mount command fails then I drop into the rescue
shell which is a simple Linux environment where I can run mdadm by
hand to figure out what went wrong. If the mount succeeds then the
script just continues and Linux boots.

The only difference concerning your /usr question would be change the
mount command to something like:

mount -o ro /dev/sdaX /usr || rescue_shell

Does this make basic sense?



One point about static flag. Normally I don't build mdadm with static enabled:

c2stable ~ # emerge -pv mdadm

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R    ] sys-fs/mdadm-3.1.4  USE="-static" 282 kB

Total: 1 package (1 reinstall), Size of downloads: 282 kB
c2stable ~ #

but for the version I put in the initramfs I did enable it.

Cheers,
Mark

Reply via email to