USB drive changing boot device names

Status
Not open for further replies.

Ian Bennett

Dabbler
Joined
Jun 10, 2016
Messages
11
This might have been answered elsewhere, but I've searched the forum and can't find anything. OK, here we go...

Installed fresh 9.10.2-U1 onto a pair of mirrored Sandisk Cruiser Fit 16GB devices, all worked fine and status shows device names for 'freenas-boot/mirror-0' as da0p2 and da1p2, exactly as expected. I then added drives, created volumes, shared out the data via AFP and all works sweet as a nut.

I need to run some automatic backup scripts over night which write some data to an external USB drive containing a UFS file system. Initially the USB drive gets a /dev/da2 device file name, which makes sense. The interesting part happens when the machine is restarted. If the USB drive is attached to a rear USB port then it gets alloacted a /dev/da0 device file name and the Sandisk Cruiser USB boot devices get /dev/da1 and /dev/da2. Everything works ok, but that change of device file name causes some of my scripts some issues! Even more interestingly, if I attach the USB drive to one of the front ports then it gets a /dev/da2 name again and the boot devices are back to /dev/da0 and /dev/da1. However, using the front ports means that stray hands and feet can catch cables leading to possible damaged USB drives!

I'd like my two USB boot devices to ALWAYS have the da0/da1 device file names, regardless of whether another USB drive is connected. Now, I could (and probably should!) beef up the scripts to cope with the situation but, for now, is there a way that I can force the boot device files names to always be consistent?

I've now tested this on both a new Dell T20 and an old HP Proliant, both exhibited the exact same behaviour as described above.
 

gpsguy

Active Member
Joined
Jan 22, 2012
Messages
4,472
You have two problems. One, you can't depend on device names remaining consistent across a restart and two, UFS storage isn't supported on FreeNAS 9.3 and later.

Users often run into the device name issue when drive fails. They might remember where daX was located when they set up their server, but it's not there now. FreeNAS uses gptid's to track the disks.

Support for volumes on UFS was dropped in FreeNAS 9.3. One can import an UFS volume (read only), but using it in the way you are doing it is not supported.

You could create a separate ZFS volume for this. Or, if you want UFS for compatibility with other OS', attach the drive to a client machine and copy the data over the network.
 

Ian Bennett

Dabbler
Joined
Jun 10, 2016
Messages
11
Thanks for the response, both points understood and taken. No need for ext drive to be UFS so I'll format as ZFS.

Given that the ext USB drive is connected (but not mounted), how would my script work out (using gptid as you advise) how to mount the appropriate drive in preparation for backup? I'm probably missing something simple here of course!

On Windows servers, I use a great utility called USBDLM which uses volume IDs to allow my scripts to do the right thing.
 

gpsguy

Active Member
Joined
Jan 22, 2012
Messages
4,472
Can you give us a high level idea of what you are doing?

I am on my phone right now and can't do forum searches, etc. very easily.

Perhaps @Arwen can chime in, since she backs up to a 8TB drive that she stores offsite (or so I think).
 

Arwen

MVP
Joined
May 17, 2014
Messages
3,611
Yes, I do perform backups to an external, single disk, ZFS pool. (I use the more
reliable and faster eSATA. But for backup purposes, I guess USB 3.x would be
okay. But not the slow USB 2.x!!!)

@Ian Bennett,
You would perform a ZFS import, ala "zpool import POOL". ZFS does not care
what the Unix device name is, it can import based on name or ID number. For
example, my media server has a SDXC card for alternate booting in case of
trouble with the primary boot media. Thus, I can check it's availability using this;

Code:
# zpool import
  pool: sdpool
  id: 12330884359690940677
  state: ONLINE
status: Some supported features are not enabled on the pool.
action: The pool can be imported using its name or numeric identifier, though
   some features will not be available without an explicit 'zpool upgrade'.
config:

   sdpool  ONLINE
    mmcblk0p5  ONLINE

Basically I attach my backup disk, run a script to scrub the pool and then make
a backup. I rotate between 2 disks, one is 8TB for all and another 750GB is for
all except media.

I was planning on posting my backup procedure and script here in the forums
somewhere. Just have not gotten a Round Tuit.
 

Ian Bennett

Dabbler
Joined
Jun 10, 2016
Messages
11
Thanks Arwen. I'm in good shape for everything else now, but the original core issue still remains. Depending on which USB port I attach my external USB backup drive to, my two Cruiser Fit mirrored boot USB sticks can vary in the device file names they are allocated on startup. If no USB drive is attached then they always get /dev/da0 & /dev/da1. If I attach a USB backup drive to the running server then that's also fine as it always gets allocated /dev/da2. So far, so good.

However, if I have a USB drive attached when the server is booted then they either get da0/da1 (in which case the USB backup drive gets da2) or da1/da2 (USB drive then gets da0). It seems to be the case that if the backup drive gets connected to the rear ports then it gets da0 at boot time, if it's attached to the front ports then it gets da2. Problem is, the drive is attached during the day and if the server restarts for whatever reason then my script can't be certain if needs to do:

- mount /dev/da0 /mnt/usbdrive
or
- mount /dev/da2 /mnt/usbdrive

I know it's a corner case, but this is for a remote office where the swap is carried out by a day-worker - I'm almost never on site. How can my script check at run time (2am) which device file the backup drive has at any point in time? Perhaps the only way is to run a 'df -h' within the script and parse the output to determine the correct device file name, but there might be an easier way.

Thanks in advance for any light you can shed on this!
 

Ian Bennett

Dabbler
Joined
Jun 10, 2016
Messages
11
Ignore my last post, I didn't read your response in enough detail until I got home and now see the part about ZFS not caring what the device file name is as you can access via name or ID number. I'm still in UFS land, I really need to get out of there immediately! ;-)

One question though - you have only one backup drive, we have five (Mon through Fri) so have no idea which one will be attached at any time. This will no doubt crystalise as I try things out, but will a 'zfs import <pool name>' embedded in the backup cron job import fine regardless of which USB drive is attached at that particular time?
 

Arwen

MVP
Joined
May 17, 2014
Messages
3,611
Ignore my last post, I didn't read your response in enough detail until I got home and now see the part about ZFS not caring what the device file name is as you can access via name or ID number. I'm still in UFS land, I really need to get out of there immediately! ;-)
No worries. Even for backup disks or transfer disks, ZFS can make sense, (if the hosts have ZFS). UFS
is so last century :).
One question though - you have only one backup drive, we have five (Mon through Fri) so have no idea which one will be attached at any time. This will no doubt crystalise as I try things out, but will a 'zfs import <pool name>' embedded in the backup cron job import fine regardless of which USB drive is attached at that particular time?
If you give the backup disks the same pool name, then the script won't really care which is installed.
You can then potentially use the ZPool's ID number in your log file to keep track of which backup
went to which single disk pool. Oh, and each pool can have a "comment" tag, which can list the
preferred day of week. See zpool get all for what pool attributes are available.

My preference would be to name the ZFS pool as appropriate, like backup_monday. Then have the
scrip verify that the correct disk was inserted. But, I can understand a good, completed backup to the
wrong disk would be better than a series of failed backups.

And by the way, I have 2 backup drives. An 8TB and a 750GB, (that I had left over from my old media
server). Can't fit everything on the 750GB, so I drop the media. As money permits, I will likely buy yet
another 8TB, (or larger) and add it into the rotation.
 
Last edited:

Ian Bennett

Dabbler
Joined
Jun 10, 2016
Messages
11
All working perfectly now, appreciate you taking the time to help.

Just purchased an electronic copy of the first Lucas/Jude ZFS book, a little bed-time reading!
 
Status
Not open for further replies.
Top