4

I set up a new Ubuntu Partition a few days ago. Yesterday I installed the Kubuntu-Desktop to replace the Unity thing.
Since I installed the new desktop the Linux-Swap partition won't work anymore and not even recognized as Swap. I don't know how that could happen.

Does anybody of you knows how to fix a problem like that? I understand it has something to do with /etc/fstab, but don't really know what to do with it.

The Swap Partition is 4GB and was set up during installation of Ubuntu.

If it helps, here is the result of: 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/sda7 during installation
UUID=345e5bbd-d951-4376-8f4b-724be9d0417b /               ext4    errors=remount-ro 0       1
# /boot was on /dev/sda5 during installation
UUID=9669db10-3a55-47cd-8c49-e8e4520ca2d3 /boot           ext4    defaults        0       2
# /home was on /dev/sda8 during installation
UUID=38b3f3ac-c96b-4f01-8fcf-eac44c6ed28f /home           ext4    defaults        0       2
# swap was on /dev/sda6 during installation
#UUID=6ea517a3-a80a-4acb-bea9-4efea2a71acf none            swap    sw              0       0
/dev/mapper/cryptswap1 none swap sw 0 0

Edit: Since there was a Question regarding: cat /etc/crypttab

cryptswap1 UUID=6ea517a3-a80a-4acb-bea9-4efea2a71acf /dev/urandom swap,cipher=aes-cbc-essiv:sha256
4
  • It seems you're using an encrypted swap partition. Can you provide the content of /etc/crypttab please? You can edit your question to improve it with additional info. Oct 22, 2014 at 12:31
  • I edited the question with /etc/crypttab. Hope it helps. I only clicked by installation to encrypt the Home Folder.
    – Severus15
    Oct 22, 2014 at 12:43
  • Thanks. Have an upvote for a good question with all the necessary info. Do you want your swap partition to be encrypted in the future too or does an unencrypted one suffice? Oct 22, 2014 at 13:03
  • I don't need an encrypted swap partition. I just want an working one. If I would have known in the Beginning that an encrypted Homefolder messes with everything, I would not have done that.
    – Severus15
    Oct 22, 2014 at 15:19

2 Answers 2

3

Try to recreate your swap partition as following steps:

Step 1. Format /dev/sda6 to be a valid swap mkswap /dev/sda6

Step 2. Activate the swap by swapon /dev/sda6

Step 3. Additionally modify /etc/fstab to make swap start after every boot. The swap line will probably be already there. You will just need to update UUID received as output of step 1.

For example in your case REMOVE these lines (IF you don't want Encrypted swap partition):

#UUID=6ea517a3-a80a-4acb-bea9-4efea2a71acf none            swap    sw              0       0
/dev/mapper/cryptswap1 none swap sw 0 0

And add this line instead at the end with NEW UUID that you get in step 1:

UUID=0c9f1cb4-a539-4ca4-8eb2-712d0efc3d10 none            swap    sw              0       0

see here and my answer there

IF you want to keep your Encrypted swap partition do the following steps:

First things first, we need to know where your swap file is located on your hard drive. dmesg can help here (or you could also check /etc/fstab)

So in your case you can see the swap is on /dev/sda6. Next thing to do is ensure the system is fully up to date, turn swap off so we can work with the partition and install the necessary files. Ensure to replace /dev/sda6 with the partition you got from dmesg (or /etc/fstab) in the step above:

sudo apt-get update
sudo apt-get upgrade
sudo swapoff /dev/sda6
sudo apt-get install lvm2 cryptsetup

Next up, load the module and verify its running.

$ sudo modprobe dm-crypt

You should see something like below

$ sudo lsmod | egrep 'aes|dm_crypt'
dm_crypt               12928  0 
aes_i586                8124  1 
aes_generic            27484  1 aes_i586

Now we clear the partition of existing data by filling it with random data. This has two purposes, first so that any old unencrypted data is overwritten and second so that your encrypted data does not stand out if your drive is analysed. What I mean by this is, if you have 750 meg of unused swap and only 250 meg used, then 3/4 of your drive will contain no data at all, just zeros. This makes the encrypted data stick out like a sore thumb. If you fill the drive with random data, the encrypted data just ‘blends in’

$ sudo dd if=/dev/urandom of=/dev/sda6 bs=1M

Again, replace /dev/sda6 with the partition you got from dmesg or fstab. This command will take a while (about 10 mins or so) and should produce output similar to this:

dd: writing `/dev/sda6': Input/output error
1028+0 records in
1027+0 records out
1077510144 bytes (1.1 GB) copied, 642.306 s, 1.7 MB/s

Then you need to tell crypttab to set up the partition as encrypted swap, again ensure to change /dev/sda6 to your partition:

sudo echo cryptoswap /dev/sda6 /dev/urandom cipher=aes-cbc-essiv:sha256,size=256,hash=sha256,swap >> /etc/crypttab

Next, edit the /etc/fstab file and search for the line with ‘swap’ in it. Comment that line out by inserting a # character at the beginning of the line, then insert the following line and save the file:

/dev/mapper/cryptoswap none swap sw 0 0

That is now your system set up with encrypted swap. Reboot your system for the changes to be picked up and the encrypted swap to be started. To ensure that the swap partition is encrypted after you boot you can check dmesg again, it should specifically mention cryptoswap:

dmesg | grep swap
 [   73.063397] Adding 979924k swap on /dev/mapper/cryptoswap.  Priority:-1 extents:1 across:979924k

If you notice a delay during boot time, or see a message such as ‘waiting for swap’ then move the mouse around a bit. It means the system is low on entropy to generate random data for initialization of the encryption. It should only take a second or two.

source

7
  • Could you please provide more information to step 3? I changed the UUID in the fstab with the Line I received in first step, but it still won't be recognised after reboot. But it will be recognised after swapon.
    – Severus15
    Oct 22, 2014 at 13:05
  • Could you please post the output of step1? Oct 22, 2014 at 13:08
  • This won't work with the entry in crypttab, because it'll reformat 6ea517a3-a80a-4acb-bea9-4efea2a71acf (sda6) with an encrypted swap partition on every boot. Oct 22, 2014 at 13:08
  • @DavidFoerster Then it also needs to update the UUID from step1 in crypttab file and it will work after updating fstab file by mount -a. Oct 22, 2014 at 13:15
  • The output of step 1 is: UUID:0c9f1cb4-a539-4ca4-8eb2-712d0efc3d10
    – Severus15
    Oct 22, 2014 at 13:33
0

αғsнιη's answer is on the right track but forgets to get rid of the crypttab entry and fails to explain in detail how to change fstab:

Try to recreate your swap partition as following steps:

  1. Format /dev/sda6 to be a valid swap mkswap /dev/sda6

  2. Activate the swap by swapon /dev/sda6

And then:

  1. Remove the last line of fstab (/dev/mapper/cryptswap1 none swap sw 0 0), uncomment the previous line and replace the UUID with that of the newly formatted swap device, e. g.:

    UUID=0c9f1cb4-a539-4ca4-8eb2-712d0efc3d10 none  swap  sw  0 0
    
  2. Remove or comment the line in /etc/crypttab or remove or rename that file altogether.

You can also reuse the old swap partition UUID, if in step 1 you do:

mkswap --uuid 6ea517a3-a80a-4acb-bea9-4efea2a71acf /dev/sda6
3
  • I have also mentioned all the steps but NOT step 4 AND Uh yes I forget uncomment that line:) Oct 22, 2014 at 16:31
  • Yes, but your step 3 was hardly understandable even for somebody who knew what you meant (= me) – especially with the two different cases (encrypted vs. unencrypted). Oct 22, 2014 at 16:32
  • Now I think it's understandable :? if not feel free to edit. Thank you Oct 22, 2014 at 16:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .