Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

mount

Attach a file system (disk, partition, ISO, network share) to a folder, or show what is mounted.

Niveau
RHCSA-examen
Groep
Schijven en bestandssystemen
Root nodig
Voor wijzigingen
Pakket
util-linux

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

Wat het doet

mount DEVICE FOLDER makes the file system on DEVICE visible in FOLDER (the mount point). The type is detected automatically. mount -a mounts everything in /etc/fstab that is not mounted yet — the test after editing fstab. Options (-o) control the behaviour: read-only, no programs, no SUID …

Without arguments it lists all mounts; findmnt shows the same in a clearer way.

Zo schrijf je het

mount [OPTION]... DEVICE|UUID=…|LABEL=… DIRECTORY
mount [OPTION]... DEVICE|DIRECTORY
mount -a [-t TYPE] [-O OPTIONS]

Belangrijkste delen

defaults
rw, suid, dev, exec, auto, nouser, async.
ro / rw
Read-only / read-write.
noexec
Programs cannot run from this file system.
nosuid
SUID/SGID bits do not work.
nodev
Device files do not work.
noatime / relatime
Do not update / update access times sometimes.
_netdev
Network file system: mount after the network is up.
nofail
Do not fail the boot if the device is missing.
noauto
Not mounted by mount -a or at boot.
user / users
Normal users may mount it.
loop
Mount a file (like an ISO) through a loop device.
remount
Change options of a mounted file system.
bind
Mount a folder in a second place.
context=
SELinux context for the whole file system.
uid=, gid=, umask=
Owner and mode for file systems without Linux rights (vfat).

Opties 29

Meest gebruikt

-a, --all
Mount everything in /etc/fstab.
-t, --types TYPE
File system type (xfs, ext4, vfat, nfs, iso9660, tmpfs …).
-o, --options OPTIONS
Mount options, comma separated.
-r, --read-only
Read-only (same as -o ro).
-w, --rw, --read-write
Read-write.
-L, --label LABEL
Mount by label.
-U, --uuid UUID
Mount by UUID.
-B, --bind
Bind mount (a folder in another place).
-R, --rbind
Bind mount with all sub-mounts.
-M, --move
Move a mount to another folder.
-m, --mkdir[=MODE]
Create the mount point if it is missing.
-O, --test-opts OPTIONS
With -a: only fstab lines with these options.
-T, --fstab PATH
Use another fstab.
-F, --fork
With -a: mount in parallel.
-f, --fake
Do everything except the mount (test).
-n, --no-mtab
Do not write /etc/mtab (old systems).
-l, --show-labels
Show labels in the list.
-c, --no-canonicalize
Do not resolve paths.
-i, --internal-only
Do not call /sbin/mount.TYPE helpers.
-N, --namespace NS
Mount in another mount namespace.
--source DEVICE, --target DIR
Name the source or target clearly.
--target-prefix DIR
Prefix for all targets.
--onlyonce
Fail if already mounted.
--options-mode MODE
How to use fstab options (ignore, append, prepend, replace).
--options-source SOURCE
Where to read options (fstab, mtab, disable).
--options-source-force
Always read options from the source.
-v, --verbose
Verbose.
-h, --help
Show help.
-V, --version
Show the version.

Voorbeelden 12

$ als gewone gebruiker# als root (of met sudo)

  1. 1Mount a partition

    mkdir /data; mount /dev/vdb1 /data

    The type is detected.

  2. 2Mount by UUID or label

    mount UUID="4e5c7a6b-3f1d-4c2e-9a5b-7d2f8e1c0a93" /data
    mount LABEL=data /data

    Stable names.

  3. 3Test /etc/fstab

    systemctl daemon-reload; mount -a

    No output = all lines work. Do it before every reboot.

  4. 4Mount an ISO file

    mount -o loop,ro rhel-10.0-x86_64-dvd.iso /repo

    Use it as a local repository.

  5. 5Read-only

    mount -o ro /dev/vdb1 /mnt

    Safe for inspection of a disk.

  6. 6Change options without unmount

    mount -o remount,ro /data

    Also used in rescue mode: mount -o remount,rw /.

  7. 7Harden /tmp-like folders (security)

    mount -o remount,noexec,nosuid,nodev /var/tmp

    Attackers cannot run downloaded programs from there. Put it in fstab to keep it.

  8. 8Bind mount a folder

    mount --bind /srv/www /var/www/html

    Same files in two places.

  9. 9A RAM disk

    mount -t tmpfs -o size=512M tmpfs /mnt/ram

    Fast temporary space; gone after unmount.

  10. 10NFS share

    mount -t nfs server2:/exports/share /mnt

    Network file systems are covered in the NFS chapter.

  11. 11Create the mount point automatically

    mount -m /dev/vdb1 /mnt/new

    Newer util-linux.

  12. 12List mounts of one type

    mount -t xfs

    Or better: findmnt -t xfs.

Let op

  • Mounting on a folder hides its old content until you unmount.
  • A mount by hand is gone after reboot; use /etc/fstab or a mount unit.

Bestanden

/etc/fstab
File systems to mount at boot.
/proc/self/mountinfo
The kernel list of mounts.

Exitcodes

0 :: Done. 1 :: Wrong use or permissions. 2 :: System error (out of memory, cannot fork …). 4 :: Internal mount bug. 8 :: User interrupt. 16 :: Problems writing or locking mtab. 32 :: Mount failure. 64 :: Some mounts worked (with -a).

Volledige handleiding

Deze pagina legt het commando uit in eenvoudige woorden. De originele handleiding heeft elk detail.

In je terminal: man 8 mount