[FIX] no swap on fresh LM19 install with home directory encryption

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help
Post Reply
User avatar
xenopeek
Level 24
Level 24
Posts: 22762
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

[FIX] no swap on fresh LM19 install with home directory encryption

Post by xenopeek » Wed Jul 25, 2018 10:29 am

There is an issue with home directory encryption that causes swap to be misconfigured during installation of Linux Mint 19, if you enabled home directory encryption during installation. This leaves you with swap that doesn't work.

To correct this run the following two commands after logging in to your new Linux Mint 19 installation:
sudo sed -i 's#/target##' /etc/crypttab
sudo sed -i '#^/swapfile#d' /etc/fstab

Finish with the following command:
sudo update-initramfs -u



Questions & Answers

Q: How do I know whether I have home directory encryption?
A: Run the following command and unless it replies the directory doesn't exist, you have home directory encryption:
ls /home/.ecryptfs

Q: How can I confirm that my swap doesn't work?
A: Run the following command and if it doesn't reply anything your swap doesn't work:
swapon --show

Q: What do those "sudo sed" commands do?
A: The first deletes "/target" from the line in /etc/crypttab file where it was erroneously added during installation. The second deletes the line starting with "/swapfile" in /etc/fstab that was erroneously not removed during installation. You may also manually edit these files with command xed admin:///etc/crypttab and xed admin:///etc/fstab if you prefer.

Q: What does the "sudo update-initramfs -u" do?
A: It updates the initramfs of your active kernel so that from next boot swap will be used correctly. If you've already installed new kernels you may wish to run the command as sudo update-initramfs -u -k 'all' instead to update the initramfs for all installed kernels. This is a one time action and future kernels you install won't need any action from you for this.
Image

Cortimi
Level 1
Level 1
Posts: 24
Joined: Sun Jul 22, 2018 1:47 am

Re: [FIX] no swap on fresh LM19 install with home directory encryption

Post by Cortimi » Sat Jul 28, 2018 11:49 pm

Went through the steps, however:

$ sudo update-initramfs -u
update-initramfs: Generating /boot/initrd.img-4.15.0-29-generic
W: initramfs-tools configuration sets RESUME=UUID=2adde1e7-6685-48ad-8b0c-2b76c347adba
W: but no matching swap device is available.

swapon --show doesn't return anything.

$ ls /home/.ecryptfs shows the proper folder

User avatar
xenopeek
Level 24
Level 24
Posts: 22762
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: [FIX] no swap on fresh LM19 install with home directory encryption

Post by xenopeek » Sun Jul 29, 2018 1:53 am

Did you check the swapon --show after reboot? You need to reboot to activate changes.

If that didn't help, can you please run this command, reboot afterwards and check swapon --show again:
sudo update-initramfs -c -k 'all'
Image

Cortimi
Level 1
Level 1
Posts: 24
Joined: Sun Jul 22, 2018 1:47 am

Re: [FIX] no swap on fresh LM19 install with home directory encryption

Post by Cortimi » Sun Jul 29, 2018 3:01 pm

Wow, don't I feel like a newb now.

$ sudo swapon --show
[sudo] password for cortimi:
NAME TYPE SIZE USED PRIO
/dev/dm-0 partition 2G 0B -2

Does that look good? I have 8GB of RAM and I crash a LOT from running out of memory (using Android emulators), so I hope this fixes things!

User avatar
xenopeek
Level 24
Level 24
Posts: 22762
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: [FIX] no swap on fresh LM19 install with home directory encryption

Post by xenopeek » Sun Jul 29, 2018 3:34 pm

Yes that looks good; it shows you have encrypted swap as you need to have with home directory encryption.

General recommendation is to have about 20% of RAM as swap so you're good on that front. If for your particular use you need more swap you can increase the size of the swapfile with some commands. But try it out as-is first.
Image

svejorange
Level 1
Level 1
Posts: 10
Joined: Tue Jul 31, 2018 4:44 am

Re: [FIX] no swap on fresh LM19 install with home directory encryption

Post by svejorange » Wed Aug 08, 2018 10:47 am

I had the same problem. Thank you for the solution.

gostal
Level 1
Level 1
Posts: 1
Joined: Fri Sep 07, 2018 9:56 am

Re: [FIX] no swap on fresh LM19 install with home directory encryption

Post by gostal » Fri Sep 07, 2018 11:12 am

I'm definitely a newbie to Mint, not so much to Linux which I have been running in various forms for about 20 years. I'm a bit puzzled.

As far as I can make out my /etc/crypttab and /etc/fstab are fine now:

Code: Select all

gostal@ki003401-linux:~$ cat /etc/crypttab 
cryptswap1 /swapfile /dev/urandom swap,offset=1024,cipher=aes-xts-plain64
...
gostal@ki003401-linux:~$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda5 during installation
UUID=33dfb83d-b24e-497f-af8e-260a1c100c53 /               ext4    errors=remount-ro 0       1
/dev/mapper/cryptswap1 none swap sw 0 0
and also swapon --show for which I get the same as Cortimi and ls /home/.ecryptfs seems reassuring.
However, when I do: sudo update-initramfs -u -k 'all' I get:

Code: Select all

update-initramfs: Generating /boot/initrd.img-4.15.0-33-generic
W: initramfs-tools configuration sets RESUME=UUID=ed9a18e4-11ca-4a2b-afba-4bcb6c36ae22
W: but no matching swap device is available.
update-initramfs: Generating /boot/initrd.img-4.15.0-20-generic
W: initramfs-tools configuration sets RESUME=UUID=ed9a18e4-11ca-4a2b-afba-4bcb6c36ae22
W: but no matching swap device is available.
also after reboot. This is apparently a warning and not an actual error. Is this to be expected when
using encrypted swap?

Not expected was also that:
sudo sed -i '#^/swapfile#d' /etc/fstab
did not delete the line beginning with /swapfile. I had to edit the file to remove the line which was the second (not counting comments). I was a bit careless this time usually I copy the original to begin with but not this time so I cannot show /etc/fstab prior to my edit.

Post Reply

Return to “Newbie Questions”