You are not logged in.

#1 2016-08-20 18:04:33

Buddlespit
Member
From: Chesapeake, Va.
Registered: 2014-02-07
Posts: 501

[Solved]Systemd swap unit file naming issue

I'm trying to move away from fstab and have systemd mount all of my drives for me. I have all of my harddrives and both of my samba shares starting from .mount unit files and all of them mount correctly. The only issue I'm having at the moment is mounting my swap. I just can't figure out (or find via Google) the proper way to name the unit file. The problem is the dash '-' in the device path.

example:
/dev/disk/by-label/Swap, unit file name dev-disk-by-label-Swap.swap will give me 'systemd[1]: dev-disk-by-label-Swap.swap: Value of What= and unit name do not match, not loading.'.

If I drop the dash in by-label:
/dev/disk/bylabel/Swap, unit file name dev-disk-bylabel-Swap.swap will give me 'systemd[1]: dev-disk-bylabel-Swap.swap: Job dev-disk-bylabel-Swap.swap/start failed with result 'dependency'.'.

I tried using /dev/sd**, unit file name dev-sd**.swap, but on reboot my raid array changed devices and the swap wasn't on the one I started out with.

I don't have enough room on my root drive (30G ssd, 15G used) to shrink and make a 16G swap partition. So no automount for me. Anyone know what I'm supposed to use for the dash in the device name?

Last edited by Buddlespit (2016-08-21 18:23:34)

Offline

#2 2016-08-21 15:23:43

Buddlespit
Member
From: Chesapeake, Va.
Registered: 2014-02-07
Posts: 501

Re: [Solved]Systemd swap unit file naming issue

Mod, should this be moved to "System Admin"?

Offline

#3 2016-08-21 17:02:13

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: [Solved]Systemd swap unit file naming issue

You might want to see 'man systemd.swap'.

Edit:
You might also want to check the automatically generated mount files in /run/systemd/generator

Last edited by R00KIE (2016-08-21 17:04:35)


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

#4 2016-08-21 17:51:44

Buddlespit
Member
From: Chesapeake, Va.
Registered: 2014-02-07
Posts: 501

Re: [Solved]Systemd swap unit file naming issue

R00KIE wrote:

You might want to see 'man systemd.swap'.

Edit:
You might also want to check the automatically generated mount files in /run/systemd/generator

You just googled those without either reading my post or reading the man page. There is no provision to using a unit file for swap if the location has a dash in it. The /run/systemd/generator for swap says it's generated using fstab, which it is, because I can't load it from a systemd unit file. Swap will not be autogenerated if the swap isn't on root drive, which it isn't because my root drive is too small.

Offline

#5 2016-08-21 18:09:47

Buddlespit
Member
From: Chesapeake, Va.
Registered: 2014-02-07
Posts: 501

Re: [Solved]Systemd swap unit file naming issue

I went ahead and created a bug report for this at the systemd github.
https://github.com/systemd/systemd/issues/4014

OK, as commented on in the bug report, it's not a bug. Because systemd treats dashes differently, as an escape character, the path has to be regenerated using

# systemd-escape -p {/path/to/location-of/swap}

or, in my case:

# systemd-escape -p /dev/disk/by-label/Swap
dev-disk-by\x2dlabel-Swap

Last edited by Buddlespit (2016-08-21 18:23:13)

Offline

#6 2016-08-21 21:12:12

Buddlespit
Member
From: Chesapeake, Va.
Registered: 2014-02-07
Posts: 501

Re: [Solved]Systemd swap unit file naming issue

Holy crap! I had to kung-foo the dog-poo out of this!

this is the filename: /etc/systemd/system/dev-disk-by\x2dlable-Swap.swap

I had to:

#systemctl start dev-disk-by\\x2dlable-Swap.swap  <--note the second '\'
#systemctl enable dev-disk-by\x2dlable-Swap.swap  <--note the lack of the second '\'

edit:
After a reboot and a retry, systemctl enable works just like systemctl start with the second slash. I had an uptime of close to two days and that reboot was because systemd was updated to 231. I'm unsure if any other updates I had made in the past two days could have caused my issue, but I do know that the reboot this morning fixed it.

Last edited by Buddlespit (2016-08-22 17:12:10)

Offline

#7 2016-08-21 23:29:56

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: [Solved]Systemd swap unit file naming issue

This is not a blog, if you want to add more information edit the relevant post.

And no, I didn't mindlessly google it and pasted it here, I did point you in the right direction, all the information you needed is in the man pages and you could look into the directory I pointed you to to help figure out how things work, namely the escaping and unit file contents.


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

Board footer

Powered by FluxBB