🐧
Linux
  • Introduction
  • 🖇️general
    • essentials
    • other commands
    • Superuser-do (sudo)
    • SUID, SGID, sticky bit
    • /dev/null
    • environment variables
    • special variables
    • shebang
  • spool
  • 🔧bash
    • overview
    • redirection
    • loop
    • .bashrc
  • text processing
    • grep
    • sed
    • awk
  • xxd/hexdump
  • text editors
    • nano
    • vi/vim
  • 📂filesystem & directories
    • Filesystem Hierachy Standard (FHS)
      • /etc
        • hosts, hosts.allow, hosts.deny
        • /cron.d
        • /httpd
        • /samba.d
        • hostname
        • crontab
        • shadow
        • passwd
        • profile
        • services
      • /dev
      • /proc
        • version
      • /mnt
      • /opt
      • /sbin
      • /lib
      • /usr
      • /tmp
      • /var
      • /bin
      • /run
    • chroot
  • find
  • locate
  • ⌚processes & jobs
    • cronjob
    • daemon
  • ⛓️system
    • systemctl
    • hostname
    • systemd
  • 🗃️media
    • ffmpeg
    • pdftk
  • 🔒Security
    • ufw
  • firejail
  • apparmor
  • 📦Package management
    • dpkg
    • apt/apt-get
  • Storage
    • lsblk
    • mount/umount
  • df/du
  • user management
    • chsh
  • Networking
    • Introduction
    • routing table/interface management
    • /etc/hosts, /etc/hosts.allow, /etc/hosts.deny
Powered by GitBook
On this page
  • mount command
  • Example
  • umount command
  • Example
  1. Storage

mount/umount

The mount and umount commands are used to attach (mount) or detach (unmount) filesystems to/from the system's directory tree, respectively.

mount command

The mount command can be used to attach a filesystem (such as from a storage device, like a hard drive or USB) to a specific directory on the system's directory tree. This allows the attached filesystem to be accessible from the mount point.

Basic command:

$ mount <storage_device> <mount_point> 

<storage_device>: The storage device or partition to mount (eg. /dev/sda1, /dev/sdb1, etc.)

<mount_point>: The directory to mount the filesystem defined by the <storage_device> value, to allow it be accessible from (eg. /mnt, /media, etc.)

Example

To mount the device /dev/sda1 to the /mnt/test-mount directory.

$ mount /dev/sda1 /mnt/test-mount

This allows the contents of the filesystem on /dev/sda1 to be accessible from /mnt/test-mount. The chroot command can be used to change the root directory to /mnt/test-mount, to be able to work directly from there. (https://jarrettgxz-sec.gitbook.io/linux/filesystem-and-directories/chroot)

umount command

The umount command can be used to detach a filesystem. It ensures that the filesystem is properly unmounted before it can be physically removed or shut down.

Basic command:

$ umount <storage_device or mount_point> 

<storage_device or mount_point>: Either the storage device that was mounted, or mount point. (eg. /dev/sda1, /dev/sdb1, /mnt, /media, etc.)

Example

To unmount the device /dev/sda1 (/mnt/test-mount directory).

$ umount /dev/sda1 
# OR
$ umount /mnt/test-mount

This command unmounts the filesystem, making it no longer accessible from the mount point location.

PreviouslsblkNextdf/du

Last updated 6 months ago