2014-03-13

Created page with "{{Lowercase title}} Category:File systems (Magyar) Category:Boot process (Magyar) ar:Fstab es:Fstab it:Fstab ja:Fstab ro:Fstab ru:Fstab zh-CN..."

New page

{{Lowercase title}}

[[Category:File systems (Magyar)]]

[[Category:Boot process (Magyar)]]

[[ar:Fstab]]

[[es:Fstab]]

[[it:Fstab]]

[[ja:Fstab]]

[[ro:Fstab]]

[[ru:Fstab]]

[[zh-CN:Fstab]]

[[zh-TW:Fstab]]

{{Related articles start}}

{{Related|Persistent block device naming}}

{{Related|NTFS Write Support}}

{{Related|Firefox Ramdisk}}

{{Related|Boot Debugging}}

{{Related|udev}}

{{Related articles end}}

Az [[Wikipedia:Fstab|/etc/fstab]] fájl határozza meg, hogy a lemezek partícióit, más blokkeszközöket, vagy távoli fájlrendszereket hogyan csatolunk a fájlrendszerünkbe.

Minden csatolandó fájlrendszert különálló sor ír le. Ezek a leírások rendszer indításakor dinamikusan [[systemd]] csatolási egységgé (mount unit) konvertálódnak, valamint akkor, amikor a rendszerkezelőt újratöltjük. Az alapértelmezett beállítások automatikusan ellenőrzik (fsck) és csatolják a fájlrendszereket, mielőtt az azok felcsatolását igénylő szolgáltatások elindulnának. Például a systemd magától megbizonyosodik róla, hogy a távoli fájlrendszerek, mint az [[NFS]] vagy a [[Samba]] csak azután induljanak, hogy a hálózatunk már működőképes. Ezért a helyi és távoli fájlrendszer-csatolások, melyek az {{ic|/etc/fstab}}-ban szerepelnek, külső beavatkozás nélkül is működőképesek. Lásd a {{ic|man 5 systemd.mount}} leírást részletekért.

A {{ic|mount}} parancs az fstab-ot hasznája, ha parancsként csak a könyvtárt vagy az eszköz nevét (pl. mount /dev/sdb2 vagy mount /my/mount) adjuk meg, s a parancs ilyenkor az fstab-ból keresi vissza a másik paramétert. Ha így teszünk, az fstab-ban foglalt csatolási opciók lesznek használatosak.

== Példa az fstab állományra ==

Egyszerű {{ic|/etc/fstab}} fájl, mely kernel név szerinti leírókat használ:

{{hc|/etc/fstab|

# <file system> <dir> <type> <options> <dump> <pass>

/dev/sda1 / ext4 defaults,noatime 0 1

/dev/sda2 none swap defaults 0 0

/dev/sda3 /home ext4 defaults,noatime 0 2}}

== A mezők definíciója ==

Az {{ic|/etc/fstab}} állomány a következő szóközzel tabulátorral elválasztott mezőket tartalmazza:

<file system> <dir> <type> <options> <dump> <pass>

* '''<file system>''' - (fájlrendszer) a csatolandó partíció vagy tárolóeszköz.

* '''<dir>''' - (könyvtár) a csatolási pont, ahova <file system> csatolásra kerül.

* '''<type>''' - (típus) a csatolandó partíció vagy tárolóeszköz fájlrendszerének típusa. Sok különböző fájlrendszer támogatott: {{ic|ext2}}, {{ic|ext3}}, {{ic|ext4}}, {{ic|btrfs}}, {{ic|reiserfs}}, {{ic|xfs}}, {{ic|jfs}}, {{ic|smbfs}}, {{ic|iso9660}}, {{ic|vfat}}, {{ic|ntfs}}, {{ic|swap}} és {{ic|auto}}. Az {{ic|auto}} típus a mount parancsra bízza a használandó fájlrendszer típusának meghatározását. Ez hasznos lehetaz optikai adathordozók esetén (CD/DVD).

* '''<options>''' - (opciók) az adott fájlrendszer csatolási opciói. Jegyezzük meg, hogy egyes [[http://linux.die.net/man/8/mount csatolási opciók] csak egy-egy fájlrendszerre jellemzők. A leggyakoribbak a következők:

:* {{ic|auto}} - Csatoljuk automatikusan a rendszer indításakor, vagy ha a {{ic|mount -a}} parancs kerül használatra.

:* {{ic|noauto}} - Csak akkor csatoljuk, ha ezt külön paranccsal kérjük.

:* {{ic|exec}} - Engedélyezi a bináris fájlok végrehajtását a fájlrendszeren.

:* {{ic|noexec}} - Tiltja a bináris fájlok végrehajtását a fájlrendszeren.

:* {{ic|ro}} - Csak olvashatóan csatolja a fájlrendszert.

:* {{ic|rw}} - Írhatóan és olvashatóan csatolja a fájlrendszert.

:* {{ic|user}} - Bármely felhasználónak engedélyezi a fájlrendszer csatolását. Ez automatikusan maga után vonja a {{ic|noexec}}, {{ic|nosuid}} és {{ic|nodev}} opciókat, kivéve, ha ezt külön jelezzk.

:* {{ic|users}} - Bármely felhasználónak, aki része az users csoportnak, engedélyezi a fájlrendszer csatolását.

:* {{ic|nouser}} - Csak root csatolhatja a fájlrendszert.

:* {{ic|owner}} - Csak az eszköz tulajdonosa csatolhatja a fájlrendszert.

:* {{ic|sync}} - Az I/O szinkronizáltan történik.

:* {{ic|async}} - I/O nem szinkronizáltan történik.

:* {{ic|dev}} - Értelmezi a speciális blokkeszközöket a fájlrendszeren.

:* {{ic|nodev}} - Nem értelmezi a speciális blokkeszközöket a fájlrendszeren.

:* {{ic|suid}} - Engedélyezi az suid és sgid bitek működését a fájlrendszeren. Ezek teszik lehetővé, hogy a felhasználók időlegesen megemelt privilégiumokkal bináris kódot hajtsanak végre egy bizonyos cél érdekében.

:* {{ic|nosuid}} - Meggátolja az suid és sgid bitek működését.

:* {{ic|noatime}} - Don't update inode access times on the filesystem. Can help performance (see [[#atime_options|atime options]]).

:* {{ic|nodiratime}} - Do not update directory inode access times on the filesystem. Can help performance (see [[#atime_options|atime options]]).

:* {{ic|relatime}} - Update inode access times relative to modify or change time. Access time is only updated if the previous access time was earlier than the current modify or change time. (Similar to noatime, but doesn't break mutt or other applications that need to know if a file has been read since the last time it was modified.) Can help performance (see [[fstab#atime_options|atime options]]).

:* {{ic|discard}} - Issue [[SSD#TRIM|TRIM]] commands to the underlying block device when blocks are freed. Recommended to use if the filesystem is located on an [[SSD]].

:* {{ic|flush}} - The {{ic|vfat}} option to flush data more often, thus making copy dialogs or progress bars to stay up until all data is written.

:* {{ic|nofail}} - Mount device when present but ignore if absent. This prevents errors being reported at boot for removable media.

:* {{ic|defaults}} - the default mount options for the filesystem to be used. The default options for {{ic|ext4}} are: {{ic|rw}}, {{ic|suid}}, {{ic|dev}}, {{ic|exec}}, {{ic|auto}}, {{ic|nouser}}, {{ic|async}}.

* '''<dump>''' - used by the dump utility to decide when to make a backup. Dump checks the entry and uses the number to decide if a file system should be backed up. Possible entries are 0 and 1. If 0, dump will ignore the file system; if 1, dump will make a backup. Most users will not have dump installed, so they should put 0 for the <dump> entry.

* '''<pass>''' - used by [[fsck]] to decide which order filesystems are to be checked. Possible entries are 0, 1 and 2. The root file system should have the highest priority 1 (unless its type is [[btrfs]], in which case this field should be 0) - all other file systems you want to have checked should have a 2. File systems with a value 0 will not be checked by the fsck utility.

== Identifying filesystems ==

There are three ways to identify a partition or storage device in {{ic|/etc/fstab}}: by its kernel name descriptor, label or UUID. The advantage of using UUIDs or labels is that they are not dependent on the order in which the drives are (physically) connected to the machine. This is useful if the storage device order in the BIOS is changed, or if you switch the storage device cabling. Also, the BIOS may occasionally change the order of storage devices. Read more about this in the [[Persistent block device naming]] article.

To list basic information about the partitions, run:

{{hc|$ lsblk -f|

NAME FSTYPE LABEL UUID MOUNTPOINT

sda

├─sda1 ext4 Arch_Linux 978e3e81-8048-4ae1-8a06-aa727458e8ff /

├─sda2 ntfs Windows 6C1093E61093B594

└─sda3 ext4 Storage f838b24e-3a66-4d02-86f4-a2e73e454336 /media/Storage

sdb

├─sdb1 ntfs Games 9E68F00568EFD9D3

└─sdb2 ext4 Backup 14d50a6c-e083-42f2-b9c4-bc8bae38d274 /media/Backup

sdc

└─sdc1 vfat Camera 47FA-4071 /media/Camera}}

=== Kernel name ===

Run {{ic|lsblk -f}} to list the partitions, and prefix them with {{ic|/dev}}.

See the [[#File_example|example]].

=== Label ===

{{Note|Each label should be unique, to prevent any possible conflicts.}}

For detailed information on how to label a device or partition, see [[Persistent block device naming#by-label]]. Renaming the root partition has to be done from a "live" Linux distribution because the partition needs to be unmounted first.

Run {{ic|lsblk -f}} to list the partitions, and prefix them with {{ic|1=LABEL=}} :

{{hc|/etc/fstab|2=

# <file system> <dir> <type> <options> <dump> <pass>

LABEL=Arch_Linux / ext4 defaults,noatime 0 1

LABEL=Arch_Swap none swap defaults 0 0}}

=== UUID ===

All partitions and devices have a unique UUID. They are generated by filesystem utilities (e.g. {{ic|mkfs.*}}) when you create or format a partition. See [[Persistent block device naming#by-uuid]] for details.

Run {{ic|lsblk -f}} to list the partitions, and prefix them with {{ic|1=UUID=}} :

{{Tip|If you would like to return just the UUID of a specific partition:

$ lsblk -no UUID /dev/sda2

}}

{{hc|/etc/fstab|2=

# <file system> <dir> <type> <options> <dump> <pass>

UUID=24f28fc6-717e-4bcd-a5f7-32b959024e26 / ext4 defaults,noatime 0 1

UUID=03ec5dd3-45c0-4f95-a363-61ff321a09ff /home ext4 defaults,noatime 0 2

UUID=4209c845-f495-4c43-8a03-5363dd433153 none swap defaults 0 0}}

== Tips and tricks ==

=== Automount with systemd ===

If you have a large {{ic|/home}} partition, it might be better to allow services that do not depend on {{ic|/home}} to start while {{ic|/home}} is checked by ''fsck''. This can be achieved by adding the following options to the {{ic|/etc/fstab}} entry of your {{ic|/home}} partition:

noauto,x-systemd.automount

This will fsck and mount {{ic|/home}} when it is first accessed, and the kernel will buffer all file access to {{ic|/home}} until it is ready.

{{Note|This will make your {{ic|/home}} filesystem type {{ic|autofs}}, which is ignored by [[mlocate]] by default. The speedup of automounting {{ic|/home}} may not be more than a second or two, depending on your system, so this trick may not be worth it.}}

The same applies to remote filesystem mounts. If you want them to be mounted only upon access, you will need to use the {{ic|noauto,x-systemd.automount}} parameters. In addition, you can use the {{ic|1=x-systemd.device-timeout=#}} option to specify a timeout in case the network resource is not available.

If you have encrypted filesystems with keyfiles, you can also add the {{ic|noauto}} parameter to the corresponding entries in {{ic|/etc/crypttab}}. ''systemd'' will then not open the encrypted device on boot, but instead wait until it is actually accessed and then automatically open it with the specified keyfile before mounting it. This might save a few seconds on boot if you are using an encrypted RAID device for example, because systemd does not have to wait for the device to become available. For example:

{{hc|/etc/crypttab|

data /dev/md0 /root/key noauto}}

=== Filepath spaces ===

If any mountpoint contains spaces, use the escape character {{ic|\}} followed by the 3 digit octal code {{ic|040}} to emulate them:

{{hc|/etc/fstab|2=

UUID=47FA-4071 /home/username/Camera<font color="grey">\040</font>Pictures vfat defaults,noatime 0 0

/dev/sda7 /media/100<font color="grey">\040</font>GB<font color="grey">\040</font>(Storage) ext4 defaults,noatime,user 0 2}}

=== External devices ===

External devices that are to be mounted when present but ignored if absent may require the {{ic|nofail}} option. This prevents errors being reported at boot.

{{hc|/etc/fstab|

/dev/sdg1 /media/backup jfs defaults,nofail 0 2}}

=== atime options ===

The use of {{ic|noatime}}, {{ic|nodiratime}} or {{ic|relatime}} can impact drive performance.

* The {{ic|atime}} option updates the ''atime'' of the files every time they are accessed. This is more purposeful when Linux is used for servers; it does not have much value for desktop use. The drawback about the {{ic|atime}} option is that even reading a file from the page cache (reading from memory instead of the drive) will still result in a write!

: Using the {{ic|noatime}} option fully disables writing file access times to the drive every time you read a file. This works well for almost all applications, except for a rare few like [[Mutt]] that needs such information. For mutt, you should only use the {{ic|relatime}} option.

: The {{ic|nodiratime}} option disables the writing of file access times only for directories while other files still get access times written.

: {{Note|{{ic|noatime}} already includes {{ic|nodiratime}}. [http://lwn.net/Articles/244941/ You do not need to specify both].}}

* {{ic|relatime}} enables the writing of file access times only when the file is being modified (unlike {{ic|noatime}} where the file access time will never be changed and will be older than the modification time). The best compromise might be the use this option since programs like [[Mutt]] will continue to work, but you will still have a performance boost as the files will not get access times updated unless they are modified. This option is used when the {{ic|defaults}} keyword option or no options at all are specified in ''fstab'' for a given mount point.

=== tmpfs ===

[[Wikipedia:Tmpfs|tmpfs]] is a temporary filesystem that resides in memory and/or your swap partition(s), depending on how much you fill it up. Mounting directories as tmpfs can be an effective way of speeding up accesses to their files, or to ensure that their contents are automatically cleared upon reboot.

Some directories where tmpfs is commonly used are [http://www.pathname.com/fhs/2.2/fhs-3.15.html /tmp], [http://www.pathname.com/fhs/2.2/fhs-5.9.html /var/lock] and [http://www.pathname.com/fhs/2.2/fhs-5.13.html /var/run]. Do NOT use it on [http://www.pathname.com/fhs/2.2/fhs-5.15.html /var/tmp], because that folder is meant for temporary files that are preserved across reboots. Arch uses a tmpfs {{ic|/run}} directory, with {{ic|/var/run}} and {{ic|/var/lock}} simply existing as symlinks for compatibility. It is also used for {{ic|/tmp}} by the default systemd setup and does not require an entry in {{ic|/etc/fstab}} unless a specific configuration is needed.

{{Note|When using [[systemd]], temporary files in tmpfs directories can be recreated at boot by using [[Systemd#Temporary_files|tmpfiles.d]].}}

By default, a tmpfs partition has its maximum size set to half your total RAM, but this can be customized. Note that the actual memory/swap consumption depends on how much you fill it up, as tmpfs partitions do not consume any memory until it is actually needed.

To explicitly set a maximum size, in this example to override the default {{ic|/tmp}} mount, use the {{ic|size}} mount option:

{{hc|/etc/fstab|2=

tmpfs /tmp tmpfs nodev,nosuid,size=2G 0 0}}

Here is a more advanced example showing how to add tmpfs mounts for users. This is useful for websites, mysql tmp files, {{ic|~/.vim/}}, and more. It's important to try and get the ideal mount options for what you are trying to accomplish. The goal is to have as secure settings as possible to prevent abuse. Limiting the size, and specifying uid and gid + mode is very secure. For more information on this subject, follow the links listed in the [[#See also]] section.

{{hc|/etc/fstab|2=

tmpfs /www/cache tmpfs rw,size=1G,nr_inodes=5k,noexec,nodev,nosuid,uid=648,gid=648,mode=1700 0 0}}

See the {{ic|mount}} command man page for more information. One useful mount option in the man page is the {{ic|default}} option. At least understand that.

Reboot for the changes to take effect. Note that although it may be tempting to simply run {{ic|mount -a}} to make the changes effective immediately, this will make any files currently residing in these directories inaccessible (this is especially problematic for running programs with lockfiles, for example). However, if all of them are empty, it should be safe to run {{ic|mount -a}} instead of rebooting (or mount them individually).

After applying changes, you may want to verify that they took effect by looking at {{ic|/proc/mounts}} and using {{ic|findmnt}}:

{{hc|$ findmnt --target /tmp|

TARGET SOURCE FSTYPE OPTIONS

/tmp tmpfs tmpfs rw,nosuid,nodev,relatime}}

==== Usage ====

Generally, I/O intensive tasks and programs that run frequent read/write operations can benefit from using a tmpfs folder. Some applications can even receive a substantial gain by offloading some (or all) of their data onto the shared memory. For example, [[Firefox_Ramdisk|relocating the Firefox profile into RAM]] shows a significant improvement in performance.

===== Improving compile times =====

Compiling requires handling of many small files and involves many I/O operations; therefore it is a prime activity to benefit from moving its working directory to a [[#tmpfs]].

====== For one session ======

The {{ic|BUILDDIR}} value may be exported within a shell to temporarily set [[makepkg]] build directory to an existing [[tmpfs]]:

$ BUILDDIR=/tmp/makepkg makepkg

====== Permanently ======

Just uncomment the {{ic|BUILDDIR}} line in {{ic|/etc/makepkg.conf}}, see [[Makepkg#Improving compile times]] for details.

=== Writing to FAT32 as Normal User ===

{{Merge|USB Storage Devices#Mounting USB memory|The linked section assumes that the partition on USB storage uses FAT32 or NTFS filesystem, so we have two sections covering the same topic. Either merge everything here or in the linked section.}}

To write on a FAT32 partition, you must make a few changes to your {{ic|/etc/fstab}} file.

{{hc|/etc/fstab|2=

/dev/sdxY /mnt/some_folder vfat user,rw,umask=000 0 0}}

The {{ic|user}} flag means that any user (even non-root) can mount and unmount the partition {{ic|/dev/sdX}}. {{ic|rw}} gives read-write access;

{{ic|umask}} option removes selected rights - for example {{ic|1=umask=111}} remove executable rights. The problem is that this entry removes executable rights from directories too, so we must correct it by {{ic|1=dmask=000}}. See also [[Umask]].

Without these options, all files will be executable. You can use the option {{ic|showexec}} instead of the umask and dmask options, which shows all Windows executables (com, exe, bat) in executable colours.

For example, if your FAT32 partition is on {{ic|/dev/sda9}}, and you wish to mount it to {{ic|/mnt/fat32}}, then you would use:

{{hc|/etc/fstab|2=

/dev/sda9 /mnt/fat32 vfat user,rw,umask=111,dmask=000 0 0}}

=== Remounting the root partition ===

If for some reason the root partition has been improperly mounted read only, remount the root partition with read-write access with the following command:

# mount -o remount,rw /

== See also ==

* [http://www.kernel.org/pub/linux/docs/lanana/device-list/devices-2.6.txt Full device listing including block device]

* [http://www.pathname.com/fhs/2.2/index.html Filesystem Hierarchy Standard]

* [http://www.askapache.com/web-hosting/super-speed-secrets.html 30x Faster Web-Site Speed] (Detailed tmpfs)

* [[Samba#Add Share to /etc/fstab|Adding Samba shares to /etc/fstab]]

Show more