{"id":161425,"date":"2026-03-19T02:25:35","date_gmt":"2026-03-18T23:25:35","guid":{"rendered":"https:\/\/cloudspinx.com\/?p=73954"},"modified":"2026-03-19T02:25:57","modified_gmt":"2026-03-18T23:25:57","slug":"lpic-101-partitions-filesystems-linux","status":"publish","type":"post","link":"https:\/\/computingforgeeks.com\/lpic-101-partitions-filesystems-linux\/","title":{"rendered":"LPIC 101 &#8211; Managing Partitions and Filesystems on Linux"},"content":{"rendered":"\n<p>Managing partitions and filesystems is one of the most critical skills tested on the LPIC-1 (101-500) exam. Whether you are setting up a fresh server, expanding storage on a production box, or recovering from a disk failure at 2 AM, you need to know these tools cold. This guide covers every partition and filesystem topic you will encounter on the exam, with real command examples and explanations that go beyond surface-level theory.<\/p>\n\n\n\n<p>This post maps directly to <strong>LPIC-1 Objective 104.1<\/strong> (Create partitions and filesystems), <strong>104.2<\/strong> (Maintain the integrity of filesystems), and <strong>104.3<\/strong> (Control mounting and unmounting of filesystems). We also touch on <strong>Objective 102.1<\/strong> (Design hard disk layout) where relevant.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Linux Disk Naming Conventions<\/h2>\n\n\n\n<p>Before you touch any partitioning tool, you need to understand how Linux names its block devices. The kernel assigns device nodes under <code>\/dev\/<\/code> based on the controller type and detection order.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">SCSI\/SATA\/USB Disks (\/dev\/sd*)<\/h3>\n\n\n\n<p>Traditional SATA drives, SAS drives, and USB storage all appear as <code>\/dev\/sda<\/code>, <code>\/dev\/sdb<\/code>, <code>\/dev\/sdc<\/code>, and so on. The letter increments with each detected device. Partitions on these disks are numbered: <code>\/dev\/sda1<\/code>, <code>\/dev\/sda2<\/code>, <code>\/dev\/sda3<\/code>.<\/p>\n\n\n\n<p>For MBR-partitioned disks, primary partitions are numbered 1 through 4. Logical partitions inside an extended partition always start at number 5, regardless of how many primary partitions exist.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">NVMe Disks (\/dev\/nvme*)<\/h3>\n\n\n\n<p>NVMe SSDs use a different naming scheme. The controller is <code>\/dev\/nvme0<\/code>, the first namespace (think &#8220;disk&#8221;) on that controller is <code>\/dev\/nvme0n1<\/code>, and partitions are <code>\/dev\/nvme0n1p1<\/code>, <code>\/dev\/nvme0n1p2<\/code>, etc. A second NVMe controller would be <code>\/dev\/nvme1<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">VirtIO Disks (\/dev\/vd*)<\/h3>\n\n\n\n<p>Virtual machines running on KVM\/QEMU with the VirtIO driver expose disks as <code>\/dev\/vda<\/code>, <code>\/dev\/vdb<\/code>, etc. Partitions follow the same pattern as SCSI: <code>\/dev\/vda1<\/code>, <code>\/dev\/vda2<\/code>. You will see these on every major cloud provider that runs KVM underneath.<\/p>\n\n\n\n<p>You can always check what block devices the kernel sees with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>lsblk<\/code><\/pre>\n\n\n\n<p>That command gives you a tree view of all disks, partitions, and their mount points. It is one of the first commands you should run when troubleshooting storage.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. Partition Tables: MBR vs GPT<\/h2>\n\n\n\n<p>Every disk needs a partition table before you can carve it into usable partitions. Linux supports two types, and the LPIC exam expects you to know both thoroughly.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">MBR (Master Boot Record)<\/h3>\n\n\n\n<p>MBR has been around since 1983. The partition table lives in the first 512 bytes of the disk. Key limitations:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Maximum disk size of 2 TiB (2,199,023,255,552 bytes)<\/li>\n<li>Maximum of 4 primary partitions<\/li>\n<li>To get more than 4 partitions, you sacrifice one primary slot for an extended partition, which then holds logical partitions<\/li>\n<li>No built-in redundancy for the partition table itself<\/li>\n<\/ul>\n\n\n\n<p>MBR is still used on older systems, small disks, and legacy BIOS boot setups. If you are working with disks under 2 TiB and need BIOS boot compatibility, MBR works fine.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">GPT (GUID Partition Table)<\/h3>\n\n\n\n<p>GPT is part of the UEFI specification and removes nearly every MBR limitation:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Supports disks up to 9.4 ZB (zettabytes) in theory<\/li>\n<li>Up to 128 partitions by default (no need for extended\/logical partitions)<\/li>\n<li>Each partition is identified by a unique GUID<\/li>\n<li>The partition table is stored at the beginning and end of the disk, providing redundancy<\/li>\n<li>Includes CRC32 checksums for integrity verification<\/li>\n<\/ul>\n\n\n\n<p>Use GPT for any disk over 2 TiB, any UEFI system, and any new installation where you have no reason to stick with MBR. Modern Linux distributions default to GPT.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. Partitioning with fdisk (MBR Disks)<\/h2>\n\n\n\n<p><code>fdisk<\/code> is the classic interactive partitioning tool for MBR disks. Modern versions of fdisk can also handle GPT, but for the exam, associate fdisk with MBR and gdisk with GPT.<\/p>\n\n\n\n<p>List all partitions on the system:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo fdisk -l<\/code><\/pre>\n\n\n\n<p>To work on a specific disk interactively:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo fdisk \/dev\/sdb<\/code><\/pre>\n\n\n\n<p>Once inside the fdisk prompt, these are the commands you need to memorize:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>p<\/strong> &#8211; Print the current partition table<\/li>\n<li><strong>n<\/strong> &#8211; Create a new partition<\/li>\n<li><strong>d<\/strong> &#8211; Delete a partition<\/li>\n<li><strong>t<\/strong> &#8211; Change the partition type (e.g., 82 for Linux swap, 83 for Linux, 8e for Linux LVM)<\/li>\n<li><strong>w<\/strong> &#8211; Write changes to disk and exit<\/li>\n<li><strong>q<\/strong> &#8211; Quit without saving<\/li>\n<li><strong>m<\/strong> &#8211; Display the help menu<\/li>\n<\/ul>\n\n\n\n<p>Here is a typical workflow for creating a new primary partition. After running <code>sudo fdisk \/dev\/sdb<\/code>, you would press <code>n<\/code> for a new partition, <code>p<\/code> for primary, accept the default partition number, accept the default first sector, then type <code>+10G<\/code> to make it 10 GiB. Press <code>w<\/code> to write and exit.<\/p>\n\n\n\n<p>After writing the partition table, inform the kernel about the changes:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo partprobe \/dev\/sdb<\/code><\/pre>\n\n\n\n<p>The <code>partprobe<\/code> command re-reads the partition table without requiring a reboot. On older kernels, you might need to use <code>partx -a \/dev\/sdb<\/code> instead.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4. Partitioning with gdisk (GPT Disks)<\/h2>\n\n\n\n<p><code>gdisk<\/code> is the GPT counterpart to fdisk. The interface is deliberately similar, so if you know fdisk, you already know most of gdisk.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo gdisk \/dev\/sdc<\/code><\/pre>\n\n\n\n<p>Key commands inside gdisk:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>p<\/strong> &#8211; Print the partition table<\/li>\n<li><strong>n<\/strong> &#8211; Create a new partition<\/li>\n<li><strong>d<\/strong> &#8211; Delete a partition<\/li>\n<li><strong>t<\/strong> &#8211; Change partition type code (uses GUID type codes like 8300 for Linux filesystem, 8200 for Linux swap, 8e00 for Linux LVM)<\/li>\n<li><strong>i<\/strong> &#8211; Show detailed info about a partition<\/li>\n<li><strong>w<\/strong> &#8211; Write changes and exit<\/li>\n<li><strong>q<\/strong> &#8211; Quit without saving<\/li>\n<\/ul>\n\n\n\n<p>Creating a partition in gdisk follows the same flow as fdisk. The main difference is the partition type codes. GPT type codes are four hex digits (like 8300) instead of the two-digit MBR codes (like 83).<\/p>\n\n\n\n<p>One important gdisk feature: you can convert an MBR disk to GPT with the <code>r<\/code> (recovery) menu followed by <code>f<\/code> (load MBR and convert to GPT). Do this with extreme care on production systems and always have a backup.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">5. Partitioning with parted (MBR and GPT)<\/h2>\n\n\n\n<p><code>parted<\/code> handles both MBR and GPT disks and, unlike fdisk and gdisk, can resize partitions. This makes it the most versatile partitioning tool in the Linux toolkit.<\/p>\n\n\n\n<p>Launch parted on a specific disk:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo parted \/dev\/sdd<\/code><\/pre>\n\n\n\n<p>Print the current partition layout:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>(parted) print<\/code><\/pre>\n\n\n\n<p>Create a GPT partition table on a new disk:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>(parted) mklabel gpt<\/code><\/pre>\n\n\n\n<p>For an MBR table, use <code>mklabel msdos<\/code> instead. Create a partition spanning from 1 MiB to 20 GiB:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>(parted) mkpart primary ext4 1MiB 20GiB<\/code><\/pre>\n\n\n\n<p>Resize a partition (this is where parted shines):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>(parted) resizepart 1 40GiB<\/code><\/pre>\n\n\n\n<p><strong>Critical warning:<\/strong> parted writes changes immediately. There is no &#8220;write and quit&#8221; step like fdisk. Every command you run takes effect on the disk right away. Double-check your commands before pressing Enter.<\/p>\n\n\n\n<p>You can also run parted in non-interactive (scripted) mode, which is useful for automation:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo parted -s \/dev\/sdd mkpart primary ext4 1MiB 20GiB<\/code><\/pre>\n\n\n\n<p>The <code>-s<\/code> flag suppresses the interactive prompts.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">6. Creating Filesystems with mkfs<\/h2>\n\n\n\n<p>A partition without a filesystem is just raw space. The <code>mkfs<\/code> family of commands formats partitions with the filesystem of your choice. The LPIC exam covers four filesystem types in detail.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">ext4<\/h3>\n\n\n\n<p>ext4 is the default filesystem on most Linux distributions. It is mature, well-tested, and handles general-purpose workloads reliably. Key features:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Maximum volume size: 1 EiB<\/li>\n<li>Maximum file size: 16 TiB<\/li>\n<li>Journaling (metadata and optionally data)<\/li>\n<li>Extents-based allocation for reduced fragmentation<\/li>\n<li>Backward compatible with ext2 and ext3<\/li>\n<li>Online resizing (grow only)<\/li>\n<\/ul>\n\n\n\n<p>Create an ext4 filesystem:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mkfs.ext4 \/dev\/sdb1<\/code><\/pre>\n\n\n\n<p>Add a label during creation for easier identification:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mkfs.ext4 -L \"data_vol\" \/dev\/sdb1<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">XFS<\/h3>\n\n\n\n<p>XFS is the default on RHEL\/CentOS\/Rocky Linux. It excels at handling large files and parallel I\/O. Key features:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Maximum volume size: 8 EiB<\/li>\n<li>Maximum file size: 8 EiB<\/li>\n<li>Excellent performance for large sequential writes<\/li>\n<li>Allocation groups allow parallel I\/O operations<\/li>\n<li>Online resizing (grow only, cannot shrink)<\/li>\n<li>Online defragmentation with <code>xfs_fsr<\/code><\/li>\n<\/ul>\n\n\n\n<p>Create an XFS filesystem:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mkfs.xfs \/dev\/sdb2<\/code><\/pre>\n\n\n\n<p>If the partition already has a filesystem and you want to overwrite it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mkfs.xfs -f \/dev\/sdb2<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Btrfs<\/h3>\n\n\n\n<p>Btrfs (B-tree filesystem) is a copy-on-write filesystem with advanced features. openSUSE uses it as the default. Key features:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Maximum volume size: 16 EiB<\/li>\n<li>Built-in snapshots and subvolumes<\/li>\n<li>Transparent compression (zlib, lzo, zstd)<\/li>\n<li>Built-in RAID support (RAID 0, 1, 10)<\/li>\n<li>Online resizing (grow and shrink)<\/li>\n<li>Data and metadata checksumming<\/li>\n<\/ul>\n\n\n\n<p>Create a Btrfs filesystem:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mkfs.btrfs \/dev\/sdb3<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">vfat (FAT32)<\/h3>\n\n\n\n<p>vfat is the Linux implementation of Microsoft&#8217;s FAT32. You will use it for EFI System Partitions (ESP) and USB drives that need to work across operating systems. Key features:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Maximum file size: 4 GiB<\/li>\n<li>Maximum volume size: 2 TiB (with 512-byte sectors)<\/li>\n<li>No file permissions, no journaling, no symlinks<\/li>\n<li>Universal cross-platform compatibility<\/li>\n<\/ul>\n\n\n\n<p>Create a FAT32 filesystem:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mkfs.vfat -F 32 \/dev\/sdb4<\/code><\/pre>\n\n\n\n<p>The <code>-F 32<\/code> flag explicitly selects FAT32 rather than FAT12 or FAT16.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">7. Mounting Filesystems<\/h2>\n\n\n\n<p>Creating a filesystem is only half the job. You need to mount it to make it accessible. Linux gives you several ways to handle this.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Manual Mounting with mount<\/h3>\n\n\n\n<p>Mount a filesystem to a directory:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mount \/dev\/sdb1 \/mnt\/data<\/code><\/pre>\n\n\n\n<p>The mount point directory must exist before you mount. If it does not:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mkdir -p \/mnt\/data<\/code><\/pre>\n\n\n\n<p>View all currently mounted filesystems:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mount | column -t<\/code><\/pre>\n\n\n\n<p>Or for a cleaner output, use <code>findmnt<\/code> which reads from <code>\/proc\/self\/mountinfo<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>findmnt --real<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Mount Options<\/h3>\n\n\n\n<p>The <code>-o<\/code> flag lets you specify mount options. These come up frequently on the exam:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>ro<\/strong> \/ <strong>rw<\/strong> &#8211; Mount read-only or read-write<\/li>\n<li><strong>noexec<\/strong> &#8211; Prevent execution of binaries on this filesystem<\/li>\n<li><strong>nosuid<\/strong> &#8211; Ignore SUID and SGID bits<\/li>\n<li><strong>nodev<\/strong> &#8211; Ignore device files on this filesystem<\/li>\n<li><strong>noatime<\/strong> &#8211; Do not update access times (improves performance)<\/li>\n<li><strong>relatime<\/strong> &#8211; Update atime only if older than mtime (default on most distros)<\/li>\n<li><strong>defaults<\/strong> &#8211; Equivalent to rw, suid, dev, exec, auto, nouser, async<\/li>\n<\/ul>\n\n\n\n<p>Example mounting with multiple options:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mount -o noexec,nosuid,nodev \/dev\/sdb1 \/mnt\/data<\/code><\/pre>\n\n\n\n<p>Remount an already-mounted filesystem with different options (no need to unmount first):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mount -o remount,ro \/mnt\/data<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">UUID vs Device Name<\/h3>\n\n\n\n<p>Device names like <code>\/dev\/sdb1<\/code> can change between reboots if you add or remove disks. The kernel assigns letters based on detection order, so what was <code>\/dev\/sdb<\/code> yesterday could become <code>\/dev\/sdc<\/code> today.<\/p>\n\n\n\n<p>UUIDs solve this problem. Every filesystem gets a unique identifier when it is created, and that UUID never changes unless you reformat. Find the UUID with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo blkid \/dev\/sdb1<\/code><\/pre>\n\n\n\n<p>Mount by UUID:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mount UUID=\"a1b2c3d4-5678-9abc-def0-123456789abc\" \/mnt\/data<\/code><\/pre>\n\n\n\n<p>Always use UUIDs in <code>\/etc\/fstab<\/code> for production systems. This is not just a best practice; it is a reliability requirement.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Persistent Mounts with \/etc\/fstab<\/h3>\n\n\n\n<p>The <code>\/etc\/fstab<\/code> file defines filesystems that should be mounted automatically at boot. Each line has six fields:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># &lt;device\/UUID&gt;                                &lt;mount point&gt;  &lt;type&gt;  &lt;options&gt;       &lt;dump&gt; &lt;fsck order&gt;\nUUID=a1b2c3d4-5678-9abc-def0-123456789abc  \/mnt\/data      ext4    defaults        0      2\nUUID=e5f6a7b8-1234-5678-9abc-def012345678  \/mnt\/backup    xfs     noatime,noexec  0      2\n\/dev\/sdb3                                  \/mnt\/scratch   btrfs   defaults        0      0<\/code><\/pre>\n\n\n\n<p>The six fields explained:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Device<\/strong> &#8211; UUID, device path, or LABEL<\/li>\n<li><strong>Mount point<\/strong> &#8211; Where the filesystem appears in the directory tree<\/li>\n<li><strong>Filesystem type<\/strong> &#8211; ext4, xfs, btrfs, vfat, swap, etc.<\/li>\n<li><strong>Options<\/strong> &#8211; Mount options (defaults, noatime, noexec, etc.)<\/li>\n<li><strong>Dump<\/strong> &#8211; Used by the dump backup utility (0 = skip, 1 = backup). Almost always 0 on modern systems.<\/li>\n<li><strong>Fsck order<\/strong> &#8211; Order for filesystem checks at boot (0 = skip, 1 = root filesystem first, 2 = everything else)<\/li>\n<\/ol>\n\n\n\n<p>After editing fstab, test it before rebooting:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mount -a<\/code><\/pre>\n\n\n\n<p>This mounts everything in fstab that is not already mounted. If there is an error, you will see it immediately instead of discovering it during a reboot when the system drops to emergency mode.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">8. Managing Swap Space<\/h2>\n\n\n\n<p>Swap provides overflow space when physical RAM is full. Linux supports two forms: swap partitions and swap files. The LPIC exam tests both.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Swap Partition<\/h3>\n\n\n\n<p>Create a partition with fdisk or gdisk and set its type to Linux swap (type 82 in fdisk, 8200 in gdisk). Then format and activate it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mkswap \/dev\/sdb5<\/code><\/pre>\n\n\n\n<p>Activate the swap partition:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo swapon \/dev\/sdb5<\/code><\/pre>\n\n\n\n<p>Verify it is active:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>swapon --show<\/code><\/pre>\n\n\n\n<p>Add it to <code>\/etc\/fstab<\/code> for persistence across reboots:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx  none  swap  sw  0  0<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Swap File<\/h3>\n\n\n\n<p>Swap files are more flexible than partitions because you can create and resize them without repartitioning. Create a 2 GiB swap file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo dd if=\/dev\/zero of=\/swapfile bs=1M count=2048<\/code><\/pre>\n\n\n\n<p>Set the correct permissions (swap files must not be world-readable):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo chmod 600 \/swapfile<\/code><\/pre>\n\n\n\n<p>Format and enable:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mkswap \/swapfile\nsudo swapon \/swapfile<\/code><\/pre>\n\n\n\n<p>Add to fstab:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/swapfile  none  swap  sw  0  0<\/code><\/pre>\n\n\n\n<p>To disable swap temporarily (useful before removing a swap file or partition):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo swapoff \/swapfile<\/code><\/pre>\n\n\n\n<p><strong>Swap partition vs swap file:<\/strong> Swap partitions have slightly less overhead because the kernel accesses them directly without going through a filesystem layer. Swap files are easier to manage and resize. For most workloads, the performance difference is negligible. Cloud instances and containers typically use swap files when swap is needed at all.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">9. Logical Volume Management (LVM)<\/h2>\n\n\n\n<p>LVM adds a layer of abstraction between your physical disks and your filesystems. It lets you resize volumes, span multiple disks, and take snapshots without downtime. LVM is covered under LPIC-1 Objective 104.1 and is heavily tested.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">LVM Architecture<\/h3>\n\n\n\n<p>LVM has three layers:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Physical Volumes (PVs)<\/strong> &#8211; Raw partitions or whole disks initialized for LVM<\/li>\n<li><strong>Volume Groups (VGs)<\/strong> &#8211; Pools of storage made from one or more PVs<\/li>\n<li><strong>Logical Volumes (LVs)<\/strong> &#8211; Virtual partitions carved from a VG. These are what you format and mount.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Creating LVM Volumes<\/h3>\n\n\n\n<p>First, mark the partitions as LVM physical volumes. Make sure the partition type is set to 8e (fdisk) or 8e00 (gdisk) beforehand:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo pvcreate \/dev\/sdb1 \/dev\/sdc1<\/code><\/pre>\n\n\n\n<p>Verify your physical volumes:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo pvs<\/code><\/pre>\n\n\n\n<p>Create a volume group from these PVs:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo vgcreate vg_data \/dev\/sdb1 \/dev\/sdc1<\/code><\/pre>\n\n\n\n<p>Check the volume group:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo vgs<\/code><\/pre>\n\n\n\n<p>Create a logical volume. Allocate 50 GiB:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo lvcreate -L 50G -n lv_projects vg_data<\/code><\/pre>\n\n\n\n<p>Or allocate all remaining free space:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo lvcreate -l 100%FREE -n lv_projects vg_data<\/code><\/pre>\n\n\n\n<p>Note the lowercase <code>-l<\/code> for extents\/percentage vs uppercase <code>-L<\/code> for absolute sizes. The logical volume device path will be <code>\/dev\/vg_data\/lv_projects<\/code> (or equivalently <code>\/dev\/mapper\/vg_data-lv_projects<\/code>).<\/p>\n\n\n\n<p>Now format and mount:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mkfs.ext4 \/dev\/vg_data\/lv_projects\nsudo mkdir -p \/mnt\/projects\nsudo mount \/dev\/vg_data\/lv_projects \/mnt\/projects<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Extending LVM Volumes<\/h3>\n\n\n\n<p>This is where LVM really pays off. Extend a logical volume by 20 GiB:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo lvextend -L +20G \/dev\/vg_data\/lv_projects<\/code><\/pre>\n\n\n\n<p>Then grow the filesystem to fill the new space. For ext4:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo resize2fs \/dev\/vg_data\/lv_projects<\/code><\/pre>\n\n\n\n<p>For XFS (which uses a different tool):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo xfs_growfs \/mnt\/projects<\/code><\/pre>\n\n\n\n<p>Note that <code>xfs_growfs<\/code> takes the mount point as its argument, not the device path. You can combine the LV extend and filesystem resize in one command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo lvextend -L +20G --resizefs \/dev\/vg_data\/lv_projects<\/code><\/pre>\n\n\n\n<p>The <code>--resizefs<\/code> flag automatically detects the filesystem type and runs the appropriate resize tool.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Reducing LVM Volumes<\/h3>\n\n\n\n<p>Shrinking is more involved and riskier than growing. You must shrink the filesystem first, then shrink the LV. XFS cannot be shrunk at all.<\/p>\n\n\n\n<p>For ext4, unmount the filesystem first, then run a filesystem check, shrink the filesystem, and finally shrink the LV:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo umount \/mnt\/projects\nsudo e2fsck -f \/dev\/vg_data\/lv_projects\nsudo resize2fs \/dev\/vg_data\/lv_projects 30G\nsudo lvreduce -L 30G \/dev\/vg_data\/lv_projects<\/code><\/pre>\n\n\n\n<p>Always shrink the filesystem to a size equal to or smaller than the target LV size. If you shrink the LV below the filesystem size, you will destroy data.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">LVM Snapshots<\/h3>\n\n\n\n<p>Snapshots capture the state of an LV at a specific moment. They are copy-on-write, so they initially use very little space and grow as the original volume changes.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo lvcreate -s -L 5G -n snap_projects \/dev\/vg_data\/lv_projects<\/code><\/pre>\n\n\n\n<p>The <code>-s<\/code> flag marks this as a snapshot. The 5G is the size of the snapshot space (how much change it can track before it fills up and becomes invalid). Mount the snapshot read-only to access the point-in-time copy:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mount -o ro \/dev\/vg_data\/snap_projects \/mnt\/snapshot<\/code><\/pre>\n\n\n\n<p>Remove a snapshot when you are done with it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo lvremove \/dev\/vg_data\/snap_projects<\/code><\/pre>\n\n\n\n<p>If you need to add more physical storage to a volume group later, add a new PV and extend the VG:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo pvcreate \/dev\/sdd1\nsudo vgextend vg_data \/dev\/sdd1<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">10. Filesystem Maintenance<\/h2>\n\n\n\n<p>Filesystems need occasional maintenance. Corruption happens, performance degrades, and metadata gets stale. The LPIC exam expects you to know the right tool for each filesystem type.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">fsck (Filesystem Check)<\/h3>\n\n\n\n<p><code>fsck<\/code> is the front-end that calls the appropriate checker for each filesystem type. <strong>Never run fsck on a mounted filesystem.<\/strong> Unmount it first, or boot into single-user\/rescue mode.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo umount \/dev\/sdb1\nsudo fsck \/dev\/sdb1<\/code><\/pre>\n\n\n\n<p>For ext4 specifically, you can use <code>e2fsck<\/code> directly. The <code>-f<\/code> flag forces a check even if the filesystem appears clean:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo e2fsck -f \/dev\/sdb1<\/code><\/pre>\n\n\n\n<p>Add <code>-p<\/code> to automatically repair safe problems without prompting:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo e2fsck -fp \/dev\/sdb1<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">tune2fs (ext2\/ext3\/ext4 Tuning)<\/h3>\n\n\n\n<p><code>tune2fs<\/code> adjusts tunable parameters on ext-family filesystems. Common uses:<\/p>\n\n\n\n<p>View current filesystem parameters:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo tune2fs -l \/dev\/sdb1<\/code><\/pre>\n\n\n\n<p>Set a filesystem label:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo tune2fs -L \"data_vol\" \/dev\/sdb1<\/code><\/pre>\n\n\n\n<p>Adjust the reserved block percentage (by default 5% is reserved for root). On a large data volume where root does not need reserved space, reduce it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo tune2fs -m 1 \/dev\/sdb1<\/code><\/pre>\n\n\n\n<p>Set the maximum mount count before a forced fsck:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo tune2fs -c 30 \/dev\/sdb1<\/code><\/pre>\n\n\n\n<p>Set the maximum time interval between filesystem checks:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo tune2fs -i 90d \/dev\/sdb1<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">dumpe2fs (ext Filesystem Info)<\/h3>\n\n\n\n<p><code>dumpe2fs<\/code> dumps detailed information about an ext filesystem, including block group details, superblock locations, and feature flags:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo dumpe2fs \/dev\/sdb1 | head -50<\/code><\/pre>\n\n\n\n<p>For just the superblock info without the block group details, add <code>-h<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo dumpe2fs -h \/dev\/sdb1<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">xfs_repair<\/h3>\n\n\n\n<p>XFS has its own repair tool. Like fsck, it must be run on an unmounted filesystem:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo umount \/mnt\/data\nsudo xfs_repair \/dev\/sdb2<\/code><\/pre>\n\n\n\n<p>If the log is dirty (the filesystem was not cleanly unmounted), xfs_repair will refuse to run. Clear the log first:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo xfs_repair -L \/dev\/sdb2<\/code><\/pre>\n\n\n\n<p>The <code>-L<\/code> flag zeroes out the log. This may cause some data loss for transactions that were in the log, but it lets the repair proceed.<\/p>\n\n\n\n<p>To view XFS filesystem information (similar to dumpe2fs for ext):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo xfs_info \/mnt\/data<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">11. Disk Usage and Block Device Information<\/h2>\n\n\n\n<p>Monitoring disk usage is a daily task for any sysadmin. The LPIC exam covers several tools for this.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">df (Disk Free)<\/h3>\n\n\n\n<p>Show filesystem usage in human-readable format:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>df -hT<\/code><\/pre>\n\n\n\n<p>The <code>-h<\/code> flag gives human-readable sizes (G, M, K). The <code>-T<\/code> flag shows the filesystem type. To check a specific mount point:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>df -hT \/mnt\/data<\/code><\/pre>\n\n\n\n<p>Show inode usage instead of block usage (useful when you are running out of inodes on ext filesystems with lots of tiny files):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>df -i<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">du (Disk Usage)<\/h3>\n\n\n\n<p>While <code>df<\/code> shows overall filesystem usage, <code>du<\/code> tells you which directories are consuming space. Show the total size of a directory:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>du -sh \/var\/log<\/code><\/pre>\n\n\n\n<p>Show subdirectory sizes sorted by size (find the space hogs):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>du -h --max-depth=1 \/var | sort -hr<\/code><\/pre>\n\n\n\n<p>The <code>-s<\/code> flag summarizes (shows total only), and <code>--max-depth<\/code> controls how many levels deep to report.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">lsblk (List Block Devices)<\/h3>\n\n\n\n<p><code>lsblk<\/code> shows all block devices in a tree view:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>lsblk<\/code><\/pre>\n\n\n\n<p>Show additional information like filesystem type, UUID, and size:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>lsblk -f<\/code><\/pre>\n\n\n\n<p>The <code>-f<\/code> output includes the filesystem type, label, UUID, available space, and mount point all in one view. This is often faster than running multiple commands.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">blkid (Block Device Attributes)<\/h3>\n\n\n\n<p><code>blkid<\/code> shows UUID, filesystem type, and labels for block devices:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo blkid<\/code><\/pre>\n\n\n\n<p>Query a specific device:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo blkid \/dev\/sdb1<\/code><\/pre>\n\n\n\n<p>This is the command you will reach for most often when you need a UUID for an fstab entry.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">12. LPIC-1 Exam Objectives Mapped<\/h2>\n\n\n\n<p>Here is how everything in this guide maps to the official LPIC-1 (101-500) exam objectives. Use this as a checklist for your study sessions.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">102.1 &#8211; Design Hard Disk Layout<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Allocating filesystems and swap space to separate partitions or disks<\/li>\n<li>Tailoring the design to the intended use of the system<\/li>\n<li>Ensuring the \/boot partition meets hardware architecture requirements for booting<\/li>\n<li>Knowledge of basic features of LVM<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">104.1 &#8211; Create Partitions and Filesystems<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Manage MBR and GPT partition tables<\/li>\n<li>Use various mkfs commands to create filesystems: ext2, ext3, ext4, XFS, VFAT, exFAT<\/li>\n<li>Basic feature knowledge of Btrfs (including subvolumes and snapshots)<\/li>\n<li>Key tools: fdisk, gdisk, parted, mkfs, mkswap<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">104.2 &#8211; Maintain the Integrity of Filesystems<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Verify the integrity of filesystems<\/li>\n<li>Monitor free space and inodes<\/li>\n<li>Repair simple filesystem problems<\/li>\n<li>Key tools: du, df, fsck, e2fsck, mke2fs, tune2fs, xfs_repair, xfs_fsr, xfs_db<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">104.3 &#8211; Control Mounting and Unmounting of Filesystems<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Manually mount and unmount filesystems<\/li>\n<li>Configure filesystem mounting on bootup<\/li>\n<li>Configure user-mountable, removable filesystems<\/li>\n<li>Use of labels and UUIDs for identifying and mounting filesystems<\/li>\n<li>Knowledge of systemd mount units<\/li>\n<li>Key files: \/etc\/fstab<\/li>\n<li>Key tools: mount, umount, blkid, lsblk<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Quick Reference: Command Cheat Sheet<\/h2>\n\n\n\n<p>Use this table as a fast lookup during your study sessions:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Task<\/th><th>Command<\/th><\/tr><\/thead><tbody><tr><td>List all block devices<\/td><td><code>lsblk -f<\/code><\/td><\/tr><tr><td>Show UUIDs<\/td><td><code>sudo blkid<\/code><\/td><\/tr><tr><td>Partition MBR disk<\/td><td><code>sudo fdisk \/dev\/sdX<\/code><\/td><\/tr><tr><td>Partition GPT disk<\/td><td><code>sudo gdisk \/dev\/sdX<\/code><\/td><\/tr><tr><td>Create ext4 filesystem<\/td><td><code>sudo mkfs.ext4 \/dev\/sdX1<\/code><\/td><\/tr><tr><td>Create XFS filesystem<\/td><td><code>sudo mkfs.xfs \/dev\/sdX1<\/code><\/td><\/tr><tr><td>Mount a filesystem<\/td><td><code>sudo mount \/dev\/sdX1 \/mnt\/point<\/code><\/td><\/tr><tr><td>Check filesystem<\/td><td><code>sudo fsck \/dev\/sdX1<\/code><\/td><\/tr><tr><td>Repair XFS<\/td><td><code>sudo xfs_repair \/dev\/sdX1<\/code><\/td><\/tr><tr><td>Create swap<\/td><td><code>sudo mkswap \/dev\/sdX1<\/code><\/td><\/tr><tr><td>Enable swap<\/td><td><code>sudo swapon \/dev\/sdX1<\/code><\/td><\/tr><tr><td>Create PV<\/td><td><code>sudo pvcreate \/dev\/sdX1<\/code><\/td><\/tr><tr><td>Create VG<\/td><td><code>sudo vgcreate vg_name \/dev\/sdX1<\/code><\/td><\/tr><tr><td>Create LV<\/td><td><code>sudo lvcreate -L 10G -n lv_name vg_name<\/code><\/td><\/tr><tr><td>Extend LV + FS<\/td><td><code>sudo lvextend -L +5G --resizefs \/dev\/vg\/lv<\/code><\/td><\/tr><tr><td>Disk free space<\/td><td><code>df -hT<\/code><\/td><\/tr><tr><td>Directory size<\/td><td><code>du -sh \/path<\/code><\/td><\/tr><tr><td>Tune ext4 params<\/td><td><code>sudo tune2fs -l \/dev\/sdX1<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Final Study Tips<\/h2>\n\n\n\n<p>A few practical pointers from someone who has taught this material to hundreds of exam candidates:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Practice in a VM.<\/strong> Spin up a virtual machine with a few extra virtual disks. Run through every command in this guide at least twice. Muscle memory matters when you have 90 minutes on the clock.<\/li>\n<li><strong>Know which tools go with which filesystem.<\/strong> <code>tune2fs<\/code>, <code>dumpe2fs<\/code>, <code>e2fsck<\/code>, and <code>resize2fs<\/code> are for ext filesystems. <code>xfs_repair<\/code>, <code>xfs_growfs<\/code>, <code>xfs_info<\/code>, and <code>xfs_fsr<\/code> are for XFS. Mixing them up is a common exam trap.<\/li>\n<li><strong>Always use UUIDs in fstab.<\/strong> If an exam question asks about persistent mounting, the answer involves UUIDs or labels, not raw device paths.<\/li>\n<li><strong>Remember the LVM hierarchy.<\/strong> PV goes into VG, VG gets carved into LVs. The commands follow the same naming pattern: <code>pvcreate<\/code>, <code>vgcreate<\/code>, <code>lvcreate<\/code> for creation; <code>pvs<\/code>, <code>vgs<\/code>, <code>lvs<\/code> for listing; <code>pvdisplay<\/code>, <code>vgdisplay<\/code>, <code>lvdisplay<\/code> for detailed info.<\/li>\n<li><strong>XFS cannot shrink.<\/strong> This comes up on the exam. You can grow an XFS filesystem online, but you cannot shrink it. If you need to make it smaller, you must back up, recreate, and restore.<\/li>\n<li><strong>parted writes immediately.<\/strong> Unlike fdisk and gdisk, parted does not have a &#8220;write changes&#8221; step. Every command takes effect the moment you press Enter.<\/li>\n<li><strong>Never fsck a mounted filesystem.<\/strong> This will show up as a wrong answer on the exam and will corrupt your data in real life.<\/li>\n<\/ul>\n\n\n\n<p>Work through these topics methodically, practice each command on real (or virtual) disks, and you will walk into the LPIC-1 exam confident that partition and filesystem questions are free points.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Managing partitions and filesystems is one of the most critical skills tested on the LPIC-1 (101-500) exam. Whether you are setting up a fresh server, expanding storage on a production box, or recovering from a disk failure at 2 AM, you need to know these tools cold. This guide covers every partition and filesystem topic &#8230; <a title=\"LPIC 101 &#8211; Managing Partitions and Filesystems on Linux\" class=\"read-more\" href=\"https:\/\/computingforgeeks.com\/lpic-101-partitions-filesystems-linux\/\" aria-label=\"Read more about LPIC 101 &#8211; Managing Partitions and Filesystems on Linux\">Read more<\/a><\/p>\n","protected":false},"author":3,"featured_media":162773,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[299,47,50,663],"tags":[39414,39533],"class_list":["post-161425","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-how-to","category-linux","category-linux-tutorials","category-storage","tag-filesystems","tag-lpic-101"],"_links":{"self":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/161425","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/comments?post=161425"}],"version-history":[{"count":1,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/161425\/revisions"}],"predecessor-version":[{"id":162770,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/161425\/revisions\/162770"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media\/162773"}],"wp:attachment":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media?parent=161425"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/categories?post=161425"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/tags?post=161425"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}