I have just installed xubuntu 14.04 and elected to do the encryption (not the full disk, just the ubuntu part and my home dir). I realized however that I failed to create any swap space. When I run gparted it shows just two partions sda1 (/boot) and the rest of my SSD sda2. But gparted does not list how much of sda2 is used or unused. why?

I'm not sure if I can at this point create any swap space, because of the encryption during the installation. What should I do, and how do I do it with gparted. Gparted does not seem to let me resize the partitions.

my gparted window looks like this:

  • Partition File Sys Mount pt Size Used Unused Flags
  • /dev/sda1 (keys) ext2 /boot 243MiB 53.17MiB 189.83MiB boot
  • /dev/sda2 extended (blank) 476.7GiB --- --- (blank)

    1. Which partition should I try to change, and how (to create swap from it)?
    2. Is it not possible to alter a partition without corrupting the encryption?

I have 16GB of RAM, and I do use the machine for scientific computing.

Thank you!



You can create a swap file instead of a swap partition if you like. To create the swap file in /home, you would run the following commands (this creates an 8GB swap file):

sudo dd if=/dev/zero of=/home/.swap bs=1M count=8K
sudo mkswap /home/.swap

Then, you would want to add the following line to your /etc/fstab file:

/home/.swap  none   swap   sw   0   0

Finally, run sudo swapon -a to activate your swap. You can change the commands and the fstab entry above to change where the swap file is being created.

Your swap will be encrypted automatically if the file is created within an encrypted partition, but it will not be accessible until after the encrypted partition is unlocked, which may cause problems with it not being automatically activated at boot.

  • Thanks for the answer. That did work. The swap file is enabled, and when i reboot it still shows up on the system monitor. Is it also possible to use this file to hibernate? I'm not able to hibernate if i do sudo pm-hibernate. – user3267752 Apr 27 '14 at 23:41
  • I do not believe that hibernation will work with this setup – that requires a swap partition, so you would have to find a way to resize your partitions (which I believe gparted can help you do). – jkt123 Apr 28 '14 at 0:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.