Mounting and unmounting in GNU/Linux

Hector's goal is to become the world's premier expert on GNU/Linux filesystems and storage. This month, he wants to focus on mastering mounting and unmounting drives and filesystems in GNU/Linux. Please generate detailed notes that Hector can study to help him to master mounting and unmounting. Assume that he is working on a modern Debian server.

Mastering Mounting and Unmounting Drives and Filesystems in GNU/Linux (Debian)

Introduction: Mounting and unmounting drives and filesystems is a fundamental skill for any GNU/Linux system administrator, especially for Hector, who aims to become an expert in GNU/Linux filesystems and storage. This guide will provide comprehensive notes to help Hector understand and master the concepts of mounting and unmounting on a modern Debian server.

Table of Contents:

  1. Understanding Mount Points:

    • A mount point is a directory in the filesystem where a device or partition is attached.
    • Common mount points include /mnt, /media, and /mnt/<custom>.
  2. Viewing Existing Mounts:

    • Use the mount command to display currently mounted filesystems.
    • df -h shows disk space usage and mounted filesystems.
    • lsblk provides information about block devices.
  3. Mounting Drives and Filesystems:

    • Syntax: mount -t <filesystem_type> <device> <mount_point>
    • Example: mount -t ext4 /dev/sdb1 /mnt/data
  4. Automatic Mounting at Boot:

    • Add entries to /etc/fstab for automatic mounts during boot.
    • Use UUID or LABEL to refer to devices to prevent issues if device names change.
    • Example /etc/fstab entry:
      UUID=<UUID> <mount_point> <filesystem_type> defaults 0 2
  5. Unmounting Drives and Filesystems:

    • Use umount <mount_point> to unmount a filesystem.
    • Example: umount /mnt/data
    • Use umount -l <mount_point> to force an unmount.
  6. Removable Media and Mounting:

    • Automount tools like udisks2 can handle removable devices.
    • These devices are often mounted under /media/<username>/<device_name>.
  7. Mounting Network Shares:

    • Install cifs-utils for mounting Windows shares using the mount.cifs command.
    • Syntax: mount.cifs //<server>/<share> <mount_point> -o <options>
    • Example: mount.cifs //192.168.1.100/share /mnt/windows -o username=user,password=pass
  8. Common Mount Options:

    • defaults: Mount with default options.
    • noauto: Do not mount at boot.
    • ro: Mount read-only.
    • rw: Mount read-write.
    • user: Allow regular users to mount/unmount.
    • Refer to man mount for more options.
  9. Handling Errors and Issues:

    • If a filesystem is in use, unmounting may fail.
    • Check for open files with lsof | grep <mount_point>.
    • Use fuser -m <mount_point> to identify processes using the filesystem.
  10. Best Practices:

    • Avoid unnecessary mounting and unmounting to reduce wear on devices.
    • Regularly check for mounted filesystems and review /etc/fstab entries.
    • Always backup data before making significant changes.

Conclusion: By studying and understanding these comprehensive notes on mounting and unmounting drives and filesystems in GNU/Linux, Hector will be well-equipped to handle various storage scenarios on his modern Debian server. Practicing these concepts and consistently exploring real-world scenarios will contribute to Hector's goal of becoming a premier expert in GNU/Linux filesystems and storage.

You should also read:

GNU/Linux xargs command

Rene is a RHEL Sysadmin in training. Please generate a detailed essay that will help her to master the GNU/Linux xargs command. Title:…

sysctl command in GNU/Linux

Victor is studying to become a RHEL Sysdamin. He wants to master the GNU/Linux sysctl command. Please write an essay for Victor's consumption…