2

I'm running vanilla Debian Jessie and I need to enable swap file. It works fine when I use swapon /var/swap.img but I'm unable to make it mount with fstab at boot time.

The following entry in fstab:

/var/swap.img none swap sw 0 0

Gives this error:

Error mounting none: mount: unknown filesystem type 'swap'

What is the proper way to mount swap file on Debian with fstab?

[Update]

Adding all entries from fstab:

root@test:~# grep -v "#" /etc/fstab 
UUID=lorem-ipsum / ext4 errors=remount-ro 0 1
/dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0
/var/swap.img none swap sw 0 0

Output from df:

root@test:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        20G  2.9G   16G  16% /
udev             10M     0   10M   0% /dev
tmpfs            99M  8.4M   91M   9% /run
tmpfs           248M     0  248M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           248M     0  248M   0% /sys/fs/cgroup

Also output from ls:

root@test:~# ls -lh /var/swap.img 
-rw------- 1 root root 1000M Dec 16 17:55 /var/swap.img

I've also checked man and it's not listing swap as supported filesystem type. I'm confused (is this normal?):

adfs, affs, autofs, btrfs, cifs, coda, coherent, cramfs, debugfs, devpts, efs, ext, ext2, ext3, ext4, hfs, hfsplus, hpfs, iso9660, jfs, minix, msdos, ncpfs, nfs, nfs4, ntfs, proc, qnx4, ramfs, reiserfs, romfs, squashfs, smbfs, sysv, tmpfs, ubifs, udf, ufs, umsdos, usbfs, vfat, xenix, xfs, xiafs.

  • That looks like a valid line. My functioning jessie system has this. /swapfile1 none swap sw 0 0 Can you show us the full fstab? Is /var on a separate filesystem? Is your swap listed last? – Zoredache Dec 16 '15 at 18:27
  • @Zoredache I've updated my question with relevant information. As you can see the /var is on root filesystem. – SiliconMind Dec 16 '15 at 18:59
  • 1
    swap.img is a silly name for a swapfile, since it's not a disk image. Instead, consider swap.swp or swap.dat or swapfile. – unforgettableid Dec 17 '15 at 4:31
6

You don't mount the swap partition or swapfile with mount, you use the swapon command. (The swap partition or file isn't really a filesystem that can be mounted and hold files, it's an area of the disk the kernel uses directly).

swapon -a will enable all swaps from /etc/fstab.

  • Thanks. Having swap in fstab is what caused my confusion. I just wanted to test if the fstab entry for swap is correct, so obvious choice for me was to use mount. Apparently I was wrong. – SiliconMind Dec 16 '15 at 22:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.