Explore plans starting at ₹699/mo →
Linux & System Administration

Linux Disk Management: LVM, fstab, and Mount Strategies for Cloud Servers

S
ServerRaja
10 min read
#Linux#SSD#NVMe#VPS#Storage#Guide#Performance#System Administration
Linux Disk Management: LVM, fstab, and Mount Strategies for Cloud Servers

Effective disk management is critical for any cloud server. Running out of space, choosing the wrong filesystem, or misconfiguring mount options can bring your applications down. On ServerRaja's NVMe SSD-powered cloud infrastructure, understanding Linux storage management ensures you extract maximum performance and reliability. This guide covers partitioning, LVM, fstab configuration, and performance optimization.

Identifying Disks and Partitions

Before making changes, understand your current storage layout:

# List all block devices with filesystem and size info
lsblk -f

# Detailed partition table fdisk -l

# Check disk usage by filesystem df -hT

# Check inode usage (can also cause "no space" errors) df -i

# View disk information and health smartctl -a /dev/sda hdparm -I /dev/sda ```

On a ServerRaja Cloud VPS, you typically see `/dev/vda` (virtual disk) or `/dev/sda` (for dedicated servers with physical drives). NVMe drives appear as `/dev/nvme0n1`.

Partitioning Disks

When you attach additional storage volumes to your ServerRaja server, you need to partition them:

# Create a new GPT partition table and partition
parted /dev/sdb
(parted) mklabel gpt
(parted) mkpart primary ext4 0% 100%
(parted) print
(parted) quit

# Or use fdisk for MBR-style partitions fdisk /dev/sdb # Press: n (new), p (primary), 1 (partition number), Enter, Enter, w (write)

# Create filesystem mkfs.ext4 /dev/sdb1 # Or for XFS (better for large files) mkfs.xfs /dev/sdb1 ```

Mounting Filesystems

Mount makes a filesystem accessible at a directory path:

# Create mount point
mkdir -p /data

# Mount the partition mount /dev/sdb1 /data

# Verify mount | grep /data lsblk ```

Persistent Mounts with fstab

Mounts created with the `mount` command disappear after reboot. For persistent mounts, edit `/etc/fstab`:

# Get the UUID of the partition (preferred over device names)
blkid /dev/sdb1

# Edit fstab nano /etc/fstab ```

Add an entry:

# <filesystem>              <mount>  <type>  <options>              <dump> <pass>
UUID=abc123-def4-5678       /data    ext4    defaults,noatime       0      2

**Critical**: Always test fstab changes before rebooting:

# Test all fstab entries without rebooting
mount -a

# If this produces no errors, your fstab is correct # If it fails, fix the entry BEFORE rebooting or you may not be able to boot ```

Logical Volume Manager (LVM)

LVM adds a flexible abstraction layer between physical disks and filesystems. It is especially valuable on cloud servers where you might need to expand storage without downtime.

LVM Concepts

  • **Physical Volume (PV)**: Actual disk or partition
  • **Volume Group (VG)**: Pool of storage from one or more PVs
  • **Logical Volume (LV)**: Virtual partition carved from a VG, what you format and mount

Setting Up LVM

# Step 1: Create physical volumes
pvcreate /dev/sdb1
pvcreate /dev/sdc1

# Verify pvs pvdisplay

# Step 2: Create a volume group vgcreate data-vg /dev/sdb1 /dev/sdc1

# Verify vgs vgdisplay

# Step 3: Create logical volumes lvcreate -L 100G -n app-lv data-vg lvcreate -L 50G -n db-lv data-vg

# Or use percentage of free space lvcreate -l 50%FREE -n logs-lv data-vg

# Verify lvs lvdisplay ```

Format and Mount LVM Volumes

# Format
mkfs.ext4 /dev/data-vg/app-lv
mkfs.ext4 /dev/data-vg/db-lv

# Create mount points mkdir -p /var/www/app mkdir -p /var/lib/mysql

# Mount mount /dev/data-vg/app-lv /var/www/app mount /dev/data-vg/db-lv /var/lib/mysql

# Add to fstab using device mapper path or UUID blkid /dev/data-vg/app-lv # Add UUID to /etc/fstab ```

Extending LVM Volumes (Online)

One of LVM's greatest strengths is online expansion. Grow your storage without unmounting or downtime:

# Extend the logical volume by 50GB
lvextend -L +50G /dev/data-vg/app-lv

# Resize the filesystem to fill the new space resize2fs /dev/data-vg/app-lv

# Or for XFS filesystems xfs_growfs /var/www/app

# Extend using all free space in the VG lvextend -l +100%FREE /dev/data-vg/app-lv resize2fs /dev/data-vg/app-lv ```

Adding a New Disk to an Existing VG

When your ServerRaja volume fills up, attach a new disk and add it to the existing volume group:

# Partition and prepare the new disk
pvcreate /dev/sdd1

# Add to existing volume group vgextend data-vg /dev/sdd1

# Now extend your logical volume lvextend -l +100%FREE /dev/data-vg/app-lv resize2fs /dev/data-vg/app-lv ```

Mount Options for Performance

Choosing the right mount options significantly impacts performance on ServerRaja NVMe SSD storage:

# High-performance options for ext4 on SSD
UUID=xxx  /data  ext4  defaults,noatime,nodiratime,discard  0  2

# Breakdown: # noatime - Don't update access timestamps (reduces writes) # nodiratime - Don't update directory access timestamps # discard - Enable TRIM for SSD longevity and performance ```

For database volumes, consider adding `data=writeback` for ext4 (improves write performance but slightly less crash safety — use with UPS/battery-backed controllers or when the database has its own journaling).

Monitoring Disk Health

# Real-time disk I/O monitoring
iostat -xz 1

# SMART health check (dedicated servers) smartctl -H /dev/sda

# Find largest directories eating space du -sh /* 2>/dev/null | sort -rh | head -10 du -sh /var/* | sort -rh | head -10

# Find deleted files still held open (still using space) lsof | grep deleted ```

Proper disk management ensures your ServerRaja cloud server runs reliably with optimal storage performance. LVM gives you the flexibility to grow, and correct fstab configuration ensures everything mounts correctly on every boot.

Key Takeaways

  • **Use LVM for any production server** — it lets you extend volumes online without downtime, which is critical when disk space runs out unexpectedly.
  • **Always reference disks by UUID in `/etc/fstab`** — device names like `/dev/sdb` can change across reboots, but UUIDs are stable and prevent boot failures.
  • **Test fstab entries with `mount -a` before rebooting** — a broken fstab entry can prevent your server from booting entirely.
  • **Mount SSD volumes with `noatime,nodiratime,discard`** to reduce unnecessary writes and maintain SSD performance over time.
  • **Monitor disk usage proactively** with `du`, `iostat`, and `lsof | grep deleted` — deleted files held open by running processes silently consume space until the process restarts.
Linux Disk Management & LVM Guide | ServerRaja