Install FreeBSD in external USB HDD disk with Auto-ZFS

Hello,

I'm using a laptop with a single M2 ssd disk with FreeBSD installed (auto-zfs).
Soon I will send my laptop to warranty and I'm thinking do a installation on a external USB HDD drive and import my home so I can connect to other laptop without toutching its internal disk.
Today I've boot FreeBSD in a USB pen and choosed "Auto-ZFS" but it points to my internal SSD.
Is there a way to work around this or clone internal disk to external one?

Other think, in the future I will use external disk as archive and backup using regular snapshots.

Thanks,

Nuno Teixeira
 
D

Deleted member 70435

Guest
Yes, there is a way, it's as if you were going to make a backup of the partition. but don't rely on the external disk, to have your system fully functional. problems can appear

 
clone internal disk to external one
One method to clone the laptop disk on the USB disk is to send and receive a ZFS data stream.

For the procedure, from the laptop system, on the USB drive
  • gpart(8) create partition table, add partitions efi and/or freebsd-boot, freebsd-swap, freebsd-zfs
  • for BIOS gpart(8) bootcode
  • for UEFI newfs_msdos(8) efi partition, mount_msdosfs(8) efi partition, create directories for the efi loader, copy efi loader
  • zpool-create(8) new-pool and altroot to a temporary mount point the USB freebsd-zfs partition
  • zfs-snapshot(8) -r laptop-pool, zfs-send(8) -R laptop-pool-snapshot | zfs-receive(8) -F new-pool
  • zpool-set(8) bootfs to new-pool/dataset
  • boot USB disk system
  • zpool set cachefile=/boot/zfs/zpool.cache new-pool
  • In case the USB disk is booted from the laptop and zfs-list(8) shows both pools datasets overlayed (mounted) on the same mount points, drop to single user mode, execute zpool-export(8) -f laptop-pool.
If you have difficulties at some of the steps, please ask.

If the laptop disk and the USB disk are the same size try Argentum's mirror method.

To make the partitioning of the USB disk simple, clone it: gpart backup laptop-disk | gpart restore -F usb-disk
 
zpool set cachefile=/boot/zfs/zpool.cache new-pool

Please, is that required for anything?



For import to be automated at boot time, a value need not be set.

Code:
% lsblk da1
DEVICE         MAJ:MIN SIZE TYPE                                          LABEL MOUNT
da1              0:177 466G GPT                                               - -
  <FREE>         -:-   1.0M -                                                 - -
  da1p1          0:178 466G freebsd-zfs                           gpt/Transcend <ZFS>
% zpool get cachefile Transcend august
NAME       PROPERTY   VALUE      SOURCE
Transcend  cachefile  -          default
august     cachefile  -          default
%
 
… external USB HDD drive … boot FreeBSD in a USB pen and choosed "Auto-ZFS" but it points to my internal SSD. …

When you choose to stripe: the installer should offer a choice of devices that includes the external USB HDD.

For example, with multiple virtual devices:

stripe.png one of two devices.png

(It's misleading; the result of choosing to stripe is not a stripe.)
 
Please, is that required for anything?
It's not a requirement but to tidy up the system.

The system on the USB disk may complain about failed cache file import of the original pool because the new pool is a exact clone and in the zpool.cache is still the pool configuration information of the original pool stored. It's not harmful but the system tries to import the original pool, recreating the zpool.cache file will silence the dmesg(8) notice:
Code:
cannot import 'zroot': no such pool or dataset
        Destroy and re-create the pool from
        a backup source.
cachefile import failed, retrying
 
When you choose to stripe: the installer should offer a choice of devices that includes the external USB HDD.

For example, with multiple virtual devices:

View attachment 14207 View attachment 14208

(It's misleading; the result of choosing to stripe is not a stripe.)
Ok, nice. I will try and see if USB HDD shows up listed and try instalation.
I will show results soon.
Thanks all for helping
 
When you choose to stripe: the installer should offer a choice of devices that includes the external USB HDD.

For example, with multiple virtual devices:

View attachment 14207 View attachment 14208

(It's misleading; the result of choosing to stripe is not a stripe.)
Ok, i did it and external disk showed up as da0 and I checked it up.
After a while a warning shows up:
---
There are multiple "FreeBSD" EFI boot entries, would you like to remove them all and add a new one? (I've started smoking hard/very nervous)
<YES> <NO>
---

This is very dangerous step for me since I'm testing in my only laptop I have, but do you know what happens when choosing yes or no ? :)
 
… do you know what happens when choosing yes or no ? …

I don't know, sorry, but here's the relevant commit:


At a glance: there is, at least, use of efibootmgr(8).

Without installing, you can run efibootmgr -v to begin getting an idea of how things are.

If, during installation, you opt to not remove entries, then you can use efibootmgr later to tidy things.



Side note: are you installing STABLE or CURRENT? Just curious.
 
I don't know, sorry, but here's the relevant commit:


At a glance: there is, at least, use of efibootmgr(8).

Without installing, you can run efibootmgr -v to begin getting an idea of how things are.

If, during installation, you opt to not remove entries, then you can use efibootmgr later to tidy things.



Side note: are you installing STABLE or CURRENT? Just curious.
CURRENT as I use at my laptop
 
Top