Learn Linux Disk Partitioning and Mounting in 5 Minutes

Partitioning and mounting disks in Linux are fundamental operations for managing storage, analogous to closet organization and entry points. The steps are as follows: 1. **Check Disks**: Use `lsblk` or `sudo fdisk -l` to identify hard drives/partitions, and `df -h` to view currently mounted partitions. 2. **Create Partition**: Enter the tool with `sudo fdisk /dev/sdb`, input `n` to create a new primary partition, specify the size (e.g., `+20G`), and save with `w`. 3. **Format**: Format with `sudo mkfs.ext4 /dev/sdb1` (e.g., using the ext4 filesystem). **Always back up data before formatting**. 4. **Temporary Mount**: Create a mount point with `sudo mkdir /mnt/mynewdisk`, then mount with `sudo mount /dev/sdb1 /mnt/mynewdisk`. 5. **Permanent Mount**: Use `sudo blkid` to get the UUID, edit `/etc/fstab` to add an entry (format: `UUID=... 挂载点 ext4 defaults 0 0`), and verify with `sudo mount -a`. Key points: Partition → Format → Mount → Persistence. Back up data before operations, and use `umount` for unmounting.

Read More