Hard drive naming


Is it possible to rename hard drives, just like we can rename the network interfaces?

In my new devices, I’ve got a combination of SSD/NVME and standard spinning drives. Ideally, I would like the SSD/NVME devices to start the labeling, I,e. sda. Then when all of those have been enumerated, the spinning drives would be enumerated sdb, sdc, …

ATM, any NVMEs are always placed at the end, and that location varies depending on the number of spinning drives.

Anyway, is it possible to control the names (/dev/sdX) the hard drives obtain?


Hi @pal-arlos,

MAAS gets the devices names from Linux, so you need to play with udev rules until you get the result you want. After you figure out the rules needed, you should create a custom commissioning script to install these rules in the ephemeral OS before MAAS does the devices discovery (20-maas-03-machine-resources). You need to include these rules in the curtin preseed also, both for the ephemeral OS and the end system.

I have never tried this, but theoretically it should work.


Would it be curtin’s writing mission to name the hard drive?
If considered the answer #1 from…
#8 . curtin completes to write the target image to the target disk of the target bare metal.
Would this be correct as the naming of hard drive rules?
Being it reports the execution status and log to MaaS. ?
I may be in error. Being a new,bee to MaaS!

I wrote a python scrript which was looking for dell mirrored drives to put the OS on for a disk commissioning script some time ago - it’s not perfect, but it might be a good starting place instead of trying to tweak OS images and the like.

While it would be nice to have the drives in the order you want, it works just as well as sdz instead of sda - and you would have less difficulty with tweaking curtin images and all that.

I was facing similar issues when all my 12t virtual drives would show up before the 512g mirrored ssd pair I wanted to use for boot devices.

Take a look at this thread: Custom storage layout configuration examples


~~ Charles

@bedfordc thank you for sharing your script, it showed/indicated what effort it possibly would become. In my use case, the need to label the drives comes in the next step. Using juju to deploy the same charm on heterogeneous platforms. In those cases, it makes a huge difference if the cache storage is placed on the NVME/SSD or on the spinning rust. ATM, it seems that the NVME/SSDs end up at the end, but then where is that? Given that the number of spinning drives are varying.

I guess will end up as a feature request.

  • Let MAAS do its commissioning.
  • If the user wants to name the devices differently, let them do that via the UI.
  • When the device is commissioned again or deployed.
    • If the device has been modified in the UI.
      • MAAS dynamically creates and appends a custom script, that creates the appropriated udev aliases (basically creates /etc/udev/rules.d/local_disknames).
    • Otherwise, process the device as normal (no script injection).

But, that would require MAAS to 1) enable users to fiddle in the UI, but probably quite similar to the NIC edit feature. 2) check if custom names are present, 3) create a script and inject dynamically, during the commissioning/deployment phase.

A benefit of this approach, cf. manually adding a script that has to fit all nodes, the initial ideal by @alexsander-souza, would be that this script has access to detailed attributes, thus removing (or at least lowering) any randomness that might occur.

Sounds reasonable, or am I missing some fundamental aspect?


We can file a feature request like you described, but I feel that manually editing the disk names won’t scale if you have a lot of machines. We should consider tags as a better way to achieve your goal.

MAAS already assign ssd and rotatory tags to disks depending on what was detected, and you can create and assign new tags. These tags can be specified when requesting a machine (e.g. storage=400(ssd),1000(rotatory) will get you a machine with a SSD disk with at least 400GB and a spinning disk of 1TB). You can use these tags with a Custom storage layout script to setup the disks and partitions the way you need.

I agree, scaling would be an issue. However, I do not think tags would do the work. AFAIK, they are used to filter devices. The example that you provided, would filter out devices that meet those requirements. However, the problem is not the filtering, it’s the naming that udev gives to the devices.

Btw, the feature that I was asking for, isn’t that already (partially?) available via the CLI?

The scalable solution would probably be to use a kernel, or cf the script that was proposed before, that deploys the naming syntax that you would like to use.

1 Like