Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

This is a brand new Ubuntu 12.04 installation on my netbook. During installation I selected to encrypt my home folder. Now I'm trying to set up hibernation, but my swap partition isn't working. First, here's some information that you might find useful:

(parted) print all                                                        
Model: ATA WDC WD1600BEVT-2 (scsi)
Disk /dev/sda: 160GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End    Size    Type      File system  Flags
 1      1049kB  158GB  158GB   primary   ext4         boot
 2      158GB   160GB  2135MB  extended
 5      158GB   160GB  2135MB  logical

Here's the swap entry from my fstab:

# swap was on /dev/sdb5 during installation
#UUID=311a1b8d-b111-4890-a8ed-32a413d833a6 none            swap    sw            0       0
/dev/mapper/cryptswap1 none swap sw 0 0

I'm not sure if I'm asking the right question, but here goes: how do I get the mapper entry created so my swap partition works?

amy@amy-netbook:/etc$ swapon -a
swapon: /dev/mapper/cryptswap1: stat failed: No such file or directory

I've tried running sudo mkswap /dev/sda5 but it didn't appear to do anything. I'll also note that blkid /dev/sda5 does nothing.

amy@amy-netbook:/etc$ blkid /dev/sda1
/dev/sda1: UUID="68e22b54-68ad-487b-a8a3-9c8f05c49788" TYPE="ext4" 
amy@amy-netbook:/etc$ blkid /dev/sda5
amy@amy-netbook:/etc$ 

How can I get my swap working again?

share|improve this question
    
What does dmsetup ls give? –  Ignacio Vazquez-Abrams Aug 15 '12 at 6:55
    
dmsetup ls gives "No devices found." –  Amy Aug 15 '12 at 7:17
add comment

1 Answer

I recently started using Ubuntu Linux and just worked through the same set of concerns.

I had my swap file in a separate partition on the single hard drive. I set up a ramdrive and wasn't sure it worked.

I ran some system monitoring stuff, but couldn't figure out why the memory didn't seem to be doing much.

I didn't get why I had swapfiles in RAM and on the hard drive, both doing nothing, and I felt frustrated.

After some reading, here is what I am doing. Maybe it will help you too.

I went to the dash and opened a terminal. Type cat /proc/swaps and press enter. This will list the swaps on your system. I have a swap file named /dev/sda5. It is about 2GB. If you see the entry, or some thing like it, your swapfile is most likely there.

I am transitioning from Windows, so I am used to seeing the swapfile change size. Linux uses memory differently. Most things I have read recommend using settings that keep data in memory rather than swapping it to disk. I was looking for a little better performance though, so I read that swapfiles have a property called 'swappiness'. It adjusts how soon data swaps to disk occur based on your memory in use.

In terminal, type cat /proc/sys/vm/swappiness and press enter. A number will be displayed. Your swappiness level. 60 is the setting at setup. The range is 1 to 100. I bumped mine up to 70 to see how things looked. Performance is good.

This is a link to one of the best pages I found on the subject. http://askubuntu.com/questions/103915/how-do-i-configure-swappiness

You can change the swappiness. Here is how I do it.

At the terminal type sudo gedit /etc/sysctl.conf and press enter. It will prompt you for a password. It is probably the same one you use to log in. Near the bottom of the file is a line something like vm.swappiness = 60
You can change the number, save the file & close it.

I had trouble getting swapon and swapoff to work at first too. Put sudo in front of it. Should look something like this: sudo swapoff -a You will be prompted for your password. If you aren't sure if the swapfile was stopped, cat /proc/swaps will let you know. sudo swapon -a will restart your swapfile. I run system monitor to see what the memory is doing. Start the utility and load up the system doing what you do. You should be able to get around fairly comfortably if you want to make other changes. Ubuntu community and Googling Ubuntu 12.04 < and my questions> usually turn up good solutions.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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