This article briefly describes how to install DragonFlyBSD on a HAMMER filesystem, i.e. using HAMMER for the root filesystem. Note that I make the assumption that the DragonFly installation will use the entire disk (in my case this is disk ad4). Also make sure that the DragonFly version you are using includes my RootOnHammer patches which should be the case for any release after 2.0 and every snapshot ISO image from now on. Btw, the whole approach is similar to ZFSOnRoot, except that I will not use the installer.
Start the live-cd installer and enter the root prompt.
Partition ad4 creating one slice covering the entire disk.
fdisk -B -I ad4
Generate a disklabel in your favourite editor that looks like the following one and save it under /tmp/disklabel.ad4s1.
# size offset fstype a: 262144 0 4.2BSD # 128.000MB b: 6291456 262144 swap # 3072.000MB c: 234441585 0 unused # 114473.430MB d: 227887984 6553600 4.2BSD # 111273.430MB
I'm using 128 MB for the boot partition (a), which should be enough to hold several kernels and it's modules. Note that I am using 3 GB for the swap partition (b). The remaining space is left for the HAMMER partition (d).
Then store the disklabel onto your disk:
disklabel -R -r ad4s1 /tmp/disklabel.ad4s1
Create the boot filesystem (UFS) and the HAMMER filesystem:
newfs /dev/ad4s1a newfs_hammer -L Root /dev/ad4s1d
At first we set up the boot filesystem by mounting it and copying the /boot directory, the kernel and it's modules onto it:
mount /dev/ad4s1a /mnt cpdup -vvv /boot /mnt/boot cpdup -vvv /kernel /mnt/kernel cpdup -vvv /modules /mnt/modules
Then we adjust /mnt/boot/loader.conf to use ad4s1d (our HAMMER partition) as root filesystem:
touch /mnt/boot/loader.conf echo 'vfs.root.mountfrom="hammer:ad4s1d"' >> /mnt/boot/loader.conf
That's all we need to do for the boot partition, so we unmount it.
Next we continue with the HAMMER partition:
mount_hammer /dev/ad4s1d /mnt
Onto this partition we will install all remaining parts of DragonFlyBSD. It's as easy as copying the files from the live-cd to the HAMMER partition:
cpdup -vvv /bin /mnt/bin cpdup -vvv /sbin /mnt/sbin cpdup -vvv /root /mnt/root cpdup -vvv /usr /mnt/usr cpdup -vvv /var /mnt/var cpdup -vvv /dev /mnt/dev cpdup -vvv /etc.hdd /mnt/etc cp /.cshrc /.profile /mnt mkdir /mnt/mnt /mnt/proc /mnt/tmp
We further want later on to mount the boot partition into /bootdir, and use /boot as short-cut (symlink) to /bootdir/boot:
mkdir /mnt/bootdir cd mnt ln -s bootdir/boot boot cd ..
We also want to edit /mnt/etc/fstab to contain the following:
# Device Mountpoint FStype Options Dump Pass# /dev/ad4s1a /bootdir ufs rw 1 1 /dev/ad4s1b none swap sw 0 0 /dev/ad4s1d / hammer rw 1 1 /dev/cd0 /cdrom cd9660 ro,noauto 0 0 proc /proc procfs rw 0 0
You might want to edit /mnt/etc/rc.conf now or later, after we have booted into the system.
That's all, so we unmount the HAMMER root partition and reboot (don't forget to remove the live-cd):
umount /mnt reboot
Once we are up and running in our new HAMMER-powered DragonFly system, we want to set up the timezone edit /etc/rc.conf and set the root password. You can easily set your timezone via:
You also might want to make /usr/obj non-history aware:
chflags nohistory /usr/obj chflags noshistory /usr/obj # do we need this?
Checkout the pkgsrc sources:
cd /usr make pkgsrc-checkout
What I also found to be very useful is to extend /usr/pkg/etc/mk.conf for the following two lines:
This tells pkgsrc to not create a work directory within each pkgsrc package where it extracts the sources and compiles the application. Instead it will use /usr/obj.
As we don't want to backup and mirror all the contents of /usr/obj (which should be considered temporary data of no value), we can create it's own HAMMER pseudo-filesystem for it, which allows to treat it separately for pruning and mirroring operations.
rmdir /usr/obj cd /usr hammer pfs-master obj
As HAMMER's pseudo-filesystems are represented by symlinks, it isn't possible to assign access rights to them or flags like nohistory, but there should be a workaround using null mounts:
# We rename the PFS to obj.pfs mv /usr/obj /usr/obj.pfs # We create a directory /usr/obj, which holds the permissions mkdir /usr/obj # Finally we null mount /usr/obj.pfs on top of /usr/obj mount_null /usr/obj.pfs /usr/obj
We'd probably like to do the same for /tmp:
rm -rf /tmp mkdir /tmp chmod 1777 /tmp # sticky flags for /tmp cd / hammer pfs-master tmp.pfs mount_null /tmp.pfs /tmp
Enjoy DragonFly and HAMMER!