π Introduction
Storage management is a critical skill for every Linux administrator. Whether you're setting up a new server, managing cloud storage, or optimizing disk space, understanding disk partitioning is essential. From identifying different storage types to formatting and mounting partitions, this guide will walk you through the entire process in a simple and efficient way.
By the end of this guide, you'll be able to:
β
Identify and analyze disk storage
β
Create and format partitions with confidence
β
Mount and manage partitions like a pro
Let's dive in! ποΈπ½
ποΈ Types of Storage
- DAS (Direct Attached Storage) π΄ - Directly connected to a single server.
- NAS (Network Attached Storage) π - Shared over a network.
- SAN (Storage Area Network) ποΈ - High-speed storage network.
- LVM (Logical Volume Manager) π - Flexible partition management.
π§ Disk Naming in Linux π·οΈ
-
Old HDDs (IDE):
/dev/hda
ποΈ -
Newer Disks (SCSI/SAS):
/dev/sda
π -
Xen Hypervisor Disks:
/dev/xvda
π₯οΈ -
KVM/QEMU Disks:
/dev/vda
π -
Multipath Disks:
/dev/mpath
π -
NVMe SSDs:
/dev/nvme0n1
β‘
π Disk names are assigned by the kernel and can be managed via /etc/udev/rules
π Checking Disk Information ποΈ
- List all block devices ποΈ
lsblk -f
- View partition table π
sudo fdisk -l
- Check free space π
parted /dev/sda print free
π οΈ Creating a Partition βοΈ
- Open
fdisk
:
fdisk /dev/sda
- Press
m
for help π - Press
n
to create a new partition β - Choose partition type:
-
MSDOS (Legacy) ποΈ
- Max disk size: 8TB
- Max partition size: 2TB (use extended partitions)
-
GPT (Modern) π
- Supports larger disks and more partitions
-
MSDOS (Legacy) ποΈ
- Save changes with
w
πΎ
π Updating Kernel with New Partition π₯οΈ
partx -a /dev/sda
partprobe -s
If errors occur, reboot with:
init 6
π Formatting the Partition ποΈ
- Check available filesystems:
mkfs + [Tab]
- Create a filesystem (example ext4):
mkfs.ext4 /dev/sda3
π Mounting the Partition π
- Create a mount point:
mkdir /apppart3
- Mount temporarily:
mount /dev/sda3 /apppart3
β Verify Everything π§
df -h
blkid
π You're all set! Now, make the mount permanent by adding it to /etc/fstab
π―
π― Conclusion π
Understanding disk partitioning is crucial for system administrators and developers alike. Whether you're setting up a new storage device or troubleshooting an existing one, knowing how to check, partition, format, and mount disks is essential.
π₯ Key Takeaways:
- Always check disk space before partitioning π
- Choose the correct partition type (MSDOS/GPT) based on system needs βοΈ
- Use
mkfs
to format andmount
to attach partitions π - Make changes permanent via
/etc/fstab
ποΈ
Mastering these commands will give you full control over your storage devices and ensure optimal system performance! ππ
Top comments (0)