Table of Contents
Formatting a disk on Ubuntu removes existing data and prepares the storage device with a new filesystem. This process is commonly used when adding new storage volumes to VPS servers or configuring additional disks for applications and backups.
Many administrators format and mount extra storage on Linux VPS servers to expand available disk space and organize server data more efficiently.
Step 1: Connect to the Ubuntu Server
Access the server using SSH:
ssh root@your_server_ip
Step 2: List Available Disks
Display all connected storage devices:
lsblk
Example output:
NAME SIZE TYPE MOUNTPOINT sda 50G disk ├─sda1 49G part / sdb 100G disk
Identify the disk you want to format carefully to avoid data loss.
Step 3: Unmount the Disk (If Mounted)
If the disk already has mounted partitions, unmount them first:
umount /dev/sdb1
Replace sdb1 with the correct partition name.
Step 4: Create a New Partition
Open the disk using fdisk:
fdisk /dev/sdb
Inside fdisk:
n p 1 ENTER ENTER w
This creates a new primary partition and saves the changes.
Step 5: Verify the New Partition
Check the updated partition table:
lsblk
You should now see a partition similar to:
/dev/sdb1
Step 6: Format the Disk with EXT4
Create an EXT4 filesystem:
mkfs.ext4 /dev/sdb1
Ubuntu will format the partition and prepare it for use.
You can also create different filesystems if needed:
mkfs.xfs /dev/sdb1 mkfs.ext3 /dev/sdb1
Step 7: Create a Mount Point
Create a directory for the disk mount:
mkdir /mnt/storage
Step 8: Mount the Disk
Mount the formatted partition:
mount /dev/sdb1 /mnt/storage
Verify the mounted disk:
df -h
Step 9: Mount the Disk Automatically After Reboot
Find the disk UUID:
blkid
Example output:
/dev/sdb1: UUID="xxxx-xxxx"
Open the fstab file:
nano /etc/fstab
Add the following line:
UUID=xxxx-xxxx /mnt/storage ext4 defaults 0 2
Save and exit Nano:
CTRL + X Y ENTER
Test the configuration:
mount -a
If no errors appear, the disk will automatically mount after reboot.
Formatting and mounting disks on Ubuntu 26.04 helps administrators manage storage efficiently and expand VPS server capacity for applications, backups, and large datasets.
