tech-userlevel archive

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

"dynamic" fstab




Hi,

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
ld0.

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?

Thanks,

[1]
build_fstab()
{
        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
EOF
}


------------------------------------------------------------------
Emile "iMil" Heitor .°. <imil@{home.imil.net,NetBSD.org,gcu.info}>
                                                                _
              | http://imil.net        | ASCII ribbon campaign ( )
              | http://www.NetBSD.org  |  - against HTML email  X
              | http://gcu.info        |              & vCards / \



Home | Main Index | Thread Index | Old Index