You have a FreeNAS 7/NAS4Free server setup and you have several USB drives attached to it. Your ongoing issue is that every time you reboot your FreeNAS server the disk mounts get mixed up and the drive numbers are out of order. One day your 120GB Western Digital HDD is da0, then all of a sudden it becomes da2 while your Seagate 500GB HDD is now da0.
If you have more USB drives attached and you use software RAID. All of a sudden, your Western Digital HDD that stores all those vacation pictures becomes a member of a RAID set. Ouch!!
The solution is to use disk labels, a handy feature of the FreeBSD operating system.
Requirements
Please note that this applies only to FreeNAS 0.7.x (legacy version of FreeNAS) and NAS4Free (the continuation of FreeNAS legacy). FreeNAS 8 may support the same features, however, it's a completely different system.
This guide assumes you are using GPT for all your drives (the default in FreeNAS 0.7.x).
Instructions
To begin, make sure you can SSH as root into your FreeNAS system (from now on we will call it NAS4Free). This will just make things simpler to manage while you switch back and forth between the web GUI and command line. You can enable root SSH using the web GUI (Services >> SSH) "Permit root login".
Before you continue, unmount all your USB drives from "Disks >> Mount Point >> Management".
- Ensure that the USB drive you want to label is listed under "Disk >> Management". If not, this is the time to add it and set the options as desired since you will not be able to change this later from the web GUI. Make sure you "Apply Changes".
- From the Disk Management screen in the web GUI, look for the disk you want to label and take note of it's name. For our example, it's da3 so the full path to the device is /dev/da3.
- Log into the NAS4Free console via SSH
- Ensure that the USB drive you are labeling is not mounted
freenas:~# mount
/dev/ad4s1a on / (ufs, local, soft-updates)
devfs on /dev (devfs, local)
procfs on /proc (procfs, local)
......
procfs on /proc (procfs, local)
/dev/ad4s2 on /mnt/BuiltIn (ufs, NFS exported, local, soft-updates, acls) - Use "glabel" to write a label to this disk. No output should be generated
glabel label micronet /dev/da3
- Verify the label information was written.
freenas:~# glabel list da3
Geom name: da3
Providers:
1. Name: label/micronet
Mediasize: 600137072128 (559G)
Sectorsize: 512
Mode: r0w0e0
secoffset: 0
offset: 0
seclength: 1172142719
length: 600137072128
index: 0
Consumers:
1. Name: da3
Mediasize: 600137072640 (559G)
Sectorsize: 512
Mode: r0w0e0 - Optional: Label the partitions using the tunefs -L command. My Example only has one partition.
tunefs -L MicroNet /dev/da3p1
- Go to Advanced >> File Editor, load the "/conf/config.xml" file and locate the "disks" section within that XML text file.
- Find the entry for the disk you are labeling and change the "name" to whatever you used for the label. Then change the "devicespecialfile" key below to /dev/label/YOUR_LABEL. Make sure you edit the correct device, otherwise you'll cause trouble.
<name>micronet</name>
<devicespecialfile>/dev/label/micronet</devicespecialfile> - Save the file.
- Now go to the mount point management screen "Disks >> Mount Point >> Management" and click on the "Add" (+) button.
- Select your disk from the drop down menu (your label should appear) and setup the options as desired. Save and Apply.
Repeat the steps for each disk you want to label. Then reboot to test and make sure it works as desired.