Linux

Disk Management in Linux: A Complete Guide to Partitioning and Mounting

This guide will help you master basic disk management operations in Linux: from viewing current partitions to formatting and permanently mounting partitions. You will gain practical skills for storage administration.

Updated at February 16, 2026
15-30 min
Easy
FixPedia Team
Применимо к:Ubuntu 22.04+Debian 11+CentOS 8+systemd-based distributions

Introduction / Why This Is Needed

Disk management is one of the key tasks for a Linux system administrator. Without proper partitioning, formatting, and mounting, you won't be able to use new disks or redistribute space. This guide will walk you through all the basic steps: from viewing existing disks to setting up permanent mounting. After completing it, you'll be able to confidently work with block devices in Linux.

Requirements / Preparation

Before you begin, ensure that:

  1. You have access to a Linux terminal (Ubuntu, Debian, CentOS, or another systemd-based distribution).
  2. You have superuser (sudo) privileges to perform disk operations.
  3. Basic utilities are installed: fdisk (usually in the util-linux package), lsblk, e2fsprogs (for ext4). They are present by default in most distributions.
  4. Critically important: If the target disk contains important data, back it up. Partitioning operations are irreversible.

Step 1: Viewing Current Disks and Partitions

First, determine which disks and partitions already exist in the system. Use two main commands:

lsblk

This command outputs a tree of all block devices (disks, partitions) in a convenient format. Pay attention to the columns: NAME (device name, e.g., sda1), SIZE (size), MOUNTPOINT (mount point, if the partition is already mounted).

sudo fdisk -l

More detailed information. Shows partition tables for each disk, partition type, start/end. Requires sudo to read all devices.

Example lsblk output:

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0   100G  0 disk 
├─sda1   8:1    0   512M  0 part /boot/efi
└─sda2   8:2    0  99.5G  0 part /
sdb      8:16   0   20G   0 disk 

Here we see two disks (sda and sdb). sdb has no partitions and is not mounted—a candidate for work.

Step 2: Creating a New Partition on the Disk

Let's say we want to create a single partition using the entire disk sdb. Use fdisk (interactive) or parted (more modern). For simplicity and broad support, we'll use fdisk.

sudo fdisk /dev/sdb

You'll enter interactive mode. Type the following commands (each on a separate line, confirming with Enter):

  1. n — create a new partition.
  2. p — partition type (primary).
  3. 1 — partition number (first).
  4. Press Enter twice to accept defaults (start and end of the disk).
  5. w — write changes and exit.

⚠️ Important: If the disk already has partitions, fdisk may ask you to delete them first (d). Be careful—this will destroy data.

Check the result:

lsblk /dev/sdb

Now you should see sdb1.

Step 3: Formatting the Partition to a Filesystem

The created partition sdb1 is still empty—it needs to be formatted. The choice of filesystem depends on your needs:

  • ext4 — the most common, reliable, suitable for most tasks.
  • xfs — efficient for very large disks and files, often used on servers.
  • btrfs — modern, with snapshot and compression support.

For a general case, use ext4:

sudo mkfs.ext4 /dev/sdb1

The process will take a few seconds. The mkfs command is a frontend for specific utilities (mkfs.ext4).

💡 Tip: To find the partition's UUID (a unique identifier that doesn't change upon reconnection), run sudo blkid after formatting. You'll need it for /etc/fstab.

Step 4: Mounting the Partition Manually

Now the partition is ready for use. Create a directory that will be the mount point:

sudo mkdir -p /mnt/mydata

Mount the partition:

sudo mount /dev/sdb1 /mnt/mydata

Check:

df -h

You should see /dev/sdb1 in the list with the mount point /mnt/mydata. The partition is available for read/write.

⚠️ Important: This is a temporary mount. After a reboot, the partition will not mount automatically. For permanent mounting, proceed to the next step.

Step 5: Setting Up Automatic Mounting via /etc/fstab

The /etc/fstab file (file systems table) contains information about all permanent filesystems. Add a line for our partition there.

Open the file in an editor (e.g., sudo nano /etc/fstab) and add this line at the end:

UUID=your-partition-uuid /mnt/mydata ext4 defaults 0 2

How to get the UUID? Run sudo blkid and copy the value for /dev/sdb1 (e.g., UUID="a1b2c3d4-...").

Field explanation:

  1. UUID=... — the partition's unique identifier (more reliable than /dev/sdb1, since device names can change).
  2. /mnt/mydata — the mount point (must exist).
  3. ext4 — filesystem type.
  4. defaults — standard options (rw,suid,dev,exec,auto,nouser,async).
  5. 0 — do not dump (for dump, usually 0).
  6. 2 — filesystem check order at boot (1 for root /, 2 for others).

Check fstab correctness without risk:

sudo mount -a

If there are no errors, the configuration is correct. The partition will mount automatically on every boot.

Verifying the Result

  1. Ensure the partition is mounted: mount | grep mydata or df -h.
  2. Try creating a file: sudo touch /mnt/mydata/test.txt.
  3. Reboot the system (sudo reboot), and after booting, check that the partition is mounted again (df -h).

Possible Issues

  • Error "mount: /mnt/mydata: special device /dev/sdb1 does not exist." — The partition was not created or an incorrect device name is specified. Check lsblk.
  • Error "wrong fs type, bad option, bad superblock" — The filesystem does not match what's specified in fstab or the partition is not formatted. Ensure the type in fstab (ext4) matches the actual one (sudo blkid).
  • Partition does not mount after boot — Check /etc/fstab syntax (spaces/tabs), existence of the mount point, and that the auto option is present in defaults.
  • Access error when mounting without sudo — In fstab, for a partition that should be mountable by a regular user, add the user option instead of defaults (but this reduces security).

F.A.Q.

Is it safe to use fdisk on an important disk?
How to make a disk mount automatically at boot?
What is the difference between ext4, xfs, and btrfs?
What to do if the mount command returns 'Permission denied'?

Hints

View current disks and partitions
Select disk and create new partition
Format partition
Create mount point and mount
Configure automatic mounting via fstab
FixPedia

Free encyclopedia for fixing errors. Step-by-step guides for Windows, Linux, macOS and more.

© 2026 FixPedia. All materials are available for free.

Made with for the community