15

In my Ubuntu 14.04 /etc/fstab, I have following line:

UUID=e4YGg1-2bHU-Ylum-3FwK-MK3s-1Fjf-ZvQEh2 none            swap    sw              0       0

Which seems pretty current for swap.

I can't figure out what the sw option stand for. There is no indication in fstab man neither swapon's.

Any idea?

Cinlloc
  • 153
  • 1
  • 1
  • 6
  • 2
    I think [this](http://superuser.com/questions/337410/what-is-the-difference-between-swap-entries-in-fstab) may tell you what you want to know: it confirms what I always assumed. – AFH Mar 26 '16 at 00:19

2 Answers2

4

According to the link below, the 'sw' option indicates that the swap partition is to be activated with 'swapon -a' command:

/dev/hda6 none swap sw 0 0

http://www.linuxquestions.org/questions/linux-newbie-8/fstab-defaults-sets-wrong-permissions-145958/

Oleg Bolden
  • 1,687
  • 14
  • 14
  • http://man7.org/linux/man-pages/man8/swapon.8.html: `-a, --all: All devices marked as ``swap'' in /etc/fstab are made available, except for those with the ``noauto'' option.` Also: https://git.kernel.org/cgit/utils/util-linux/util-linux.git/tree/sys-utils/swapon.c?h=v2.27.1#n677 – Tom Yan Mar 26 '16 at 09:56
  • Same case for the version Ubuntu 14.04 has: https://git.kernel.org/cgit/utils/util-linux/util-linux.git/tree/mount/swapon.c?h=v2.20.1#n611 – Tom Yan Mar 26 '16 at 10:04
4

This column is described in Linux's man fstab as:

The fourth field, (fs_mntops), describes the mount options associated with the filesystem.

It is formatted as a comma separated list of options. It contains at least the type of mount plus any additional options appropriate to the filesystem type. For documentation on the available options for non-nfs file systems, see mount(8).

When the file system is swap, these mount options don't do anything. See: What is the difference between swap entries in fstab?

These fstab options are part of struct fstab:

 struct fstab {
         char    *fs_spec;       /* block special device name */
         char    *fs_file;       /* filesystem path prefix */
         char    *fs_vfstype;    /* type of filesystem */
         char    *fs_mntops;     /* comma separated mount options */
         char    *fs_type;       /* rw, ro, sw, or xx */
         int     fs_freq;        /* dump frequency, in days */
         int     fs_passno;      /* pass number on parallel fsck */
 };

So in summary there are 6 columns in /etc/fstab means:

  1. fs_spec: describes the block special device, the local filesystem, or the remote filesystem to be mounted.
  2. fs_file: describes the mount point for the filesystem. For swap partitions, this field should be specified as none.
  3. fs_vfstype: describes the type of the filesystem.
  4. fs_mntops: describes the mount options associated with the filesystem.
  5. fs_freq: is used for these filesystems by the dump command to determine which filesystems need to be dumped.
  6. fs_passno: is used by the fsck program to determine the order in which filesystem checks are done at reboot time.
glibg10b
  • 209
  • 1
  • 9
kenorb
  • 24,736
  • 27
  • 129
  • 199
  • Well, `ro` and `rw` are documented in mount(8): http://man7.org/linux/man-pages/man8/mount.8.html, while `sw` and `xx` probably make no sense in Linux. Also, fstab in Linux has only 6 fields, `ro` and `rw` belongs to the mount options field. – Tom Yan Mar 26 '16 at 17:20
  • That's correct, 4th column describes the mount options associated with the filesystem. – kenorb Mar 26 '16 at 18:27
  • Clarified further more. – kenorb Mar 26 '16 at 18:41
  • Hm actually my point is, it's a bit pointless to bring up the BSD fstab for the question. fstab in Linux has 6 fields, while according to the code you quoted, fstab in BSD has 7. And the extra one that BSD has while Linux doesn't is `char *fs_type; /* rw, ro, sw, or xx */`. I mean, yeah BSD has it, but so? It's a bit like saying "both `sw` and `swap` starts with `sw`, so `sw` means `swap`". – Tom Yan Mar 26 '16 at 18:57
  • @Tom Corrected the inconsistency issues. – kenorb Mar 27 '16 at 00:29