Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== Installing FreeBSD Root on ZFS using GPT ====== ===== Manually Installing FreeBSD on ZFS ===== This guide assumes you want to manually creating the pool, to change default settings, or to not use the entire disk. If you just want to setup ZFS on the entire disk, use the 'ZFS' option in the bsdinstall partitioning menu. - Boot %%FreeBSD%% install DVD or USB Memstick - Select Install, and answer questions such as keyboard layout and hostname - When prompted to partition the disk: - If you do not want to use the entire disk, skip to the [[#Create_Partitions|Partition Creation]] section. - choose the 'shell' option. In this mode you are expected to create a root file system mounted under /mnt that the installer will install the operating system into. - Determine which disk you wish to use: <code> camcontrol devlist </code> %%<%%TOSHIBA HDWN180 GX2M> at scbus7 target 0 lun 0 (ada0,pass1) SATA disks usually start with ada followed by a number. SAS and USB disks start with da followed by a number. The rest of this page assumes the disk is ada0; replace it with your disk device's name in all commands below. - Create a fresh partition table: <code> gpart destroy ada0 gpart create -s gpt ada0 </code> <callout type="warning"> This will erase all data on the disk! </callout> - Create the bootcode partition: - for UEFI Boot: <code> gpart add -a 4k -s 260M -t efi ada0 # Create a FAT32 partition 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 umount /mnt </code> - for Legacy Boot: <code> gpart add -a 4k -s 512K -t freebsd-boot ada0 gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0 </code> ===== Create Partitions ===== Add some partitions for %%FreeBSD%% to use: a freebsd-swap partition and a freebsd-zfs partition. * -a %%<%%number>: controls alignment. * -s %%<%%size>: sets the size of the partition; if not set, it will default to the remaining space on the disk. * -l %%<%%name> sets the label for the partition. Create the swap and zfs partitions <code> gpart add -a 1m -s 4G -t freebsd-swap -l swap0 ada0 gpart add -a 1m -t freebsd-zfs -l disk0 ada0 </code> <callout type="info"> **Note:** While a [[/RootOnZFS#ZFS_Swap_Volume|ZFS Swap Volume]] can be used instead of the freebsd-swap partition, it is not recommended, and crash dumps can't be saved to the ZFS Swap Volume. </callout> ===== Create the Pool ===== - Find the device for the freebsd-zfs partition created above <code> gpart show -p ada0 </code> => 40 15628053088 ada0 GPT (7.3T) 40 1024 ada0p1 freebsd-boot (512K) 1064 984 - free - (492K) 2048 4194304 ada0p2 freebsd-swap (2.0G) 4196352 15623856776 ada0p3 freebsd-zfs (7.3T) - Mount a tmpfs to /mnt <code> mount -t tmpfs tmpfs /mnt </code> - Create the ZFS Pool <code> zpool create -o altroot=/mnt zroot ada0p3 </code> <callout type="info"> **Note:** zroot is the name of the ZFS Pool; it could be anything, e.g. tank, data, mypool, ... </callout> ===== Create the ZFS file system hierarchy ===== {{page>RootOnZFS/PoolLayout&nofooter&noeditbtn}} ===== Configure Boot Environment ===== <code> zpool set bootfs=zroot/ROOT/default zroot </code> ===== Finish install ===== - Create /tmp/bsdinstall_etc/fstab <code> cat << EOF > /tmp/bsdinstall_etc/fstab # Device Mountpoint FStype Options Dump Pass# /dev/gpt/swap0 none swap sw 0 0 EOF </code> - Exit Shell Partitioning mode, bsdinstall will continue and complete the installation. <code> exit </code> - In the post installation step, when asked if you would like to drop into the installed system, choose yes and run the following two commands. <code> sysrc zfs_enable="YES" echo 'zfs_load="YES"' >> /boot/loader.conf </code> ---- {{tag>HowTo}} rootonzfs/gptzfsboot.txt Last modified: 2023/05/05 14:12by RebeccaCran