Is the automatic mounting of the swap partition by systemd on GPT disk an Arch-specific feature?

Last time for another thing, I looked into the fstab file and noticed that the swap partition was not automatically mounted, but it was still active. I read about this in the Arch Wiki and found that this is not necessary in the case of a GPT partition table, because the systemd service can also do this at boot time.
My question is, is this nice little useful function not possible in the case of an MBR partition table, and is it only used in Arch Linux and not in other operating systems?

It shouldn’t be Arch-specific but it is part of systemd so distros that don’t use systemd wouldn’t be able to benefit from it.

I only asked because of the case you helped me with in the past, Kubuntu is also installed on a GPT disk, and the swap partition had to be automatically mounted in the fstab file.

There are several factors involved.

  • The swap partition has to be on the same disk as the ESP
  • The partition type GUID must be 0657fd6d-a4ab-43c4-84e5-0933c84b4f4f
  • You can’t have a swap partition mounted in /etc/fstab or an explicit mount unit
  • You have to be running a version of systemd after the functionality was implemented
  • It is possible to inhibit systemd-gpt-auto-generator although it seems unlikely that Ubuntu would do that
1 Like

Because I’m a distro-hopper, I discovered this is not Arch-specific. In the process of installing some distro it terminally insists in formatting “swap” and assigning it a new UUID so De(bi|vu)an couldn’t find it. This peaked me off at first for not knowing what it was.

If Manjaro is installed to and bootable from an external USB disk it’s not recommended to have “swap” on an internal HDD/SSD. Because if that “swap” is changed by something else it really drags around and then editing “/etc/fstab” becomes the solution.

Fedora or Manjaro installed on the same disk as “swap” could have the latter’s UUID changed once or more, but it’s not something I’d go for. But Debian and some distros based on it could really irritate with the “RESUME=” thing. Again, this is being said by a distro-hopper. :slight_smile:

1 Like

Thank you for your comments. It seems that until now I haven’t really used Linux distributions installed on GPT disks, so I don’t have much experience with it. In any case, the GPT partition table has several advantages compared to the traditional MBR-based scheme, of course the BIOS must also support this. For example, one of my laptops has a hybrid BIOS, UEFI and legacy BIOS are supported.

You are correct - it is not.

The feature as you call it works on any systemd based system - technically - you can omit the fstab entirely and system will still start.

Only requirement is the correct partition type guids

EFI - 0xEF00
BIOS-BOOT - 0xEF02
x86 root - 0x8304
home (if you have separate home) - 0x8302
swap - 0x8200

You can use systemd-mount to mount almost any device at predicatable locations.

Well, we probably remember how much criticism systemd received against init when it was introduced. https://www.tecmint.com/systemd-replaces-init-in-linux/

I am all-in for systemd - in fact the old init system was confusing and required way to much bash scripting knowledge - when I look back I think it was one of the reasons I never got very far with Linux despite several touchdowns over the years.

The systemd units can be short and precise - which I very much prefer :slight_smile:

Have you put everything about systemd on one card? :slight_smile: By the way, the init was really a bit difficult, but for those who got used to it, it was difficult to get over it again. In my opinion, the advantage of systemd is its simplicity and easier handling with the help of services.

I don’t understand?

The main reason I am systemd-pro is likely the fact that I have spent the better part of my worklife maintaining Windows based environments.

I had time to touch down on Linux but not long enough to get a firm grip.

I retired early from 2010 and onwards - stress and generaly burn-out - the recovery process is long and hard - and part of the recovery was Linux.

Now I know my Arch system in-out-backward-forward :slight_smile:

Just spent 30 minutes unpacking and installing a new workstation - I use systemd units to mount my extra devices - I have all my settings and scripts on secondary devices and everything is scripted - copy my mountunits over and starting them - no fiddling with fstab and what-not.

It takes me around 15 minutes to be back up.

You can say that I “socialized” in a Windows environment, like many of us, at first I just marveled at the Linux tree, then I started to learn, and everything became easier when we got to know its different mentality from Windows.

Indeed, you are right, for those who are used to Windows, systemd makes things easier compared to init, where you had to deal with scripts much more. I remember an example of the latter when I needed to configure the Xfce system sounds years ago. (play login and logout sounds). The latter was especially difficult. task, the Xfce forum helped.
https://forum.xfce.org/viewtopic.php?id=9424