ESC

Start typing to search across invoices, services, domains, tickets, and more...

Search... Ctrl+K
Linux Server

How to Partition, Format and Mount a Data Disk on Linux (Auto-Mount at Boot)

6 steps 11 min read 221 views 0
On this page

A newly added disk does not show up as a usable folder on Linux until you partition, format and mount it. This guide walks through mounting a data disk on Linux end to end: identifying it with lsblk, partitioning with fdisk or parted, formatting with mkfs.ext4 or mkfs.xfs, and finally adding it to /etc/fstab by UUID so it mounts automatically at boot. The commands work on Debian, Ubuntu, CentOS, Rocky Linux and AlmaLinux and should be run as root.

Partitioning and formatting erase everything on the disk. Double-check the device name before you start, never run these commands against the system disk (usually vda or sda), and back up any disk that already holds data.

Step 1: Find the Data Disk with lsblk

Run lsblk to list all block devices. A disk with no partitions and no mount point is your new data disk. On KVM cloud servers it is usually vdb, on dedicated servers often sdb, and NVMe drives appear as nvme1n1. The examples use /dev/vdb; replace it with your actual device.

lsblk
# Example output
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
vda    253:0    0   40G  0 disk
└─vda1 253:1    0   40G  0 part /
vdb    253:16   0  200G  0 disk

Step 2: Partition the Data Disk (fdisk or parted)

For disks under 2 TB you can create an MBR partition with fdisk by answering the prompts:

fdisk /dev/vdb
# Inside fdisk type:
#   n      new partition
#   p      primary
#   1      partition number
#   Enter  accept default first sector
#   Enter  accept default last sector (use the whole disk)
#   w      write changes and exit

Disks larger than 2 TB require a GPT partition table. parted does it in one command, and "0% 100%" keeps the partition properly aligned:

# GPT partition table, one partition using the whole disk (required for disks > 2 TB)
parted -s /dev/vdb mklabel gpt mkpart primary 0% 100%
partprobe /dev/vdb
lsblk /dev/vdb

Step 3: Format the Disk as ext4 or XFS

ext4 offers the widest compatibility and can be grown online or shrunk offline. XFS performs consistently with large files and large volumes but cannot be shrunk. Either is fine; if you have no special needs, stick with your distribution's default.

# Option A: ext4 (default on Debian / Ubuntu)
mkfs.ext4 /dev/vdb1

# Option B: XFS (default on CentOS / Rocky / AlmaLinux)
mkfs.xfs /dev/vdb1

# Install XFS tools if mkfs.xfs is missing
apt install -y xfsprogs        # Debian / Ubuntu
dnf install -y xfsprogs        # CentOS / Rocky / AlmaLinux

Step 4: Create a Mount Point and Mount the Disk

Create a directory such as /data, mount the partition on it and confirm the size and filesystem type with df -hT. This mount only lasts until the next reboot.

mkdir -p /data
mount /dev/vdb1 /data
df -hT /data

Step 5: Auto-Mount at Boot with UUID in /etc/fstab

Device names like vdb1 can change when disks are added or removed, so use the UUID in fstab. Look it up with blkid, back up fstab and append a line. The nofail option lets the system boot normally even if the data disk has a problem instead of dropping to emergency mode. If you formatted with XFS, write xfs instead of ext4.

blkid /dev/vdb1
# /dev/vdb1: UUID="3f1c2a9e-5b7d-4c11-9a0e-2d6f8b1e4c55" TYPE="ext4" ...

cp /etc/fstab /etc/fstab.bak
echo 'UUID=3f1c2a9e-5b7d-4c11-9a0e-2d6f8b1e4c55  /data  ext4  defaults,nofail  0  2' >> /etc/fstab

Step 6: Verify the fstab Entry

Unmount the disk and remount everything from fstab with mount -a. If there are no errors and /data appears in df, the entry is correct and will survive a reboot. If you get an error, fix the line or restore /etc/fstab.bak right away — never reboot with a broken fstab.

umount /data
systemctl daemon-reload
mount -a
df -hT /data

FAQ

lsblk does not show the new disk.

Some systems need a reboot or a bus rescan before a newly attached cloud disk appears, so try rebooting first. On dedicated servers, check whether the drive has been configured as a logical volume on the RAID controller. If it still does not appear, open a ticket so we can verify the disk allocation.

A wrong fstab line stops the server from booting.

Open the VNC console from the client area, enter the root password at the maintenance prompt, run mount -o remount,rw /, then edit /etc/fstab to comment out or fix the bad line and reboot.

Can I format the whole disk without a partition?

Technically you can run mkfs directly on /dev/vdb, but keeping a partition table helps other tools recognise the disk and reduces the risk of mistakes. If you expect to grow storage later, consider LVM.

Still stuck after following these steps? Open a support ticket and the IMIDC 24/7 technical team will help. Please include the server IP, operating system, the commands you ran and a screenshot of the error so we can pinpoint the issue faster.

Was this answer helpful?

Related Tutorials