13

Even though the swap partition exists, and set to load in fstab, it's still not being mounted.

fdisk returns this for the swap partition:

file system: /dev/sda5
      start: 1
        end: 244
     blocks: 1951744
         id: 82
     system: Linux swap / Solaris

and in my fstab it says

file system: /dev/sda5
mount point: none
       type: swap
    options: sw
       dump: 0
       pass: 0

and I can load it fine with swapon /dev/sda5 but it just won't load at boot.

Is there more information that I can give to help troubleshoot? I dont know what other info could be useful


As requested, full fstab file:

# <file system> <mount point>   <type>  <options>            <dump>  <pass>
proc            /proc           proc    nodev,noexec,nosuid  0       0
/dev/sda6       /               ext4    errors=remount-ro    0       1
/dev/sda5       none            swap    sw                   0       0
/dev/sr1        none            udf     rw,noauto            0       0

I was looking at the system log and I saw this, not sure what it means or if it's normal but:

Apr 29 17:57:24 caelan-ubuntu os-prober: debug: running /usr/lib/os-probes/50mounted-tests on /dev/sda5
Apr 29 17:57:24 caelan-ubuntu 50mounted-tests: debug: /dev/sda5 is a swap partition; skipping

output of mountall

mountall: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
mountall: Connection is closed

output of mountall -v

http://pastie.org/private/ras9mc7mf66yudnjoem4w

swap finished
...
local 4/4 remote 0/0 virtual 12/12 swap 0/0

not sure, still not loading swap... still can be added in commandline, and my windows partition is being mounted on boot, and that is in the fstab too.

11
  • Would you mind posting up the contents of /etc/fstab?
    – boehj
    Apr 30, 2011 at 4:51
  • @boehj: done...
    – caesay
    Apr 30, 2011 at 5:02
  • Cheers. Nothing's jumping out at me here. It seems odd. The only possible thing I can think of is that, seeing as you're using extended partitions, / should appear first i.e. /dev/sda5 and swap as /dev/sda6. This is just grasping at thin air however. I'm interested to see how this one will be resolved. Perhaps you could use UUIDs in place of /dev/sdX? To find these values do sudo blkid.
    – boehj
    Apr 30, 2011 at 5:16
  • @boehj: no dice... still not being loaded.
    – caesay
    Apr 30, 2011 at 5:25
  • @Tommy - Sorry I couldn't help you buddy. I'm certain someone on here will be able to though. Good luck with it. :)
    – boehj
    Apr 30, 2011 at 5:31

8 Answers 8

8

This is going to sound stupid, but try it: reorder /etc/fstab to put the swap partition last.

It seems that mountall -v fails harmlessly when run as NON-root user, and its output can be used to diagnose why mountall doesn't work right at boot. Your last line of output from mountall -v includes the critical clue:

local 4/4 remote 0/0 virtual 12/12 swap 0/0

In other words, 0 swap drives mounted, 0 swap drives found in /etc/fstab.

Now why didn't mountall find your swap drive listed in /etc/fstab? Good question. This should probably be a bug against mountall. To diagnose it, I copied your /etc/fstab and ran mountall -v as non-root user. By editing /etc/fstab randomly and continuing to test mountall -v, I found how to change mountall's reported "swap 0/0". Just reordering the lines of /etc/fstab was enough to make it change to "swap 0/1", in other words, 1 swap drive found in /etc/fstab. With that, it may be enough to boot properly. If not, please post new result of mountall -v.

1
8

Thank you for your question. As I was looking at it, I discovered that my system had the same problem as yours after upgrading to Natty, yesterday. I believe the problem is that the UUID of the swap partition changed during the upgrade. Here is how I fixed it.

  1. Run sudo blkid. This will show the current UUID's of all partitions on the disk. I suspect you will see that the UUID of your swap partition now differs from the value in /etc/fstab.

  2. If it is different, run some text editor under sudo to edit /etc/fstab. Replace the value of the UUID with the current actual value as shown by the blkid command, above. Do not include the quotation marks.

  3. Save the file and reboot your system. Run free -m to make sure the change fixed the problem:

    $ free -m
                 total       used       free     shared    buffers     cached
    Mem:          1001        604        396          0        123        199
    -/+ buffers/cache:        281        719
    Swap:         1953          0       1953
    
4
  • i was not using the UUID, i was using the /dev/sda5 as i mentioned in my question. that wouldnt affect me?
    – caesay
    Apr 30, 2011 at 20:05
  • Ok. So, your /etc/fstab doesn't use UUID's, either?
    – Tim
    May 1, 2011 at 1:15
  • no.. it does not work. with or without uuid's
    – caesay
    May 1, 2011 at 17:39
  • 1
    Worked like charm! Oct 15, 2016 at 19:29
2

I had a similar problem on Ubuntu 12.04 (Precise), but my /etc/fstab was already correct. It turns out that there was something broken about the format of my swap partition that prevented blkid and mountall from detecting the swap partition.

Details:

  • My swap partition was /dev/mapper/foo-swap_1 -- an LVM logical volume on an encrypted (LUKS) partition.
  • The swap partition would never be active at boot.
  • Manually running swapon -a worked.
  • lsblk showed the swap partition
  • blkid did NOT show the swap partition
  • blkid -p /dev/mapper/foo-swap_1 printed the following message:

    /dev/mapper/foo-swap_1: ambivalent result (probably more filesystems on the device, use wipefs(8) to see more details)
    
  • wipefs -n /dev/mapper/foo-swap_1 showed TWO different filesystem signatures!

Nuking both signatures (wipefs -a) and reformatting the swap (mkswap) fixed the problem for me.

Here's a script that automates the fix:

#!/bin/sh

# helper functions
log() { printf %s\\n "$*"; }
error() { log "ERROR: $*" >&2; }
fatal() { error "$*"; exit 1; }
try() { "$@" || fatal "'$*' failed"; }

# path to the swap partition
SWAP=/dev/mapper/foo-swap_1

# remember the UUID of the swap partition
UUID=$(try sed -e 's/RESUME=UUID=//' /etc/initramfs-tools/conf.d/resume) || exit 1
[ -n "${UUID}" ] || fatal "couldn't read UUID"

# delete filesystem/raid signatures from the swap partition
try wipefs -a "${SWAP}"

# format the swap partition
try mkswap -f -U "${UUID}" "${SWAP}"
1

I don't have any quick answer, but I poked around and found some things you could check to try to narrow down the problem:

  • /etc/fstab(5) should list swap partition (yours looks fine afaict)
  • /etc/init/mountall.conf should include the line emits all-swaps
  • if you run mountall as non-root user, its reply should include swapon: /dev/sda5: open failed: Permission denied
  • dmesg | less should include something like what mine has:

[ 2.272092] sda: sda1 sda2 sda3

[ 2.272924] sd 1:0:0:0: [sda] Attached SCSI disk

...(more lines about mounting sda1, sda2)...

[ 20.298550] Adding 10239996k swap on /dev/sda3. Priority:-1 extents:1 across:10239996k

  • free should report something like Swap: 10239996 0 10239996
4
  • i cant find any output in dmesg about the drives.. mountall returns an error, and the mountall.conf does have that line.
    – caesay
    May 1, 2011 at 17:34
  • If mountall never tried to run swapon, that seems to be your problem. What is the verbose output mountall -v?
    – krubo
    May 1, 2011 at 22:16
  • added it to the question @krubo
    – caesay
    May 13, 2011 at 4:06
  • see where mountall -v says swap 0/0? That's a perfect clue. See my new answer.
    – krubo
    May 14, 2011 at 0:15
1

After the upgrade to 12.04, certain little anomalies occurred, no biggie. I was unaware my swap partition wasn't working until I tried to Gimp a 14 megapixel jpg from my Olympus e330. Yikes.

Forums to the rescue. Clues:

blkid shows

/dev/sdb6: UUID="3e0550cf-4a55-4aa8-80fa-24103c1b25a7" TYPE="swap" 

but it is not active according to System Monitor, mmm'kay.

The UUID was definitely right but no go... not sure how I got to this command:

# blkid -p /dev/mapper/foo-swap_1
error: /dev/mapper/foo-swap_1: No such file or directory

File manager showed me a 0 byte icon, filename control, -- so what was supposed to be written there? By what?

$ sudo swapon --all --verbose yielded
swapon: cannot find the device for UUID=3e0550cf-4a55-4aa80fa-24103c1b25a7

I edited the /etc/fstab file adding

/dev/sdb6   none    swap    sw  0   0

Reboot and System Monitor shows it active, yay.

OK, I must have been here and found the command

blkid -p /dev/mapper/foo-swap_1

So it's a clue for someone smarter than me. Hope it helps.

1

Nothing above was in my case

I resized swap: deleted old one and then made a new one bigger. After there was an error Something X session related. I changed UUID in /etc/fstab, but it did not work for me. Checked journal: ... unknown filesystem "swap"

Solution: in /etc/fstab change ext4 to swap for /swap and reboot

0
0

My /etc/fstab (Debian) has the following content:

UUID=7b533ab9-cb87-4a30-a4d8-689788f21985 none  swap sw 0 0

Yours should have that line based on what you told us about your config:

/dev/sda5 none swap sw 0 0

I wonder why as a beginner in Linux you're wondering about this. RAM is cheap these days. I've got 4 GB, and do Java development (IntelliJ especially uses a ton of RAM for example) but I never run out of it.

And I have to say I'm surprised you've got this kind of problems. Did you not run the Ubuntu Installer using default options?

Or maybe you're getting all these problems because of dual booting (Win/Lin)?

1
  • it does have that line, i dont have too much ram, and i am dual booting but it shouldnt be an issue because my windows doesnt touch my swap partition, and i can load it fine with swapon.
    – caesay
    Apr 30, 2011 at 16:57
0

After UUID:

# Turn off swap swapoff "${SWAP}"

At the end:

swapon "${SWAP}"

You must log in to answer this question.

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