> For the complete documentation index, see [llms.txt](https://www.shellspells.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.shellspells.net/linux/system-ops/filesystem/drives-and-partitions.md).

# Drives & Partitions

## <mark style="color:red;">Enumerate</mark>

<table data-header-hidden data-full-width="true"><thead><tr><th width="252">Command</th><th>Description</th></tr></thead><tbody><tr><td><mark style="color:yellow;"><code>fdisk -l</code></mark></td><td>List Partitions and Drives.</td></tr><tr><td><mark style="color:yellow;"><code>parted -l</code></mark></td><td>List Partitions and Drives (with more details).</td></tr><tr><td><mark style="color:yellow;"><code>lsblk</code></mark></td><td>List Block Devices.</td></tr><tr><td><mark style="color:yellow;"><code>blkid</code></mark></td><td>List block devices and their UUIDs. Useful for identifying specific drives.</td></tr><tr><td><mark style="color:yellow;"><code>hdparm -i /dev/sda</code></mark></td><td>Information about a SATA drive.</td></tr><tr><td><mark style="color:yellow;"><code>smartctl -a /dev/sda</code></mark></td><td>S.M.A.R.T. data for a SATA drive (health status).</td></tr><tr><td><mark style="color:yellow;"><code>cat /etc/fstab</code></mark></td><td>List Filesystems from /etc/fstab.</td></tr><tr><td><mark style="color:yellow;"><code>mount</code></mark></td><td>List Mounted Filesystems.</td></tr><tr><td><mark style="color:yellow;"><code>df -h</code></mark></td><td>Display Disk Usage and Free Space (Human-Readable).</td></tr><tr><td><mark style="color:yellow;"><code>df -t</code></mark></td><td>Filesystem types.</td></tr><tr><td><mark style="color:yellow;"><code>df -i</code></mark></td><td>Inode usage.</td></tr><tr><td><mark style="color:yellow;"><code>du -sh &#x3C;dir></code></mark></td><td>Display Directory Disk Usage (Human-Readable).</td></tr><tr><td><mark style="color:yellow;"><code>statvfs &#x3C;dir></code></mark></td><td>Display Filesystem Information.</td></tr></tbody></table>

Block Device = Storage device that manages data in fixed-size blocks or chunks.

## <mark style="color:red;">Modify</mark>

<table data-header-hidden data-full-width="true"><thead><tr><th width="411">Command</th><th>Description</th></tr></thead><tbody><tr><td><mark style="color:yellow;"><code>fdisk &#x3C;device></code></mark></td><td>Interactively Create and Manage Disk Partitions (e.g., <mark style="color:yellow;"><code>fdisk /dev/sda</code></mark>).</td></tr><tr><td><mark style="color:yellow;"><code>parted &#x3C;device></code></mark></td><td>Interactively Create and Manage Disk Partitions with more features (e.g., <mark style="color:yellow;"><code>parted /dev/sda</code></mark>).</td></tr><tr><td><mark style="color:yellow;"><code>resize2fs &#x3C;partition></code></mark></td><td>Resize an Ext2/Ext3/Ext4 Filesystem on a Partition.</td></tr><tr><td><mark style="color:yellow;"><code>gparted</code></mark></td><td>Graphical Partition Editor for managing partitions.</td></tr><tr><td><mark style="color:yellow;"><code>umount &#x3C;mount_point></code></mark></td><td>Unmount a Mounted Filesystem (e.g., <mark style="color:yellow;"><code>umount /mnt/mydrive</code></mark>).</td></tr><tr><td><mark style="color:yellow;"><code>sync</code></mark></td><td>Synchronize Cached Data to Disk.</td></tr><tr><td><mark style="color:yellow;"><code>partprobe</code></mark></td><td>Inform the OS of Partition Table Changes.</td></tr><tr><td><mark style="color:yellow;"><code>gdisk &#x3C;device></code></mark></td><td>GUID Partition Table (GPT) Disk Utility (e.g., <mark style="color:yellow;"><code>gdisk /dev/sda</code></mark>).</td></tr><tr><td><mark style="color:yellow;"><code>mkpart</code></mark></td><td>Create a New Partition in <mark style="color:yellow;"><code>gdisk</code></mark>.</td></tr><tr><td><mark style="color:yellow;"><code>resizepart</code></mark></td><td>Resize a Partition in <mark style="color:yellow;"><code>gdisk</code></mark>.</td></tr><tr><td><mark style="color:yellow;"><code>mklabel</code></mark></td><td>Create a GPT Label in <mark style="color:yellow;"><code>gdisk</code></mark>.</td></tr><tr><td><mark style="color:yellow;"><code>partx</code></mark></td><td>Create Device Maps for Partitions.</td></tr><tr><td><mark style="color:yellow;"><code>lvm</code></mark></td><td>Logical Volume Manager for managing logical volumes.</td></tr><tr><td><mark style="color:yellow;"><code>pvcreate</code></mark></td><td>Initialize a Physical Volume for use in LVM (e.g., <mark style="color:yellow;"><code>pvcreate /dev/sdb1</code></mark>).</td></tr><tr><td><mark style="color:yellow;"><code>vgcreate</code></mark></td><td>Create a Volume Group in LVM (e.g., <mark style="color:yellow;"><code>vgcreate myvg /dev/sdb1</code></mark>).</td></tr><tr><td><mark style="color:yellow;"><code>lvcreate</code></mark></td><td>Create a Logical Volume in LVM (e.g., <mark style="color:yellow;"><code>lvcreate -L 10G -n mylv myvg</code></mark>).</td></tr><tr><td><mark style="color:yellow;"><code>lvresize</code></mark></td><td>Resize a Logical Volume in LVM (e.g., <mark style="color:yellow;"><code>lvresize -L +2G /dev/myvg/mylv</code></mark>).</td></tr><tr><td><mark style="color:yellow;"><code>mkswap &#x3C;partition></code></mark></td><td>Create a Swap Space on a Partition (e.g., <mark style="color:yellow;"><code>mkswap /dev/sdb2</code></mark>).</td></tr><tr><td><mark style="color:yellow;"><code>swapon &#x3C;partition></code></mark></td><td>Enable Swap Space on a Partition (e.g., <mark style="color:yellow;"><code>swapon /dev/sdb2</code></mark>).</td></tr><tr><td><mark style="color:yellow;"><code>swapoff &#x3C;partition></code></mark></td><td>Disable Swap Space on a Partition (e.g., <mark style="color:yellow;"><code>swapoff /dev/sdb2</code></mark>).</td></tr><tr><td><mark style="color:yellow;"><code>mdadm</code></mark></td><td>Manage Software RAID (Redundant Array of Independent Disks).</td></tr><tr><td><mark style="color:yellow;"><code>mkraid</code></mark></td><td>Create a Software RAID Array.</td></tr><tr><td><mark style="color:yellow;"><code>mdadm --create</code></mark></td><td>Create a RAID Device.</td></tr><tr><td><mark style="color:yellow;"><code>mdadm --add</code></mark></td><td>Add a Disk to an Existing RAID array.</td></tr><tr><td><mark style="color:yellow;"><code>mdadm --remove</code></mark></td><td>Remove a Disk from a RAID array.</td></tr><tr><td><mark style="color:yellow;"><code>mdadm --grow</code></mark></td><td>Grow or Resize a RAID array.</td></tr><tr><td><mark style="color:yellow;"><code>mkfs &#x3C;filesystem_type> &#x3C;partition></code></mark></td><td>Create a Filesystem on a Partition (e.g., <mark style="color:yellow;"><code>mkfs.ext4 /dev/sda1</code></mark>).</td></tr><tr><td><mark style="color:yellow;"><code>dd</code></mark></td><td>Copy Data from One Device/Partition to another.</td></tr><tr><td><mark style="color:yellow;"><code>dd if=&#x3C;source> of=&#x3C;destination></code></mark></td><td>Copy Data from Source to Destination (e.g., <mark style="color:yellow;"><code>dd if=/dev/sdb of=/dev/sdc</code></mark>).</td></tr><tr><td><mark style="color:yellow;"><code>dd if=&#x3C;source> of=&#x3C;destination> bs=&#x3C;block_size></code></mark></td><td>Copy Data with Specified Block Size (e.g., <mark style="color:yellow;"><code>dd if=/dev/sdb of=/dev/sdc bs=4M</code></mark>).</td></tr></tbody></table>
