Back to all articles
Linux & Servers2026-05-06

How to Manage Disks and Partitions in Linux: Practical Guide

Learn to identify disks, create partitions, format filesystems, and mount volumes safely on Linux servers.

Storage management is one of the most important tasks in Linux server administration. Whether you need to add a new backup volume or expand the disk space of a VPS, knowing the correct commands prevents accidental data loss.

In this article, we present a practical step-by-step guide to managing disks and partitions via the terminal.

1. Identifying Connected Disks

Before making any changes, we need to list the available disks and verify what partitions already exist.

Essential commands:

  • lsblk: Shows the block device tree (disks and partitions) connected and their mount points.
  • df -h: Displays the free and occupied space of all partitions currently mounted in the operating system.

Identify the disk you want to manipulate. Generally, SATA/Virtual disks appear as /dev/sdb, /dev/sdc, or /dev/vdb (in VPS environments).

2. Creating a Partition with fdisk

The fdisk utility is the classic tool for partition table manipulation.

The process:

  1. Access the disk using superuser privileges:
    sudo fdisk /dev/sdb
  2. Check the label with sudo fdisk -l /dev/sdb. Disklabel type: gpt is the usual case on a VPS. dos is MBR.
  3. Type n to create a new partition. On MBR, p selects primary. GPT does not ask that: confirm the number (usually 1) and the first and last sectors with Enter to use the whole disk.
  4. Type w to write and exit. fdisk is interactive. Do not paste it in the same block as mkfs: the shell waits for the prompts and the later commands never reach the partition table.

3. Formatting the Filesystem

Creating the partition is not enough; you must format it so the system can read and write files. The most common and stable default filesystem in Linux is ext4.

How to format:

Run the mkfs command pointing to the created partition (and not to the entire disk): sudo mkfs.ext4 /dev/sdb1

4. Mounting the Partition (mount and fstab)

To start using the partition, we need to connect it to a folder in the system (mount point).

Temporary mount:

sudo mkdir /mnt/data sudo mount /dev/sdb1 /mnt/data

Persistent mount (after reboots):

If the server is restarted, the temporary mount will be lost. To make it permanent, add the entry in the /etc/fstab file:

  1. Get the unique identifier (UUID) of the disk partition:
    sudo blkid /dev/sdb1
  2. Open the /etc/fstab file with a text editor (like nano or vi):
    sudo nano /etc/fstab
  3. Add the line at the end of the file:
    UUID=your-uuid-here /mnt/data ext4 defaults 0 2

5. The full sequence, with a read-only check first

mkfs erases the partition's contents. The first command only reads. If /dev/sdb shows a mountpoint, stop.

lsblk -o NAME,SIZE,FSTYPE,MOUNTPOINT
df -h
sudo fdisk -l /dev/sdb

New partition, filesystem, and mount. On GPT, the fdisk prompts are n, Enter (number), Enter (first sector), Enter (last sector), w. On MBR, p comes after n, and only then the number. Exit with w before the commands below. This block is safe to paste:

sudo mkfs.ext4 /dev/sdb1
sudo mkdir -p /mnt/data
sudo mount /dev/sdb1 /mnt/data
sudo blkid /dev/sdb1

Copy the UUID that blkid printed into /etc/fstab. The last field 2 asks for a filesystem check at boot, after the root filesystem:

UUID=paste-the-uuid-here /mnt/data ext4 defaults 0 2
sudo findmnt --verify
df -h /mnt/data

findmnt --verify reads fstab without mounting again. An error here is the boot that would drop into emergency mode. The system disk, usually /dev/sda or /dev/vda, stays out of this sequence.

When the partition does not mount

  • sudo findmnt --verify points at the fstab line with the wrong UUID. Copy the blkid /dev/sdb1 output again, without quotes.
  • lsblk with no sdb1 means fdisk never wrote the table, or the disk was a different one. Do not run mkfs again.
  • sudo dmesg | tail after the mount shows wrong fs type when mkfs.ext4 did not run on that partition.

Conclusion

Managing disks in Linux requires attention to detail, especially in typing device names correctly. Mastering these steps ensures complete flexibility to manage the growth of databases and media of your enterprise applications.

Common questions

What does sudo fdisk -l do?

sudo fdisk -l lists every disk and its partition table. It only reads the layout. It does not create, delete, or format partitions.

How do I list disks in Linux before using fdisk?

Run lsblk to see disks and mount points, and df -h for used space. Confirm the device name, such as /dev/sdb, before any command that writes to the disk.

Managed KVM VPS

ExpertCore provisions and runs the VPS: isolated KVM, backups, and engineering support.

See VPS plans