How to copy freenas-boot pool onto a usb drive and boot from it?

seltz

Dabbler
Joined
Dec 15, 2015
Messages
28
Out of curiosity, I'm trying to see if it's possible to copy of my freenas boot partition (currently on an ssd) onto a smaller usb drive then boot off it but ran into issues when booting (see results below) - any idea? I realize this isn't a normal use case and the general recommendation is to do mirroring.


Here's my process
:

#usb drive - wipe contents
gpart destroy -F /dev/da0
#usb drive - setup gpt partitioning scheme
gpart create -s gpt da0
#usb drive - setup boot partition
gpart add -b 40 -s 512k -t freebsd-boot da1
#usb drive - add boot partition
gpart add -t freebsd-zfs -l root da0

# usb drive: embed bootstrap code in partion scheme metadata
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 da0

#so now da0p1 has the bootcode, da0p2 has open space for root


# First attempt to just to do a mirror, you quickly
# realize you can’t do it with a small usb drive
# zpool attach freenas-boot /dev/ada0p2 /dev/da0p2
# > cannot attach /dev/da0p2 to /dev/ada0p2: device is too small
# So let’s try sending a snapshot

#usb drive: create zpool

zpool create freenas-boot2 /dev/da0p2

#current boot drive: create snapshot
zfs snapshot freenas-boot/ROOT@migrate

#current boot drive -> usb drive:
zfs send -R freenas-boot@migrate | zfs recv -Fdu freenas-boot2
zpool list #notice the other drive has copied contents now

Attempt to reboot, and boot off the flash drive instead.

Screen Shot 2020-06-28 at 5.32.56 PM.png



I have tried rebooting (back on the regular ssd) and observing that the usb drive seems to be having some space occupied:

freenas-boot 95.5G 1.01G 94.5G - - 0% 1% 1.00x ONLINE -
freenas-boot2 7G 1.27G 5.73G - - 0% 18% 1.00x ONLINE -

Though after trying to mount (not sure I should be doing this) the filesystem it's empty. Did I mess up in sending the snapshot? I'm Assuming snapshots can be sent while the source volume is mounted.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
Don't do that.

Just save your config, install fresh to the USB stick and restore the config.

(USB sticks are no longer the recommended boot option... better to use a USB to SATA and SSD if you want to have trouble-free NAS operation).
 

seltz

Dabbler
Joined
Dec 15, 2015
Messages
28
Don't do that.

Just save your config, install fresh to the USB stick and restore the config.

(USB sticks are no longer the recommended boot option... better to use a USB to SATA and SSD if you want to have trouble-free NAS operation).

I'm trying to see what's possible rather than what one should do. I do understand the normal recommendation is to do a fresh install, use an entire disk for freenas-boot, etc. There are people who have successfully managed to mirror freenas-boot then boot off it.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
I don't think there is ever a good reason to do that.

The trick will probably be marking the partition as active/bootable (fdisk)
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
I did it with mirroring, but you need a drive the same size or larger for that.
I doubt you can get it to boot as long as the pool is not called "freenas-boot". Which you cannot create a second time from a running FreeNAS.
Hence attach -> mirror -> resilver -> detach old drive.
 

seltz

Dabbler
Joined
Dec 15, 2015
Messages
28
Top