Hi all,
I have gone through the wiki and countless other posts on the Internet, most of them list commands but offer very little information on why that command is being used or why a particular method is being used.
I am trying to write up the basic steps needed to set up as system with GELI+ZFS on root on mirrored drives. I would greatly appreciate your help in filling the gaps and correcting any errors.
I am mainly following: https://wiki.freebsd.org/RootOnZFS/GPTZFSBoot/9.0-RELEASE
I an currently testing it in a VM and the set up is as follows:
Create the basic three partitions:
Write boot code to both disks:
Load necessary modules:
Encrypt the disks with only a passphrase:
(I'm not sure why a lot of how-tos suggest using key files but then place them in /boot which is easily accessible, am I missing something?)
Creating ZFS datasets:
Then exit out of the shell and go back to bsdinstall. Install as normal and then get back to the shell after bsdinstall finishes. This is where I am not sure, I thought everything would be installed under tank/ROOT (as it was set as the /) but it got installed under /tank.
At the end of bsdinstall, it gives an option to get into the installed system to do final setting-up. Get back to the shell (this is the newly installed system and the PWD is tank dataset not ROOT, everything was extracted to tank not ROOT), then:
Otherwise one cannot use ZFS commands in the new environment.
Add the necessary variables/settings:
Then create a zpool cache file:
Then move the boot folder to the second partition under the bootdir dataset:
Then set the final mount points:
Exit and reboot.
That's the basic outline. I would greatly appreciate if you could point out errors and offer some explanation.
Cheers,
Yudi
I have gone through the wiki and countless other posts on the Internet, most of them list commands but offer very little information on why that command is being used or why a particular method is being used.
I am trying to write up the basic steps needed to set up as system with GELI+ZFS on root on mirrored drives. I would greatly appreciate your help in filling the gaps and correcting any errors.
I am mainly following: https://wiki.freebsd.org/RootOnZFS/GPTZFSBoot/9.0-RELEASE
I an currently testing it in a VM and the set up is as follows:
- 2 GB RAM
- two HDDs 8 GB each mirrored - three partitions
- for boot code 128 KB
- for /boot 2 GB
- for the rest of the system and encrypted
- no key file for encrypted partitions, only passphrase
- using 9.1-RELEASE
- there will be no swap or handling of 4k drives, just to keep it as simple as possible.
Create the basic three partitions:
Code:
gpart destroy -F ada0
gpart destroy -F ada1
gpart create -s gpt da0
gpart create -s gpt da1
gpart add -s 128 -t freebsd-boot da0
gpart add -s 128 -t freebsd-boot da1
gpart add -s 2G -t freebsd-zfs da0
gpart add -s 2G -t freebsd-zfs da1
gpart add -t freebsd-zfs da0
gpart add -t freebsd-zfs da1
Write boot code to both disks:
Code:
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 da0
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 da1
Load necessary modules:
Code:
kldload opensolaris (I'm not sure why this is needed as loading zfs also loads opensolaris?)
kldload zfs
kldload geom_eli
(I'm not sure why a lot of how-tos suggest using key files but then place them in /boot which is easily accessible, am I missing something?)
Code:
geli init -b -s 4096 /dev/da0p3
geli init -b -s 4096 /dev/da1p3
geli attach /dev/da0p3
geli attach /dev/da1p3
Creating ZFS datasets:
Code:
zpool create bootdir mirror /dev/da0p2 /dev/da1p2
zpool set bootfs=bootdir bootdir
zpool create -R /mnt -O canmount=off tank mirror /dev/da0p3.eli /dev/da1p3.eli
zfs create -o mountpoint=/ tank/ROOT
zfs set mountpoint=/mnt/ROOT/bootdir bootdir
zfs mount bootdir
Then exit out of the shell and go back to bsdinstall. Install as normal and then get back to the shell after bsdinstall finishes. This is where I am not sure, I thought everything would be installed under tank/ROOT (as it was set as the /) but it got installed under /tank.
At the end of bsdinstall, it gives an option to get into the installed system to do final setting-up. Get back to the shell (this is the newly installed system and the PWD is tank dataset not ROOT, everything was extracted to tank not ROOT), then:
mount -t devfs devfs /dev
.Otherwise one cannot use ZFS commands in the new environment.
Add the necessary variables/settings:
Code:
echo ‘zfs_enable=â€YESâ€â€˜ >> /etc/rc.conf
echo ‘vfs.root.mountfrom=â€zfs:tankâ€â€˜ >> /boot/loader.conf (Is this correct? or is it needed?)
echo ‘zfs_load=â€YESâ€â€˜ >> /boot/loader.conf
echo ‘geom_eli_load=â€YESâ€â€˜ >> /boot/loader.conf
Then create a zpool cache file:
zpool set cachefile=/boot/zfs/zpool.cache tank
.Then move the boot folder to the second partition under the bootdir dataset:
Code:
mv boot ROOT/bootdir/
ln -fs ROOT/bootdir/boot
Then set the final mount points:
Code:
zfs unmount -a (this throws an error, cannot unmount /mnt, it's busy)
zfs set mountpoint=legacy tank
zfs set mountpoint=/ tank/ROOT
zfs set mountpoint=/bootdir bootdir
Exit and reboot.
That's the basic outline. I would greatly appreciate if you could point out errors and offer some explanation.
Cheers,
Yudi