Solved Best practise to access drives with unique identifiers?

My new FreeBSD 10.2 server consists of one SSD for the base system, several HDDs for data storage and a hot swap bay which I use for backups. All drives are encrypted with geli and I use ZFS on all internal disks. I have written a small script to automatically attach encrypted disk, import ZFS pools etc.. The problem is that as soon as I start my server with a disk in the hot swap bay the device numbering changes (e.g. /dev/ada5 becomes /dev/ada6 and the HDD in the bay gets /dev/ada5).

I have already figured out, that all my storage disks also appear as /dev/diskid/DISK-<disk serial> and I can use them as a unique identifier to import the ZFS pool. But... Does someone has an idea why I only see my storage disks and not my SSD in /dev/diskid/*?

I have a script to unmount all storage disks and put these drives in standy-by mode to save energy ( camcontrol standby /dev/adaX). The problem is that it doesn't work with "diskid"-identifiers. camcontrol standby /dev/diskid/DISK-... gives me the error message camcontrol: cam_get_device: unable to find device unit number. Is there a unique disk identifier which I can use with camcontrol?
 
If you used GPT, GPT labels are easily set with gpart(8). See glabel(8) for general information on disklabels, but note that GPT labels are better than most because they require no extra metadata, they just go in the GPT.

The reason the SSD does not show other labels is because when a partition is mounted, the other labels "wither" and are hidden.
 
Thanks! Do you know how I can set GPT labels for my ZFS disks? Do I have to reformat them? gpart show /dev/ada1 gives me gpart: No such geom: /dev/ada1. I get the same error message also for /dev/ada1.eli. It is a 4 TB disk, so it must have a GPT partition table, or?
 
They were probably used as raw disks for ZFS, so GPT is not available. However, if camcontrol(8) does not like disk IDs, it probably wouldn't like labels either.

There might be another option. The old ad devices were usually statically-numbered, and ada(4) shows those devices at startup. See man 4 ada | less +/kern.cam.ada.legacy_aliases.
 
That makes sense. I have found out that one can also use the bus number and target id ( camcontrol devlist) as a device name in camcontrol.
 
Back
Top