DragonFly BSD

Installation

This document describes the installation of DragonFly BSD. This process uses a bootable DragonFly CD or USB disk image, usually referred to as a 'live CD' or 'USB disk image'. These are available at one of the current mirrors, which distribute the images by various protocols.

It is recommended to install DragonFly with USB because USB is faster and more flexible.


Installation from CD or USB

Downloading DragonFly BSD

Choose the closest mirror site and go to iso-images/ directory. Then choose installation image:

dfly-x86_64-X.X.X_REL.iso uncompressed image for CD and VM.
dfly-x86_64-X.X.X_REL.iso.bz2 compressed image for CD and VM.
dfly-x86_64-X.X.X_REL.img.bz2 compressed image for USB.

Then download md5.txt and verify image:

% md5 -C md5.txt dfly-x86_64-X.X.X_REL.*
(MD5) dfly-x86_64-X.X.X_REL.img.bz2: OK
(MD5) dfly-x86_64-X.X.X_REL.iso: OK
(MD5) dfly-x86_64-X.X.X_REL.iso.bz2: OK

Creating install media

Decompress downloaded image if it is compressed:

% bzip2 -d dfly-x86_64-X.X.X_REL.iso.bz2

Flash drives

A bootable USB flash drive can be created by attaching the target device and copying over the image with dd(1).

Using DragonFly BSD, assuming device was recognized as sd8:

# dd if=dfly-x86_64-*_REL.img of=/dev/sd8 bs=1m

CD

DragonFly's image is too big to fit on CD-ROM, however, it fits on DVD.

You can create a bootable CD on DragonFly BSD by using cdrecord(1)

# cdrecord -tao dfly-x86_64-*_REL.iso

Performing a simple install

The installer is designed to install DragonFly BSD with a minimum of user intervention. In fact, you can often just hit [Enter] to get a good DragonFly BSD install, moving your hands to the rest of the keyboard only to make choises.

After dmesg(8) is shown, you will see the first installer question:

...
Welcome to DragonFly!

To start the installer, login as 'installer'. To just get a shell prompt, login as 'root'

DragonFly/x86_64 (Amnesiac) (ttyv0)

login: 

Type installer and press [Enter] and follow the instructions.

Manual Installation (all types) (assumes whole disk)

WARNING! These instructions assume that 'da0' is the drive you are installing to and that you booted from somewhere else. 'da0' in these instructions must not contain anything you used to boot the system from. Normally you will have booted from some other media, such as a USB stick, CD, or the network.

WARNING! These instructions assume that you are not sharing the drive with any other operating system and have no data on the drive that you wish to keep. Generally speaking, my recommendation is to not have multi-OS boot setups (its too easy to mistakenly wipe them when messing around with other installations). Instead, invest in a hot-swap drive bay and put each OS on its own SSD.

To do a manual installation you need to initialize the disk. DragonFlyBSD uses a modified fdisk which works on any-sized disk by having the kernel recognize the maximum size fdisk supports and translate that to the whole disk's actual size. You need to install the boot sector and also setup a bootable DragonFlyBSD disklabel.

# fdisk -IB /dev/da0

# disklabel -r -w -B /dev/da0s1 auto

Edit the label and create three partitions: a, b, and d. The 'a' partition is going to be /boot and needs to be a 1GB UFS partition. 'b' is your swap and should be roughly 2x main memory (we recommend at least 4GB or more, particularly if you will be running browsers). 'd' is your root partition.

# disklabel -e da0s1

a: 1G 0 4.2BSD
b: 8G * swap
d: * * HAMMER

Manual Non-Crypto Installation

Format the filesystems and mount them:

# newfs /dev/da0s1a
# newfs_hammer -L ROOT /dev/da0s1d
# mount /dev/da0s1d /mnt
# mkdir /mnt/boot
# mount /dev/da0s1a /mnt/boot

Once you have them mounted, copy from a working DragonFly installation. This can be from installation media or via NFS if you have setup the network and have a server somewhere. Two cpdup commands are needed since we have two partitions. If the source of your image is broken up into additional partitions, you may have to cpdup each one (cpdup nominally stops at mount boundaries on the source):

# cpdup /boot /mnt/boot
# cpdup / /mnt

Finally, edit "/mnt/boot/loader.conf", "/mnt/etc/fstab", and "/mnt/etc/rc.conf" to point to your disk. At a minimum you will need this line in your "/mnt/boot/loader.conf" (we recommend configuring by serial number, which you can get from the dmesg output, but if you don't want to then use the drive name which might be something like 'da0s1d'):

vfs.root.mountfrom="hammer:serno/SERIALNUMOFDISK.s1d"

Your "/etc/fstab" file should contain something like the below:

serno/SERIALNUMOFDISK.s1a    /boot           ufs     rw              1 1
serno/SERIALNUMOFDISK.s1b    none            swap    sw              0 0
serno/SERIALNUMOFDISK.s1d    /               hammer  rw              1 1

Finally, unmount the partitions and reboot the machine. Once the machine is in reset, before it hits the BIOS, unplug your installation media:

# umount /mnt/boot
# umount /mnt
# reboot

Manual Crypto Installation

To setup a crypto system follow the generic non-crypto steps above. Make sure that your boot drive has a "/boot/kernel/initrd.img.gz" file in as the system will need to bootstrap through MD0 in order to mount an encrypted root. In this example I am also encrypting swap.

If your drive partitions previously contained unencrypted data and you want to wipe it, you can dd /dev/urandom to the target partitions. It can take many hours to do this so you might decide to skip this optional step:

# dd if=/dev/urandom of=/dev/da0s1b bs=32k
# dd if=/dev/urandom of=/dev/da0s1d bs=32k

Setup an encrypted swap and root partition as shown below:

# kldload dm
# cryptsetup --key-size 256 --hash sha512 -y luksFormat /dev/da0s1b
# cryptsetup --key-size 256 --hash sha512 -y luksFormat /dev/da0s1d
# cryptsetup luksOpen /dev/da0s1b swap
# cryptsetup luksOpen /dev/da0s1d root

Format the filesystems and mount them. Note that the boot partition is not encrypted.

# newfs /dev/da0s1a
# newfs_hammer -L ROOT /dev/mapper/root
# mount /dev/mapper/root /mnt
# mkdir /mnt/boot
# mount /dev/da0s1a /mnt/boot

Once you have them mounted, copy from a working DragonFly installation. This can be from installation media or via NFS if you have setup the network and have a server somewhere. Two cpdup commands are needed since we have two partitions. If the source of your image is broken up into additional partitions, you may have to cpdup each one (cpdup nominally stops at mount boundaries on the source):

# cpdup /boot /mnt/boot
# cpdup / /mnt

Finally, edit "/mnt/boot/loader.conf", "/mnt/etc/fstab", and "/mnt/etc/rc.conf" to point to your disk. At a minimum you will need this line in your "/mnt/boot/loader.conf" (we recommend configuring by serial number, which you can get from the dmesg output, but if you don't want to then use the drive name which might be something like 'da0s1d').

initrd.img_load="YES"
initrd.img_type="md_image"
vfs.root.mountfrom="ufs:md0s0"
vfs.root.realroot="crypt:hammer:serno/SERIALNUMOFDISK.s1d:root"
dm_load="YES"
dm_target_crypt_load="YES"

Your "/etc/fstab" file should contain something like the below:

serno/SERIALNUMOFDISK.s1a    /boot           ufs     rw              1 1
/dev/mapper/root              /               hammer  rw              1 1

You can setup the encrypted swap via the "/etc/rc.local" file with the following lines:

# cryptsetup luksOpen /dev/serno/SERIALNUMOFDISK.s1b swap
#swapon /dev/mapper/swap

Finally, unmount the partitions and reboot the machine. Once the machine is in reset, before it hits the BIOS, unplug your installation media:

# umount /mnt/boot
# umount /mnt
# reboot