Command-Line Manual Installation How-To (With Video If Needed)

Good afternoon everyone:

This is a continuation of my Reddit thread and YouTube video detailing how to install FreeBSD for a very basic desktop using the command line as found on the installer disk exclusively. I have three main reasons for doing this, as stated on the thread:

Firstly, yes, the automatic installer for FreeBSD is pretty great. Better than any Linux one I've seen. And though I am no expert, I had three goals making this.

1: To help you better learn how to use a lot of tools for customizing FreeBSD. ZFS is the big one. ZFS can be configured six ways to Sunday and be used to provide a lot of configuration and compartmentalization you may not see or do if you do it on the installer. (This guide keeps it very simple, and admins and security pros may cringe going through it, so please remember this is for a bare-bones desktop system. Nothing more. Feel free to customize further if you know how.)

2: You can get to really control what your system looks like. It's the same kind of appeal of building your own car or computer: You know everything that went into it and when. You make all your own decisions about the software as well as the hardware. Yes, the OS has certain demands for how it's laid out, but you can add all kinds of components manually this way.

3: And I found Linux's usually had a way to do this and guides and stuff, but I couldn't find a similar guide for FreeBSD. And that was a shame because it's just as capable. So I decided to close the gap.

Booting and Partitioning
  1. Boot to the live installer.
  2. On the menu, instead of choosing “Installer,” choose “Shell”.
  3. List the available disks.
    1. sysctl kern.disks
  4. FreeBSD uses a system called “geom” to manage its disks. We will use separate tools to install with this, specially geom partition, or ‘gpart’. For the purpose of this instruction guide, we will assume the disk is called ada0.
  5. Clear and initialize your first disk. The first step destroys anything on the disk and the second initializes it as a gpt device.
    1. gpart destroy -F ada0
    2. gpart create -s gpt ada0
  6. Create your boot partition. This will be an efi-type FAT32 device as EFI requires this. Then we will copy our EFI bootloader from the live CD.
    1. gpart add -a 4k -t efi -s 512M -l efi ada0
    2. newfs_msdos -F 32 -c 1 /dev/ada0p1
    3. mount -t msdosfs -o longnames /dev/ada0p1 /mnt
    4. mkdir -p /mnt/EFI/BOOT
    5. cp /boot/loader.efi /mnt/EFI/BOOT/BOOTX64.efi
  7. Create swap space. Size (-s) as appropriate. Here, we do 32 gigabytes and turn it on.
    1. gpart add -t freebsd-swap -s 32G -l freebsd-swap ada0
    2. swapon /dev/ada0p2
  8. Create the rest of the disk. We’re using ZFS because ZFS is amazing. (If there are other disks, repeat this for the other disks.) Size does not need to be specified, it will use the remaining space automatically.
    1. gpart add -t freebsd-zfs -l system ada0
  9. Now we need to partition. Initialize ZFS tools.
    1. zfs import
  10. Mount a tmpfs and create your zpool. The pool name (zroot here) can be anything, though "tank" is usually recommended in other guides.
    1. mount -t tmpfs tmpfs /mnt
    2. zpool create -o altroot=/mnt zroot ada0p3
  11. Create the file system hierarchy.
    1. Set compression.
      1. zfs set compression=on zroot
    2. Create a boot environment hierarchy and set up so you can install.
      1. zfs create -o mountpoint=none zroot/ROOT
      2. zfs create -o mountpoint=/ -o canmount=noauto zroot/ROOT/default
      3. mount -t zfs zroot/ROOT/default /mnt
      4. ln -s /usr/home /mnt/home

Installing the system​

  1. Install the system by copying the system files from the live CD. If there is a way to download these files off the web before uncompressing them, I'd love to hear it.
    1. cd /mnt
    2. tar xvJf /usr/freebsd-dist/base.txz
    3. tar xvJf /usr/freebsd-dist/kernel.txz
    4. tar xvJf /usr/freebsd-dist/lib32.txz
  2. Configure the boot environment
    1. zpool set bootfs=zroot/ROOT/default zroot
  3. Chroot in and configure fstab for swap and rc.conf and loader.conf to load the ZFS drivers.
    1. chroot /mnt
    2. echo /dev/ada0p2 none swap sw 0 0 > /etc/fstab
    3. sysrc zfs_enable=YES
    4. echo zfs_load=”YES” >> /boot/loader.conf
  4. Set the timezone, network and hostnames.
    1. tzsetup
    2. ifconfig
      1. This will show you the name of your ethernet port. In my instance, it’s re0. Use that to initialize it with DHCP in rc.conf.
    3. sysrc ifconfig_re0=”DHCP”
    4. Set the hostname.
      1. vi /etc/hostname
        1. Type the hostname you choose for the box. For this example, we’ll use and type:
          1. freeb-strap
  5. Set a root passwd.
    1. passwd
  6. That’s it. Reboot into your new FreeBSD desktop.

There's more configuration needed, and at this point I would reference the handbook to move forward. But this gets things to a bare-bones install so you can continue as you'd like.
 
Back
Top