Drives & Partitions
Enumerate
fdisk -l
List Partitions and Drives.
parted -l
List Partitions and Drives (with more details).
lsblk
List Block Devices.
blkid
List block devices and their UUIDs. Useful for identifying specific drives.
hdparm -i /dev/sda
Information about a SATA drive.
smartctl -a /dev/sda
S.M.A.R.T. data for a SATA drive (health status).
cat /etc/fstab
List Filesystems from /etc/fstab.
mount
List Mounted Filesystems.
df -h
Display Disk Usage and Free Space (Human-Readable).
df -t
Filesystem types.
df -i
Inode usage.
du -sh <dir>
Display Directory Disk Usage (Human-Readable).
statvfs <dir>
Display Filesystem Information.
Block Device = Storage device that manages data in fixed-size blocks or chunks.
Modify
fdisk <device>
Interactively Create and Manage Disk Partitions (e.g., fdisk /dev/sda
).
parted <device>
Interactively Create and Manage Disk Partitions with more features (e.g., parted /dev/sda
).
resize2fs <partition>
Resize an Ext2/Ext3/Ext4 Filesystem on a Partition.
gparted
Graphical Partition Editor for managing partitions.
umount <mount_point>
Unmount a Mounted Filesystem (e.g., umount /mnt/mydrive
).
sync
Synchronize Cached Data to Disk.
partprobe
Inform the OS of Partition Table Changes.
gdisk <device>
GUID Partition Table (GPT) Disk Utility (e.g., gdisk /dev/sda
).
mkpart
Create a New Partition in gdisk
.
resizepart
Resize a Partition in gdisk
.
mklabel
Create a GPT Label in gdisk
.
partx
Create Device Maps for Partitions.
lvm
Logical Volume Manager for managing logical volumes.
pvcreate
Initialize a Physical Volume for use in LVM (e.g., pvcreate /dev/sdb1
).
vgcreate
Create a Volume Group in LVM (e.g., vgcreate myvg /dev/sdb1
).
lvcreate
Create a Logical Volume in LVM (e.g., lvcreate -L 10G -n mylv myvg
).
lvresize
Resize a Logical Volume in LVM (e.g., lvresize -L +2G /dev/myvg/mylv
).
mkswap <partition>
Create a Swap Space on a Partition (e.g., mkswap /dev/sdb2
).
swapon <partition>
Enable Swap Space on a Partition (e.g., swapon /dev/sdb2
).
swapoff <partition>
Disable Swap Space on a Partition (e.g., swapoff /dev/sdb2
).
mdadm
Manage Software RAID (Redundant Array of Independent Disks).
mkraid
Create a Software RAID Array.
mdadm --create
Create a RAID Device.
mdadm --add
Add a Disk to an Existing RAID array.
mdadm --remove
Remove a Disk from a RAID array.
mdadm --grow
Grow or Resize a RAID array.
mkfs <filesystem_type> <partition>
Create a Filesystem on a Partition (e.g., mkfs.ext4 /dev/sda1
).
dd
Copy Data from One Device/Partition to another.
dd if=<source> of=<destination>
Copy Data from Source to Destination (e.g., dd if=/dev/sdb of=/dev/sdc
).
dd if=<source> of=<destination> bs=<block_size>
Copy Data with Specified Block Size (e.g., dd if=/dev/sdb of=/dev/sdc bs=4M
).
Last updated
Was this helpful?