[systemd-devel] swap units and uuids

Lennart Poettering lennart at poettering.net
Thu Aug 26 17:32:33 PDT 2010


On Thu, 26.08.10 23:11, Diego Calleja (diegocg at gmail.com) wrote:

> Hi, while reading the documentation I noticed that the "What" parameter
> of .swap units doesn't seems to be able to take an UUID/label. Well, that's
> just a TODO...what worried me is that:
> 
> "Swap units must be named after the devices they control"
> 
> Isn't this rule incompatible with UUIDs/labels?

Actually no, it isn't. The reason for this is a bit convoluted though:

A device that comes and goes can do so under various names, and these
names might be aliases of different devices at varying times. Example:
you plug in a device with a swap partition with the uuid of X. At that
time the partition is available in the system as kernel device
/dev/sdf6. Then, later on you unplug the device, plug in some other
stuff, then plug it in again, now it is /dev/sdg6. So the first time the
device /dev/sdf6 was the same as /dev/disk/by-uuid/X, and the second
time /dev/sdg6 was the same as /dev/disk/by-uuid/X. If an entry in fstab
now refers to uuid X this actually points to two different devices
depending on the time. And that's a bit weird. To deal with this we
decided to expose every single of the device names by a different device
unit in systemd. i.e. there is dev-sdf6.device, there is dev-sdg6.device
and there is dev-disk-by-uuid-X.device, and they are maintained
seperately and all references to them are seperately stored as
well. However, depending on the time, dev-disk-by-uuid-X.device might
actually follow dev-sdf6.device or dev-sdg6.device in its state
machine. (Note that normally systemctl won't show you units that
"follow" other units, unless you pass --all)

So long story short, if the swap stuff is properly implemented, then a
uuid/label swap unit will refer to one specific device which is then called
exactly like the swap unit. At that device might then follow different
other units at different times.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list