Welcome to the Linux Foundation Forum!

Lab 13.1 swapon failed: Invalid argument

Options

I'm sure I'm overlooking something, but I'm getting an "swapon failed: Invalid argument" on this lab.

I'm running CentOS 7 for these labs.

[root@localhost ~]# cat /proc/swaps
Filename Type Size Used Priority
/dev/sda2 partition 4063228 6972 -1
[root@localhost ~]# dd if=/dev/zero of=swpfile bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 6.13878 s, 175 MB/s
[root@localhost ~]# mkswap swpfile
Setting up swapspace version 1, size = 1048572 KiB
no label, UUID=55ec2a9f-a003-4031-a4f4-eaf9627d132d
[root@localhost ~]# swapon swpfile
swapon: /root/swpfile: insecure permissions 0644, 0600 suggested.
swapon: swpfile: swapon failed: Invalid argument
[root@localhost ~]# chown root:root swpfile
[root@localhost ~]# chmod 600 swpfile
[root@localhost ~]# swapon swpfile
swapon: swpfile: swapon failed: Invalid argument

I've checked out the man pages and googled the error. Any tips or ideas? Thanks

Comments

  • coop
    coop Posts: 915
    Options
    I did the exact same thing and it worked just fine. THe warnings are just that,
    but they don't affect the result, if you do cat /proc/swaps you see it is there.

    However, googling says it may depend on the filesystem type the swapfile is sitting on.
    In particular, btrfs apparently doesn't go for it. see

    http://superuser.com/questions/539287/swapon-failed-invalid-argument-on-a-linux-system-with-btrfs-filesystem

    Perhaps that is the problem? I didn't know of this until I scoured around.
  • ultraninja
    ultraninja Posts: 20
    Options
    The issue was btrfs. I created an ext4 partition and was able to create a file, format as swap, and swapon that file.

    Thanks coop

Categories

Upcoming Training