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



## animortis (Jan 30, 2022)

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*

Boot to the live installer.
On the menu, instead of choosing “Installer,” choose “Shell”.
List the available disks.
sysctl kern.disks

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.
Clear and initialize your first disk. The first step destroys anything on the disk and the second initializes it as a gpt device.
gpart destroy -F ada0
gpart create -s gpt ada0

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.
gpart add -a 4k -t efi -s 512M -l efi ada0
newfs_msdos -F 32 -c 1 /dev/ada0p1
mount -t msdosfs -o longnames /dev/ada0p1 /mnt
mkdir -p /mnt/EFI/BOOT
cp /boot/loader.efi /mnt/EFI/BOOT/BOOTX64.efi

Create swap space. Size (-s) as appropriate. Here, we do 32 gigabytes and turn it on.
gpart add -t freebsd-swap -s 32G -l freebsd-swap ada0
swapon /dev/ada0p2

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.
gpart add -t freebsd-zfs -l system ada0

Now we need to partition. Initialize ZFS tools.
zfs import

Mount a tmpfs and create your zpool. The pool name (zroot here) can be anything, though "tank" is usually recommended in other guides.
mount -t tmpfs tmpfs /mnt
zpool create -o altroot=/mnt zroot ada0p3

Create the file system hierarchy.
Set compression.
zfs set compression=on zroot

Create a boot environment hierarchy and set up so you can install.
zfs create -o mountpoint=none zroot/ROOT
zfs create -o mountpoint=/ -o canmount=noauto zroot/ROOT/default
mount -t zfs zroot/ROOT/default /mnt
ln -s /usr/home /mnt/home



Installing the system​
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.
cd /mnt
tar xvJf /usr/freebsd-dist/base.txz
tar xvJf /usr/freebsd-dist/kernel.txz
tar xvJf /usr/freebsd-dist/lib32.txz

Configure the boot environment
zpool set bootfs=zroot/ROOT/default zroot

Chroot in and configure fstab for swap and rc.conf and loader.conf to load the ZFS drivers.
chroot /mnt
echo /dev/ada0p2 none swap sw 0 0 > /etc/fstab
sysrc zfs_enable=YES
echo zfs_load=”YES” >> /boot/loader.conf

Set the timezone, network and hostnames.
tzsetup
ifconfig
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.

sysrc ifconfig_re0=”DHCP”
Set the hostname.
vi /etc/hostname
Type the hostname you choose for the box. For this example, we’ll use and type:
freeb-strap




Set a root passwd.
passwd

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.


----------

