ZFS How do I make sure usb external disks added without raid to zpool are properly seen by the system?

Last time I tried this, I had trouble where the box would not boot. I think the device id of the usb external disks changes on reboot.
I wonder if this is solved by plugging all the external drives in and rebooting before I add anything.
Should there be a way that ZFS just knows which drive is which? No matter what device id the os boots up and assigns to it?
I have read about UUID and wonder should I do something besides just add the usb external drives to the zpool?
The zpool now has 2x500g internal drives. They are 4kb sectors.

Upon reboot I wonder if the usb drives appear in a different order?
The UUID I think is supposed to sort this out so the system still knows which disk is which.

I am not doing raid just adding the disks to the zpool so I get that 1 disk fails means loss.
External usb drives will connect to:
1 usb3 pci expansion card 2 ports
2 one port of the usb multiple 4 port expander plugged into regular usb2 port on back of the desktop pc

Any tips?

Code:
root@mercantilism:~ # uname -a
FreeBSD mercantilism 12.1-RELEASE-p7 FreeBSD 12.1-RELEASE-p7 GENERIC  amd64
root@mercantilism:~ # d
Filesystem            Size    Used   Avail Capacity  Mounted on
zroot/ROOT/default    8.1G    4.1G    4.0G    51%    /
devfs                 1.0K    1.0K      0B   100%    /dev
zroot/var/log         4.0G    552K    4.0G     0%    /var/log
zroot/usr/home        864G    860G    4.0G   100%    /usr/home
zroot/tmp             4.1G     66M    4.0G     2%    /tmp
zroot                 4.0G     88K    4.0G     0%    /zroot
zroot/usr/ports       4.0G     88K    4.0G     0%    /usr/ports
zroot/var/crash       4.0G     88K    4.0G     0%    /var/crash
zroot/var/audit       4.0G     88K    4.0G     0%    /var/audit
zroot/usr/src         4.0G     88K    4.0G     0%    /usr/src
zroot/var/mail        4.0G    120K    4.0G     0%    /var/mail
zroot/var/tmp         4.0G     88K    4.0G     0%    /var/tmp
root@mercantilism:~ # zpool status
  pool: zroot
state: ONLINE
  scan: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        zroot       ONLINE       0     0     0
          ada0p3    ONLINE       0     0     0
          ada1p3    ONLINE       0     0     0

errors: No known data errors
root@mercantilism:~ # sysctl vfs.zfs.min_auto_ashift
vfs.zfs.min_auto_ashift: 12
root@mercantilism:~ # cat /etc/rc.conf
hostname="mercantilism"
ifconfig_re0="DHCP"
sshd_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
zfs_enable="YES"
postgresql_enable="YES"
 
ZFS doesn't care about the drive's nomination. That said, if you add a drive and the controller shifts everything around on a running system then ZFS can and will get confused.

USB drives typically show up as da*. So they're not going to interfere with your SATA drives, which are ada*.
 
ZFS doesn't care about the drive's nomination. That said, if you add a drive and the controller shifts everything around on a running system then ZFS can and will get confused.

USB drives typically show up as da*. So they're not going to interfere with your SATA drives, which are ada*.
The old problem cropped up in the past when I rebooted. If I remember correctly, it was not the first reboot.....like a few days later. Hmmm.
 
ah ha!!
https://forums.freebsd.org/threads/labeling-partitions-done-right-on-modern-computers.69250
gpt lables to get partitions right ufs and zfs on modern computers


Code:
Another important use case: ZFS
Creating a pool, using regular device names is a bad idea. I would honestly compare that to pointing a knife to your chest, closing your eyes and then start running.
On a small storage pool you may be able to sort out problems with changing device names, but with huge pools or root-on-zfs, the flexibility of labels can definitely save you some headache.
Labels really shine when you name them after the physical position of the disks inside a backplane or raid encosure, like left, 2nd-from-left, 3rd-from-left.
For small pools, naming the disks after a random topic can also be handy. I have a small pool of 4 loose external USB disks, each with a sticker on it, that corresponds to it's GPT label.
flour, yeast, water and salt, those drives can be connected randomly to any USB port or hub on any computer and the pool will always import nicely.

To create an example pool, using two mirrored SATA drives, one would do something like to the following:
Code:
# gpart create -s gpt ada0
# gpart create -s gpt ada1
# gpart add -t freebsd-zfs -l backup-left ada0
# gpart add -t freebsd-zfs -l backup-right ada1
zpool create <your options> backup mirror gpt/backup-left gpt/backup-right
The output from zpool status backup would look like this:
Code:
pool: backup
     id: 2004489531562853512
  state: ONLINE
action: The pool can be imported using its name or numeric identifier.
config:

    backup                    ONLINE
      mirror-0                ONLINE
        gpt/backup-left       ONLINE
        gpt/backup-right      ONLINE
Now you can add a drive, move the drives around, pull them out and put them back as you like. Ahhh, I love GPT labels :D
 
What about gpart() labels??? I seem to remember a How-To recently posted that may be of interest...
gpt labels are preferable to geom labels. gpt labels are a part of the partition and won't change unless you modify them, but geom labels are separate from the partion. As such, you should be able to take a zpool from one computer and move it to another without the drives getting out of order, which is presumably one of the reasons for the original question.

Just make sure to do any labeling before attaching them to the pool as weird things can happen with them being listed under labels rather than gpt in /dev.

EDIT: By the same logic, it's a really, really good idea to label the physical disks as related to the label that they're given so that you know which drives to replace when you need to do so in the future.
 
Back
Top