System not mounting swap partition
Mia Lopez
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 / Solarisand in my fstab it says
file system: /dev/sda5
mount point: none type: swap options: sw dump: 0 pass: 0and 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 0I 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; skippingoutput 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 closedoutput of mountall -v
swap finished
...
local 4/4 remote 0/0 virtual 12/12 swap 0/0not 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.
118 Answers
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/0In 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.
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.
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.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
blkidcommand, above. Do not include the quotation marks.Save the file and reboot your system. Run
free -mto 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
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
mountallas non-root user, its reply should includeswapon: /dev/sda5: open failed: Permission denied dmesg | lessshould 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
freeshould report something likeSwap: 10239996 0 10239996
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 -aworked. lsblkshowed the swap partitionblkiddid NOT show the swap partitionblkid -p /dev/mapper/foo-swap_1printed 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_1showed 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}" 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 directoryFile 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-24103c1b25a7I edited the /etc/fstab file adding
/dev/sdb6 none swap sw 0 0Reboot and System Monitor shows it active, yay.
OK, I must have been here and found the command
blkid -p /dev/mapper/foo-swap_1So it's a clue for someone smarter than me. Hope it helps.
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
My /etc/fstab (Debian) has the following content:
UUID=7b533ab9-cb87-4a30-a4d8-689788f21985 none swap sw 0 0Yours should have that line based on what you told us about your config:
/dev/sda5 none swap sw 0 0I 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)?
1After UUID:
# Turn off swap
swapoff "${SWAP}"
At the end:
swapon "${SWAP}"