Sunday, April 28, 2024
 Popular · Latest · Hot · Upcoming
30
rated 0 times [  30] [ 0]  / answers: 1 / hits: 33205  / 1 Year ago, mon, january 9, 2023, 9:30:35

When I installed Ubuntu, I setup an encrypted home partition. Now I have come to an issue where I am running out of memory because I haven't setup swap. How can I setup an encrypted swap file?



A couple of times while booting I've seen some reference to cryptswap. I've also got these lines contained in /etc/fstab



# swap was on /dev/sda6 during installation
#UUID=1ba8a53b-1842-4de7-8e38-2d6c79f3a1ab none swap sw 0 0
/dev/mapper/cryptswap1 none swap sw 0 0

More From » encryption

 Answers
5

Thanks to this guide I set up an encrypted swap file (can't be used for hibernation). On Debian based distributions, you will need the cryptsetup package for these instructions.



  1. Firstly create an appropriately sized file (here 4 gigabytes) to store the swap data:


    fallocate -l 4G /cryptswap


  2. Add the following to /etc/crypttab:


    cryptswap /cryptswap /dev/urandom swap


  3. Activate the newly created encrypted drive:


    service cryptdisks reload


  4. Add the following to /etc/fstab:


    /dev/mapper/cryptswap none swap sw 0 0


  5. Activate the new swap file:


    swapon -a



[#32987] Tuesday, January 10, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cretanol

Total Points: 320
Total Questions: 99
Total Answers: 115

Location: Australia
Member since Sat, May 27, 2023
1 Year ago
cretanol questions
Fri, Dec 2, 22, 13:30, 1 Year ago
Thu, Dec 8, 22, 03:00, 1 Year ago
Mon, Aug 1, 22, 03:21, 2 Years ago
Fri, Sep 24, 21, 16:28, 3 Years ago
Sun, Apr 24, 22, 06:37, 2 Years ago
;