[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: 22882
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: 22882
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: 22882
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

gostal
Level 1
Level 1
Posts: 14
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.
Laptop: Latitude E6520, i3-2330M @ 2.20GHz, 4GB, Intel HD Graphics 3000, OS Mint 19 version Mate, Windows 7 Enterprise
Desktop: Dell Precision T5810, Xeon E5-1650 v4 @ 3.60GHz,72 GB, Radeon Pro WX 7100, OS OpenSuse Leap 42.3
Stockholm, Sweden

snowshoeb
Level 1
Level 1
Posts: 3
Joined: Sun Oct 21, 2012 9:05 am

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

Post by snowshoeb » Sat Sep 29, 2018 10:36 am

I got a different error using a swap partition instead of a swap file with encrypted home directory installing LM19. The swap partition UUID in /etc/initramfs-tools/conf.d/resume was that of the unencrypted swap partition commented out in /etc/fstab/ resulting in 20 second delays booting the LM 19 default kernel of 4.15.0-20 and boot hangs with 4.15.0-34. Deleting /etc/initramfs-tools/conf.d/resume and running sudo update-initramfs -u fixed both boot issues.

User avatar
sigmalion
Level 1
Level 1
Posts: 4
Joined: Thu Oct 11, 2018 9:40 am

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

Post by sigmalion » Thu Oct 11, 2018 9:43 am

snowshoeb wrote:
Sat Sep 29, 2018 10:36 am
Deleting /etc/initramfs-tools/conf.d/resume and running sudo update-initramfs -u fixed both boot issues.
It worked for me, thanks a lot.

derflou78
Level 1
Level 1
Posts: 1
Joined: Sat Oct 13, 2018 4:19 pm

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

Post by derflou78 » Sat Oct 13, 2018 4:20 pm

LVM is a logical set of partitions inside the physical partition, in your case sda3.
The default will be / & swap but you cannot see that from outside the LVM.

FifesAndClarions
Level 1
Level 1
Posts: 2
Joined: Wed Oct 03, 2018 8:00 pm

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

Post by FifesAndClarions » Tue Oct 16, 2018 12:16 pm

xenopeek/ or someone who can possibly help:

On xenopeek's third post it says:
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.
I direly need help accomplishing such an increase. I'm not a newb with comfort level using the command line and follow steps, but I am rather a newb in terms of overall general knowledge; I hardly keep any chain of commands in my head or intimately know how they work in tandem.

That said, I installed LM19 a little over a week ago with an encrypted home folder. I quickly noticed the initial lack of swapfile and noticed it was one of the first things listed in 'Known Issues'. I followed the simple set of commands provided and was furnished automatically with a swapfile size of 1.4GB (never gave an option of setting a custom size; and my total RAM is 2.9GB on this system). 1.4 isn't terribly small but I had my doubts as to whether it'd be enough for how I typically use my system.

Today I concluded I needed more, but after scouring through forums (LM, ubuntu, and others), I haven't found anything that comes close to helping me with "cryptswap" -- whether steps to successfully delete and create a new one, or simply resize.
I've steered clear of even experimenting with steps that I'm 99% certain would not apply in my case -- I can't afford to bork anything right now -- and ended up trying one set and instantly regretting it -- as it didn't resize anything, and left me with
swapon: /swapfile: read swap header failed
, whatever that means.
For the record, the two commands I tried I believe were:

Code: Select all

sudo cryptsetup resize cryptswap1
sudo mkswap /dev/mapper/cryptswap1

I hope I haven't rambled on too much, and wish I could provide more detail but there's little detail for me to provide at this point beyond the pathetic efforts I've made so far, plus the 50 random forum pages noisily rattling in my head to no avail.

Someone knowledgeable -- please help me delete or if possible fix/cleanup my current mess, and to set it so that I can have 2gb swap file!!
I can follow directions pretty well.

Post Reply

Return to “Newbie Questions”