Skip to content

Instantly share code, notes, and snippets.

@liweitianux
Last active January 2, 2024 06:15
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save liweitianux/45c1abf7a692394d4a7702e192a8a7e1 to your computer and use it in GitHub Desktop.
Save liweitianux/45c1abf7a692394d4a7702e192a8a7e1 to your computer and use it in GitHub Desktop.
DragonFly BSD Installation (MBR, HAMMER2 boot+root)

DragonFly BSD Installation

1. Create Disk Slice

Assume the disk is /dev/da8, to create a slice of about 100 GB.

dfly# cat > fdisk.conf << _EOF_
p  1  108  1  209712510
a  1
_EOF_

dfly# fdisk -f fdisk.conf /dev/da8

dfly# fdisk -B /dev/da8

(fdisk(8) will round the start and size to cylinder boundaries.)

2. Create Partitions

I'm naming the disklabel with DFly, and will use this name to mount the partitions.

dfly# disklabel -r -w /dev/da8s1 auto DFly

dfly# disklabel /dev/da8s1 > disklabel.txt

dfly# cat >> disklabel.txt << _EOF_
a:  96g  0  HAMMER2
b:    *  *  swap
_EOF_

dfly# disklabel -R /dev/da8s1 disklabel.txt

dfly# disklabel -B /dev/da8s1

3. Create Filesystems

I'm placing both / and /boot on the same HAMMER2 partition, with different PFSes, avoiding a separate UFS partition for /boot.

dfly# newfs_hammer2 -L ROOT /dev/da8s1a

dfly# mkdir /mnt/target
dfly# mount /dev/da8s1a@ROOT /mnt/target

dfly# hammer2 -s /mnt/target pfs-create BOOT
dfly# mkdir /mnt/target/boot
dfly# mount /dev/da8s1a@BOOT /mnt/target/boot

NOTE: The above setup may fail to boot, because of Bug #3202: Cannot boot from HAMMER2. This needs to be confirmed.

One workaround (also need to confirm) in my head is: first create the BOOT PFS with newfs_hammer2 -L BOOT, and then create the ROOT PFS with hammer2 pfs-create ROOT.

4. Copy System

Download the .img image and mount it for installation:

dfly# vnconfig -c vn ~aly/downloads/DragonFly-x86_64-20190325-DEV-v5.5.0.307.g3f3e6.img
# output: vn4

dfly# mkdir /mnt/system
dfly# mount /dev/vn4s2a /mnt/system

Copy the system over, clean up, and adjust /etc:

dfly# cpdup -vI /mnt/system /mnt/target
dfly# cpdup -vI /mnt/system/boot /mnt/target/boot

dfly# cd /mnt/target
dfly# rm -r README* autorun* dflybsd.ico index.html

dfly# rm -r etc
dfly# mv etc.hdd etc

Umount the system image:

dfly# umount /mnt/system
dfly# vnconfig -u vn4

5. Configurations

Booting:

dfly# cat > /mnt/target/boot/loader.conf << _EOF_
vfs.root.mountfrom="hammer2:part-by-label/DFly.a@ROOT"
_EOF_

Filesystems:

dfly# cat > /mnt/target/etc/fstab << _EOF_
/dev/part-by-label/DFly.a@ROOT  /       hammer2 rw      1 1
/dev/part-by-label/DFly.a@BOOT  /boot   hammer2 rw      1 1
/dev/part-by-label/DFly.b       none    swap    sw      0 0
_EOF_

System settings:

root# cat >> /mnt/target/etc/rc.conf << _EOF_
dumpdev="/dev/part-by-label/DFly.b"
hostname="???"
ifconfig_<name>="DHCP"
sshd_enable="YES"
dntpd_enable="YES"
_EOF_

Root password:

dfly# chroot /mnt/target passwd

6. Finish Up

dfly# umount /mnt/target/boot /mnt/target
dfly# reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment