Advice for hacking on ufs/ffs
Dag-Erling Smørgrav
des at des.no
Tue Jul 25 18:49:40 UTC 2006
Eric Anderson <anderson at centtech.com> writes:
> DES - anything special with the nfs root'ed box, to make this work
> well?
Not really. Here's a short summary. Assume you have a spare disk in
your workstation, ad1, which you are going to use for your test box.
Create and populate a file system for your test box:
% mkdir /box
% echo '/dev/ad1 /box ufs rw 2 2' >>/etc/fstab
% newfs -U /box
% mount /box
% mergemaster -i -D /box
% cd /usr/src
% make installworld DESTDIR=/box
Check out a source tree:
% cd /box/usr
% cvs -R -q -d /home/ncvs co -P src
Chroot into your sandbox:
% echo 'devfs /box/dev devfs rw 0 0' >>/etc/fstab
% mount /box/dev
% chroot /box /bin/sh
At this point you want to create an appropriate make.conf and kernel
config for your test box.
Useful make.conf settings include:
# build *everything* with debugging symbols
DEBUG_FLAGS ?= -g
# and leave them in when installing
STRIP = # empty
# don't clean out your previous build before rebuilding the kernel -
# you'll be doing that a lot
NO_KERNELCLEAN = YES
When you are ready, build and install world and kernel:
[still inside the chroot]
% cd /usr/src
% make buildworld buildkernel && make installworld installkernel
You don't really need to chroot; you can do everything outside the
sandbox, making sure that DESTDIR and __MAKE_CONF are correctly
defined. I find it easier to work in a chroot because it saves me
from having to remember just that.
If you're going to use a serial console, kick up the speed a notch:
[still inside the chroot]
% cat >>/boot/loader.conf <<EOF
console="comconsole"
comconsole_speed="115200"
boot_verbose="YES"
EOF
You'll also need an fstab:
[still inside the chroot]
% cat >>/etc/fstab <<EOF
workstation:/box / nfs rw 0 0
md /tmp mfs rw,-s8m 0 0
md /var/tmp mfs rw,-s8m 0 0
md /var/run mfs rw,-s8m 0 0
EOF
Now, outside the chroot, you need to set things up for PXE. First,
you'll need to set up a DHCP server which will hand out an IP address
to your test box and instruct it to get the loader and root file
system from your workstation:
% pkg_add -r isc-dhcp3-server
% cat >/usr/local/etc/dhcp.conf <<EOF
ddns-update-style none;
authoritative;
default-lease-time 86400;
max-lease-time 604800;
subnet 10.0.0.0 netmask 255.255.255.0 {
option routers 10.0.0.1;
option subnet-mask 255.255.255.0;
option broadcast-address 10.0.0.255;
option domain-name "example.com";
option domain-name-servers 10.0.0.1;
host box {
hardware ethernet 00:01:02:03:04:05;
fixed-address box.example.com;
next-server workstation.example.com;
filename "pxeboot";
option root-path "/box";
}
}
EOF
% echo 'dhcp_enable="YES"' >>/etc/rc.conf
% /usr/local/etc/rc.d/isc-dhcpd.sh start
Of course, you also need to set up NFS and TFTP:
[nfs]
% echo 'nfs_server_enable="YES"' >>/etc/rc.conf
% echo 'mountd_enable="YES"' >>/etc/rc.conf
% echo '/box -maproot=root -network 10.0.0.0 -mask 255.255.255.0' >>/etc/exports
% /etc/rc.d/nfsserver start
% /etc/rc.d/mountd start
[tftp]
% mkdir /tftpboot
% cp /box/boot/pxeboot /tftpboot
% sed -i.bak -e 's/^#tftp/tftp/' /etc/inetd.conf
% echo 'inetd_enable="YES"' >>/etc/rc.conf
% /etc/rc.d/inetd start
At this point, if I didn't miss anything, you should be able to just
switch on your test box and watch it boot.
DES
--
Dag-Erling Smørgrav - des at des.no
More information about the freebsd-fs
mailing list