Z
Z
zzmaster2017-10-26 10:06:31
Swap
zzmaster, 2017-10-26 10:06:31

Swap file in CentOS - what to add to fstab?

In various manuals, for example here
https://www.centos.org/docs/5/html/5.2/Deployment_...
it is written that at the last stage, the line must be added to the fstab file

/swapfile swap swap defaults 0 0

however, the content of my fstab is
#
# /etc/fstab
# Created by anaconda on Wed Jul 26 08:42:33 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=a58b04a6-13de-4b25-8e60-281854f89174	/	ext4	quota,grpquota,usrquota,rw	0	1
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0

that is, the parameter with the slash comes second. If I add as suggested - will the system boot at all?
Maybe you need
swap /swapfile swap defaults 0 0

?
What causes such sabotage on the CentOS page? ))

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
sergio_nsk, 2017-10-26
@zzmaster

Why not read man fstab?
The first column is what will be mounted, which can be a file, a block device (which is also a file), a label, or a filesystem ID. The second - where to mount. The third is the file system type.
tmpfs, devpts, sysfs, proc are virtual filesystems, they ignore the first column.
swap is also tricky: if swap is specified in the first column, then swapon -a will be called; if it starts with /, then swapon /path will be called. And for swap, the second column should be none:
So you can try

swapon /swapfile
swapon -s

If everything works, then feel free to add a line to fstab.

C
CityCat4, 2017-10-26
@CityCat4

/dev/mapper/vg_none-lv_swap        swap                  swap    defaults        0 0

Line from real fstab.
Linux has a swap partition . Maybe there is a swapfile, but I don't know.

S
Sergey, 2017-10-26
@brestows

There is no sabotage in fstab:
what_mount where_mount cacaf_fs mount_parameters
so you are told
to mount_swapfile mount_as_swap with_swap_fs with_default_parameters without_checks

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question