Skip to main content

The concept of Mounting in Linux

A detailed explanation of Partitioning disks andMounting process in Linux systems, with a simple comparison to Windows. I'll give you an organized summary of the most important points:

1. What is Partition?

  • Partition A reserved portion of a hard disk (Disk) that has a defined beginning and end (using sextants).
  • It is created Partition Table to record the start and end information for each partition.
  • Without the parity table, the system wouldn't know how to access the data even if it's already on disk.

2. Partition Formatting

  • After creating the parade, you must Initialize it with a File System like ext4 or xfs or ntfs to be ready to store data.
  • Example:
    mkfs.xfs /dev/nvme0n1p1 # Initialize the Partition with the XFS file system

3. Mounting

  • Almont This is the process of linking a partition to a directory in the Linux file system structure to make it usable.
  • Types of mont:
    • Temporary Mount: It disappears after a reboot.
      mount /dev/nvme0n1p1 /mnt
    • Permanent Mount: Recorded in a file /etc/fstab to remain after a reboot.
      /dev/nvme0n1p1 /mnt xfs defaults 0 0 0

4. File /etc/fstab

  • is the file responsible for Permanent mont. It has 6 columns:
    1. Device: Can be used:
      • Device name (e.g. /dev/nvme0n1p1).
      • The UUID (better because it doesn't change).
      • The Label (a user-defined name).
    2. Mount Point: like /mnt or /media.
    3. File System: like xfs or ext4.
    4. Options: like defaultsand, uh. ro (read-only). noexec (prevents execution).
    5. Backup (Dump): 0 Means no backup.
    6. Fsck Order: 0 means no examination. 1 of high importance (e.g. /). 2 For other partitions.

5. Useful commands

  • Display of partitions:
    lsblk
  • Display the current mont:
    mount
  • Cancel the mont:
    umount /mnt
  • Bring back Mount Partition with new options:
    mount -o remount,ro /dev/nvme0n1p1/mnt

6. Difference between temporary and permanent mont

Feature Temporary mont Permanent mont
Survival after reboot ❌ No ✔️ Yes
Method of execution By order mount Live Add to /etc/fstab
Administrator User (manual) System systemd (automatically)

7. Important tips

  • Use UUID instead of the device name in /etc/fstab to avoid issues if the device name changes.
  • Example of getting a UUID:
    blkid /dev/nvme0n1p1
  • Avoid writing /etc/fstab manually if you are unsure: You can copy the line from /etc/mtab (which records the current mont) and paste it into /etc/fstab.

8. Common mistakes

  • If a message appears "read-only file system"It may be a pending read-only protection (ROP). Solution: Return the mont with write permissions:
    mount -o remount,rw /dev/nvme0n1p1 /mnt

Conclusion

  • Partition is a disk partition, andAlmont is to connect it to the system.
  • Permanent monetization is done via /etc/fstaband the timer by order of mount.
  • Use UUID or Label More secure than device names.
If you have any specific questions, ask and I'll answer in more detail!

Leave a Reply