6

When I try to sudo swapon -a i get this message:

swapon: /dev/sdb4: read swap header failed: Invalid argument

sdb4 is where my swap partition is.

sudo blkid gives back this:

/dev/sdb1: UUID="75622b47-3265-48a6-a697-265b44bdfe55" TYPE="ext4" 
/dev/sdb3: UUID="d638620e-b8b1-49ae-b234-7e89aa0de676" TYPE="ext4" 
/dev/sdb5: UUID="E656-2CAB" TYPE="vfat" 
/dev/mapper/cryptswap1: UUID="83e2e318-eee6-4864-a1c4-330bd16bc6a7" TYPE="swap"

this is the content of fstab:

# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    nodev,noexec,nosuid 0       0
# / was on /dev/sdb1 during installation
UUID=75622b47-3265-48a6-a697-265b44bdfe55 /               ext4    errors=remount-ro 0       1
# swap was on /dev/sdb4 during installation
#UUID=86d7eebb-b840-4fb0-a1fc-a84074062cb2 none            swap    sw              0       0
#/dev/fd0        /media/floppy0  auto    rw,user,noauto,exec,utf8 0       0   
/dev/sdb4        none            swap    sw              0       0

2 Answers 2

6

Check if swap partition is set up correctly

Execute the command sudo fdisk -l. This will list all your partitions and their partition types. In Ubuntu, a swap partition will be listed similar to below:

/dev/sdb4            7295        8268     7811072   82  Linux swap / Solaris

If you don't see the last 2 values 82 and Linux Swap, then it is not setup as swap partition.

Setup a swap partition

Ensure that the partition you are going to use (such as /dev/sdb4) is not a real partition with real data before turning it in to swap partition since all your data will be lost.

The following steps will set up a swap partition:

sudo swapoff -a

Replace /dev/sdb4 with the correct partition name if different:

sudo /sbin/mkswap /dev/sdb4

Enable the swap partition you just set up:

sudo swapon -a

For detailed help, refer to https://help.ubuntu.com/community/SwapFaq

5

Simple: you don't have an sdb4 partition! Your swap appears to be on /dev/mapper/cryptswap1. It looks like you setup cryptswap, so you need to fix your fstab to point to the new swap partition, preferably by UUID, not by device name.

1
  • Kudos to psusi for reading more closely than I did. My answer completely misses the point...
    – Flimzy
    Jun 17, 2011 at 22:32

You must log in to answer this question.

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