playstation
New Member
Hi, folks!
I'm currently studying for RHCSA, and I have no prior Linux experience, and I don't use Linux on a daily basis. Anyway, I'm currently trying to mount a new swap partition in my virtual machine with CentOS Stream 9. I know how to do it via editing /etc/fstab file: first we create partition with type linux-swap, then we make swap FS, then we run swapon to mount it, and then we edit /etc/fstab file to make sure the mount is persistent and run systemctl daemon-reload command. It works in my virtual machine: I run "free -m" command before and after described procedure, and it shows the increased swap, and it stays the same after reboot.
Now I'd like to do the same via systemd. I already learned how to mount regular partitions where I can store files etc, but mounting swap partition gave me some trouble.
I unmounted previously mounted swap, commented line in /etc/fstab, and then I created a file myswap.mount in /etc/systemd/system directory. Here are the contents of this file:
Then I run systemctl daemon-reload command, but when I run systemctl enable --now myswap.mount it gives me an error: "Where= path is not absolute". Unfortunately, I don't understand how to specify where to mount it in my systemd config file. If I remove "Where=swap", I get this error message that I see via journalctl -ex command: "mount: /myswap: operation failed: Invalid argument." So I assume the problem is in my config file. Please could you tell me where is the issue and how to fix it?
Thanks in advance!
I'm currently studying for RHCSA, and I have no prior Linux experience, and I don't use Linux on a daily basis. Anyway, I'm currently trying to mount a new swap partition in my virtual machine with CentOS Stream 9. I know how to do it via editing /etc/fstab file: first we create partition with type linux-swap, then we make swap FS, then we run swapon to mount it, and then we edit /etc/fstab file to make sure the mount is persistent and run systemctl daemon-reload command. It works in my virtual machine: I run "free -m" command before and after described procedure, and it shows the increased swap, and it stays the same after reboot.
Now I'd like to do the same via systemd. I already learned how to mount regular partitions where I can store files etc, but mounting swap partition gave me some trouble.
I unmounted previously mounted swap, commented line in /etc/fstab, and then I created a file myswap.mount in /etc/systemd/system directory. Here are the contents of this file:
[Unit]
Description=swap
Conflicts=umount.target
Before=local-fs.target umount.target
[Mount]
What=UUID=b1f040f6-485f-4c8b-8419-19d83c9bdca9
Where=swap
Type=swap
Options=defaults
[Install]
WantedBy=local-fs.target
Then I run systemctl daemon-reload command, but when I run systemctl enable --now myswap.mount it gives me an error: "Where= path is not absolute". Unfortunately, I don't understand how to specify where to mount it in my systemd config file. If I remove "Where=swap", I get this error message that I see via journalctl -ex command: "mount: /myswap: operation failed: Invalid argument." So I assume the problem is in my config file. Please could you tell me where is the issue and how to fix it?
Thanks in advance!