tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

"dynamic" fstab


I'm building a generic-demo disk image in order to give people
a hint on how easy / fast / secure a webserver built on top of
NetBSD can be.

This disk image should be able to boot on major virtualization
systems such as Xen, kvm, VirtualBox and VMware. Problem is
Xen in PV mode will provide a disk block-device named xbd0,
VMware and VBox will provide wd0 and kvm using Virtio will show

The image itself is created using a Xen PV domU, so the fstab
has xbd0a as the root file system and xbd0b as swap, but of course,
when that disk is booted under kvm/virtio, the boot sequence will
fail as xbd0 is not the good root device.

For my particular purposes, I hacked /etc/rc.d/fsck_root[1] in order
to build a fstab corresponding to the output of
`sysctl -n kern.root_device'. It works, but that's ugly. Is there
any cleaner way to achieve that trick?


        root_dev=`sysctl -n kern.root_device`
        mount -o rw /dev/${root_dev}a /
cat > /etc/fstab << EOF
# Automatically generated fstab, DO NOT EDIT
/dev/${root_dev}a /        ffs    rw,log 1 0
/dev/${root_dev}b none     swap   sw,dp 0 0
kernfs            /kern    kernfs rw
ptyfs             /dev/pts ptyfs  rw
procfs            /proc    procfs rw

Emile "iMil" Heitor .°. <imil@{,,}>
              |        | ASCII ribbon campaign ( )
              |  |  - against HTML email  X
              |        |              & vCards / \

Home | Main Index | Thread Index | Old Index