Книга: Fedora™ Unleashed, 2008 edition
Mounting Automatically with /etc/fstab
Mounting Automatically with /etc/fstab
A special file, /etc/fstab
, exists to provide the system with predetermined options and mount points so that the file systems can be automatically or manually mounted with minimal typing and without having to recall arcane Linux syntax.
The /etc/fstab
file can only be written to by the super-user. The commands fsck
, mount
, and umount
all read information from /etc/fstab
. Each file system gets its own line with the information separated by tabs.
On each line of fstab
, the first field indicates the block device or remote file system that will be mounted. The second field identifies the mount point on the local system where the file system will be mounted. The third field is the file system type, and the fourth field is a comma-delimited list of mount
options. Options include:
? exec
— If this option is specified, binaries can be executed from this file system.
? noauto
— This means that the -a option does not cause the file system to be mounted and it is not mounted at bootup.
? noexec
— If this option is specified, binaries cannot be executed from this file system.
? nosuid
— This option does not permit set-user-identifier or set-group- identifier bits to take effect.
? ro
— This option mounts the file system as read-only.
? rw
— This option mounts the file system as read/write.
? sync
— Reading from and writing to the files are done synchronously.
? user
— This option allows a regular (not just root) user to mount the file system, but it includes the options noexec
, nosuid
, and nodev
by default unless they are overridden by exec
, dev
, and suid
.
For iso9660
file systems, the interesting option is unhide
, which shows hidden and associated files.
The fstab
man pages contain an in-depth description of fstab
and its options.
The fifth field of /etc/fstab
is used by dump
(a traditional Unix backup program) to determine whether the file system should be dumped (backed up); 1
is yes, and 0
is no. Default values are set for you during the initial installation. They are of concern only if you actually use dump
; then you would set the value to 1 for the file systems you wanted to back up.
The sixth field is used by fsck to determine how fsck needs to interact with the file system — 0
means that fsck
is never run on the file system (a FAT32 file system, for example); 1
means that fsck
will be run on the drive at a predetermined time. 2
is recommended for nonroot file systems so that fsck
is not run on them as frequently.
Here is a simple /etc/fstab
file from a system with a RAID0 ext3
root partition and dual-booted with MS Windows:
LABEL=/12 / ext3 defaults 1 1
none /dev/pts devpts gid=5,mode=620 0 0
none /proc proc defaults 0 0
none /dev/shm tmpfs defaults 0 0
/dev/hda11 swap swap defaults 0 0
/dev/cdrom /mnt/cdrom iso9660 noauto,owner,kudzu,ro 0 0
/dev/fd0 /mnt/floppy auto noauto,owner,kudzu 0 0
/dev/hda1 /mnt/win_c vfat auto,quiet,exec 0 0
Notice the two entries marked with the kudzu
option. This is the result of the actions of updfstab
, which keeps fstab
synchronized with the state of any removable devices on the system such as CD-ROMs. The quiet
option shown for the Windows partition suppresses error messages and is recommended if you use the Wine application.
NOTE
Device labels can be very useful. You can use the label in /etc/fstab
, and if you have many devices, their labels might be easier for you to remember and track than would be their device names. You can also shuffle around partitions without editing fstab
, just by changing their labels. The e2label
command is easier to remember than the analogous tune2fs
command.
The command e2label
can display or change a device's label. (You also can change a device label with tune2fs -L
.) For example, to change the label of /dev/hda4 to archives, use:
# e2label /dev/hda4 archives
As mentioned earlier, you record mounting preferences in /etc/fstab
during installation. You need to modify /etc/fstab
only if you make changes to your mounts or desire to change the default settings to address the specific needs of your system.
As long as the super-user understands the syntax and options of the fstab
file, she can edit the file with any text editor.
- Mounting File Systems
- Mounting Automatically with
- Using Double Quotes to Resolve Variables in Strings with Embedded Spaces
- Drawbacks with restore
- 7. AGGREGATION WITH INDEPENDENT WORKS
- Конструкция with-do
- 3. Hexadecimal – the way we communicate with micros
- CHAPTER 3 Working with GNOME
- CHAPTER 8 Printing with Fedora
- CHAPTER 15 Remote Access with SSH
- CHAPTER 20 Remote File Serving with FTP
- Managing Files with the Shell