39

While booting Ubuntu 12.04, the disk drive for /dev/mapper/cryptswap1 is not ready yet or not present is showing. Why is this?

fosslinux
  • 3,831
bittu
  • 391
  • 1
  • 4
  • 3
  • You probably encrypted home directory during installation but not swap. If low on RAM it may slow your system down, otherwise noting else should happen. – danijelc Nov 14 '13 at 11:07

2 Answers2

37

This error message indicates that the the system was unable to use its encrypted swap partition.

Not being able to use swap may cause slowdown, especially if your machine doesn't have much RAM installed.

Assuming the system is booting, you should be able to fix the problem without too much hassle.

If this is happening when you boot the CD/DVD or USB flash drive to install Ubuntu, then assuming installation is still working, it can be ignored. Your installed system might or might not have the same problem once created--if it does, the problem can be addressed in the installed system.

If this is happening on a system that is installed on your hard disk, then your system might still run okay, but it's a good idea to fix it--if you have a swap partition (or swap file), you may as well use it.

Most Ubuntu systems with swap have a swap partition. Assuming that is the case, the technique described in this blog post may help:

Here's a summary, with some additional information that may be helpful for novices, and in my own words. I suggest taking a look at that post as well though (assuming it remains accessible), as it contains some examples and other information that I've left out for brevity.

  1. Open a Terminal window (Ctrl+Alt+T) or a virtual console and run: sudo swapoff -a
  2. Open /etc/crypttab (e.g., sudo nano -w /etc/crypttab or sudo -H gedit /etc/cryptab for a GUI editor) and put a # at the beginning of the line that starts with cryptswap1. Save the file.
  3. Do the same thing with the line that starts with /dev/mapper/cryptswap1 in /etc/fstab.
  4. Install gparted Install gparted. Run it and format your swap partition as linux-swap. Make sure to get the right partition; if you get the wrong one, you'll lose possibly important data! The line you commented out in crypttab should give the correct partition name (it comes right after /dev/).
  5. Run sudo mkswap /dev/..., repacing ... with that same device name. Part of that command's output should be text that says UUID=..... where ..... is a string of letters and numbers.
  6. In the file /etc/initramfs-tools/conf.d/resume, find the line that says RESUME=UUID= followed by letters and numbers like (but not identical to) ..... from the last step. Replace them with ..... (i.e., with the letters and numbers mkswap gave after UUID=.
  7. Run sudo swapon /dev/... (with the same /dev/... as you had in steps 4 and 5 above).
  8. Run sudo ecryptfs-setup-swap.

swapon -s will check to see if swap is successfully enabled. See that blog post for more information, and example output, for checking this.

Source: http://punygeek.blogspot.com/2012/10/ubuntu-1204-how-to-solve-disk-drive-for.html (on http://punygeek.blogspot.com/) by Litmus / Puny Geek. Some commands are copied; prose is not copied, but often expresses the same ideas.

Finally, note that this might be a bug. (I believe multiple factors could cause this problem, only some of which are bugs.) In particular, it resembles Launchpad Bug #1153661. If you believe that's your situation, you might want to subscribe to that, mark yourself affected (with the green "This bug affects..." link at the top of the page), and if you have any additional information to provide, comment with it.

fosslinux
  • 3,831
Eliah Kagan
  • 117,780
  • 1
    This worked for me. Just one comment, I had to restart my computer between steps 3 and 4, as gparted would not format the swap partition otherwise. – geoffrey Oct 01 '13 at 18:43
  • Did not work for me, in the sense that I still see the /dev/mapper/cryptswap1 msg on bootup, however if I run swapon -s at a terminal it looks as if the swap is mounted: /dev/mapper/cryptswap1 partition 9765884 0 -1, so maybe things are working anyway? (free -m also shows the swap present) – fpghost Dec 22 '13 at 17:11
  • By the way, I think you may need a sudo update-initramfs -u after step 6, at least according to the blog you linked... – fpghost Dec 22 '13 at 17:13
  • how do I tell if I have encrypted swap? – arsaKasra May 14 '14 at 17:35
  • 2
    Using Ubuntu 14.04 #6 didn't work for me - that file doesn't exist. However I just skipped that step and this solved my problem perfectly! I was getting that error message on boot and the boot-up time was significantly slower than it is now. Thanks – redbmk Jul 02 '14 at 21:29
  • I have this problem, but when I try to run the last step, I get the following message: HOWEVER, THE SWAP ENCRYPTION CONFIGURATION PRODUCED BY THIS PROGRAM WILL BREAK HIBERNATE/RESUME ON THIS SYSTEM!. I use the hibernation feature. What do I do? – starbeamrainbowlabs Oct 28 '14 at 20:04
  • Tried it on 14.04 and works like a charm. – Praveen Sripati Mar 12 '15 at 04:54
  • I may have the wrong end of the stick but you are saying try these things once you have booted? My computer never gets past the warning. Any suggestions? – Len May 14 '15 at 23:00
  • 1
    @Len You're right--this only works if you can boot the system. You could try booting from recovery mode (try that first), or chrooting from a live CD/DVD/USB and doing it that way (more complicated, but doable). In a recovery mode root shell, or in a chroot you create in a live environment, all your commands run as root so you can leave off sudo in the commands. gedit is unlikely to work in either situation but nano should work fine. If you use a live system you can just run its GParted (outside the chroot); otherwise, use fdisk and mkswap. I suggest posting a new question. – Eliah Kagan May 15 '15 at 01:13
  • @eliah-kagan Thanks, I have tried some of what you have suggested but with no success and will now try and draft new question. – Len May 15 '15 at 08:10
  • Didn't work for me on 14.04, but this technique did. – Don Kirkby Feb 01 '16 at 07:06
  • I was hoping that this would be helpful to me but I dont see the swap partition in gparted I get a notice about gparted not supporting luks yet, thats on sda5. when looking in the native disks program i see the swap_1 yet im still getting the notice as described in the original post, im flumoxed – CodingInTheUK Feb 20 '16 at 15:31
7

Piggyback on Eliah's solution along with the bug reports on ubuntu (1310058), I was able to workaround the issue where encrypted swap gets lost when rebooting ubuntu 14.04.

Credit help goes to

http://punygeek.blogspot.com/2012/10/ubuntu-1204-how-to-solve-disk-drive-for.html https://bugs.launchpad.net/ubuntu/+source/ecryptfs-utils/+bug/1310058 (comments #3, #17, and #22)

sudo swapoff -a

comment out swap config in /etc/crypttab

#cryptswap1 UUID={your uuid} /dev/urandom swap,cipher=aes-cbc-essiv:sha256

comment out swap config in /etc/fstab

#/dev/mapper/cryptswap1 none swap sw 0 0

Reboot your computer, so you can reformat the swap partition using gparted afterwards. Make the swap, and make note of the UIID mkswap generates for you.

sudo mkswap /dev/sdXX

Update /etc/initramfs-tools/conf.d/resume with UUID from previous mkswap

RESUME=UUID={your uuid goes here}

And enable the Swap partition:

sudo update-initramfs -u
sudo swapon /dev/sdXX
sudo ecryptfs-setup-swap

Update your /etc/crypttab settings to include noauto and offset=8 (bug in ubuntu 14.04) (I recommend using vim here, so tabs don't get messed up).

cryptswap1 UUID={your uuid} /dev/urandom noauto,swap,offset=8,cipher=aes-cbc-essiv:sha256

Update your /etc/fstab with noauto:

/dev/mapper/cryptswap1 none swap noauto,sw 0 0

Manually kickstart your swap with the following config in /etc/init/cryptswap1.conf. Note: you may have to manually create that config file from scratch. You may use any text editor in place of VIM.

sudo vim /etc/init/cryptswap1.conf

and fill with the following content:

start on started mountall
script
  /sbin/cryptdisks_start cryptswap1
  /sbin/swapon /dev/mapper/cryptswap1
end script
Kaz Wolfe
  • 34,122
  • 21
  • 114
  • 172
Antony
  • 358