Page 1 of 1

swapfile problem: "read swap header failed"

Posted: Sat Jan 05, 2013 10:31 am
by zproc
On an old Raspbian upgraded and dist-upgraded (i'd prefer to not have to install a new image) i have this swap problem, so i'm not sure the swap works.

Code: Select all

[email protected] ~ $ sudo dphys-swapfile swapon
swapon: /var/swap: read swap header failed: Invalid argument
for further info:

fstab:

Code: Select all

[email protected] ~ $ cat /etc/fstab
proc            /proc           proc    defaults          0       0
/dev/mmcblk0p1  /boot           vfat    defaults          0       0
/dev/mmcblk0p2  /               ext4    defaults,noatime  0       0
# a swapfile is not a swap partition, so no using swapon|off from here on, use  dphys-swapfile swap[on|off]  for that
dphys-swapfile config

Code: Select all

[email protected] ~ $ cat /etc/dphys-swapfile 
CONF_SWAPSIZE=100
my raspbian version

Code: Select all

uname -a
Linux raspberrypi 3.2.27+ #250 PREEMPT Thu Oct 18 19:03:02 BST 2012 armv6l GNU/Linux
the permissions/etc of the swapfile

Code: Select all

[email protected] ~ $ ls -lsa /var/swap 
102404 -rw------- 1 root root 104857600 Jul 31 07:36 /var/swap
Anybody knows what i could do to fix this?

edit:

someone helped me on irc.

i did

sudo dphys-swapfile uninstall
sudo dphys-swapfile setup

again and then

sudo dphys-swapfile swapon
returns no error now.

Re: swapfile problem: "read swap header failed"

Posted: Tue Oct 29, 2013 11:35 am
by Wrrr 10-G
Dont forget to make it a swapfile with "sudo mkswap /path/to/swapfile"
(I had to do this before dphys-swapfile accepted the file)

Re: swapfile problem: "read swap header failed"

Posted: Thu Dec 05, 2013 11:40 pm
by YellowberryPie
I have a similar problem:
My Pi doesn't even have a swapfile. So I tried to create one like it's written up here, but when i mkswap he just shows

Code: Select all

mkswap: error: swap area needs to be at least 40 KiB
when i try swapon i get

Code: Select all

swapon: /var/swap: read swap header failed: Das Argument ist ung├╝ltig
It's hard to find anything else about this so please help me.

Re: swapfile problem: "read swap header failed"

Posted: Mon Apr 13, 2015 3:40 am
by malvcr
I just had a similar problem, trying to move the swap file to an xfs formatted partition (on an USB key).

After several attempts, found this (https://bugzilla.redhat.com/show_bug.cgi?id=1129205)

Basically, it seems that the Raspbian dphys-swapfile setup command could be creating a swap file with holes on it, so the swapon command will fail. To test it, I made the swap file with "dd" and converted it with "mkswap" and worked perfectly.

Code: Select all

sudo dd if=/dev/zero of=<the path for the file> count=<quantity of megabytes> bi-1MiB
sudo mkswap <the path for the file>
sudo dphis-swapfile swapon
Raspbian with kernel 3.18.7.v7+ on a rpi2

Re: swapfile problem: "read swap header failed"

Posted: Wed Apr 15, 2015 2:27 pm
by malvcr
oops ... in my past post I made a mistake (my sight is not perfect) ... this is the correction:

sudo dd if=/dev/zero of=<the path for the file> count=<quantity of megabytes> bs=1MiB
sudo mkswap <the path for the file>
sudo dphis-swapfile swapon