Что означает опция "sw" в / etc / fstab?

3921
Cinlloc

В моей Ubuntu 14.04 / etc / fstab у меня есть следующая строка:

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

Что кажется довольно актуальным для обмена.

Я не могу понять, что ЮЗ вариант стоять. Там нет никаких признаков в Fstab человек, ни Swapon's.

Любая идея?

6
Я думаю, что [это] (http://superuser.com/questions/337410/what-is-the-difference-between-swap-entries-in-fstab) может сказать вам, что вы хотите знать: это подтверждает то, что я всегда предполагается. AFH 8 лет назад 2

2 ответа на вопрос

3
kenorb

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 file system is swap, these mount options doesn'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.
Ну, `ro` и` rw` описаны в mount (8): http://man7.org/linux/man-pages/man8/mount.8.html, тогда как `sw` и` xx`, вероятно, не делают смысл в линуксе. Кроме того, fstab в Linux имеет только 6 полей, `ro` и` rw` относятся к полю параметров монтирования. Tom Yan 8 лет назад 0
Это верно, 4-й столбец описывает параметры монтирования, связанные с файловой системой. kenorb 8 лет назад 0
Уточнил еще больше. kenorb 8 лет назад 0
Хм, на самом деле, я хочу сказать, что бессмысленно поднимать вопрос о BSD fstab. fstab в Linux имеет 6 полей, в то время как в коде, который вы цитировали, fstab в BSD имеет 7. И дополнительное, которое есть у BSD, в то время как в Linux нет, это `char * fs_type; / * rw, ro, sw или xx * / `. Я имею в виду, да, есть у BSD, но так? Это немного похоже на то, что «sw» и «swap» начинаются с «sw», поэтому «sw» означает «swap». Tom Yan 8 лет назад 0
@Tom Исправлены проблемы несоответствия. kenorb 8 лет назад 0
2
Oleg Bolden

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/

http://man7.org/linux/man-pages/man8/swapon.8.html: `-a, --all: все устройства, помеченные как` `swap '' в / etc / fstab, доступны, кроме те, у которых есть опция `` noauto ''. Также: https://git.kernel.org/cgit/utils/util-linux/util-linux.git/tree/sys-utils/swapon.c?h=v2 .27.1 # n677 Tom Yan 8 лет назад 0
То же самое для версии Ubuntu 14.04: https://git.kernel.org/cgit/utils/util-linux/util-linux.git/tree/mount/swapon.c?h=v2.20.1#n611. Tom Yan 8 лет назад 0

Похожие вопросы