News
Happy System Administrator Appreciation Day - to the true heroes of IT!
Serverspace Black Friday
MA
May 18 2020
Updated August 4 2025

How to Mount a Disk and Create Partitions in Linux VPS, VDS, and Dedicated Servers

Linux VPS

Using another OS?

Select the desired version or distribution.

The hard disk installed in the system may not be enough and sometimes the question arises of adding additional media. Let's look at how to mount a disk on a Virtual Private Server (VPS), Virtual Dedicated Server (VDS), and Standalone Server.

Preparation

Before you start working, make sure that the disk exists in the system. Sometimes the presence of a device in the BIOS may not be sufficient. Check the available drives with the command:

sudo fdisk -l

In our case, there are 2 disks in the system - sda and sdb, both 10 GB each, the first system disk. We will work with the second disk (sda).

It is important to remember that Linux systems can be damaged by incorrectly specifying a drive, such as a system one. Carefully check and double-check media selection. The fact that the new disk (out of the box) does not have a file system or partitions helps.

Disk marking

To mark the disk, run the fdisk utility with the path to the disk:

fdisk /dev/sdb

When you press “m” and confirm the entry with Enter, the program will provide a page of available commands:

Reference:

DOS (MBR)

a toggle a bootable flag

b edit nested BSD disklabel

c switch the DOS compatibility flag

General

d delete a section

F list free unpartitioned space

l list of known partition types

n add a new section

p show partition table

t change partition type

v check the partition table

i print information about the partition

Miscellaneous

m show this menu

u change display/input units

x additional features (only for experts)

Script

I load disk layout from sfdisk script file

O dump disk layout to sfdisk script file

Save and exit

w save the table to disk and exit

q exit without saving changes

Create a new tag

g create a new empty GPT partition table

G create a new empty SGI partition table (IRIX)

o create a new empty DOS partition table

s create a new empty Sun partition table

Since we will create a simple partition (not bootable), we will use the entire disk space, press the “n” key and Enter.
The system will ask about the type of partition - select p - primary.

The partition number — 1

We answer the question about the first and last sector by pressing the Enter key.

Important! If you want to create several logical drives, then in response to the last sector you should specify the size in kilo-, mega-, giga-, tera-, petabytes. Accordingly, if the partition needs a size of 2 gigabytes, then specify 2G.

Save the changes by pressing “w” and confirm the selection with the Enter key.

Formatting a disk

After the operation described above, the device /dev/sdb1 will be created in the system - in essence, this is a partition on the disk. Now formatting.

Modern Linux offers a choice of several file system options. The file system is created by executing the mkfs command with the keys specified, or by running one of the programs:

mkfs.bfs
mkfs.btrfs
mkfs.cramfs
mkfs.ext2
mkfs.ext3
mkfs.ext4
mkfs.ext4dev
mkfs.fat
mkfs.minix
mkfs.msdos
mkfs.ntfs
mkfs.vfat
mkfs.xfs

Formatting is performed by the command:

sudo mkfs.ext4 /dev/sdb1

The disk is ready to work. It remains only to mount it.

Mounting a disk

The peculiarity of the Linux OS is that it is possible to mount a disk (or another block device) in any of the directories, the main thing is that the directory is empty.

Create a directory in the /mnt directory:

sudo mkdir /mnt/1

We change the access rights to the directory. Only root and only read and write.

sudo chmod -R 660 /mnt/1

We mount:

sudo mount /dev/sdb1 /mnt/1

To mount the disk automatically when the system boots, edit the /etc/fstab file. Open with any text editor, for example, nano:

sudo nano /etc/fstab

At the very end of the file, insert the line:

/dev/sdb1 /mnt/1 ext4 defaults 0 0

Save the file.

Conclusion

Mounting a disk and creating partitions in Linux is a fundamental skill for managing server storage on VPS, VDS, or dedicated environments. This guide walked you through checking available disks, partitioning with fdisk, formatting with mkfs, and mounting the disk both manually and automatically at boot using /etc/fstab. By following these steps carefully, you can safely extend your server’s storage and ensure it’s ready for stable operation. Always double-check device names to avoid overwriting critical system data.

FAQ

  • Q1: How can I check which disks are available on my Linux server?
    A: Use the command sudo fdisk -l to list all connected disks and partitions.
  • Q2: What is the difference between /dev/sda and /dev/sdb?
    A: These represent physical disks. /dev/sda is usually the first (and often system) disk, while /dev/sdb is typically the second disk or an added volume.
  • Q3: What file system should I use when formatting a new partition?
    A: ext4 is the most common and stable file system for Linux. However, you can choose others like xfs, btrfs, or ntfs depending on your use case.
  • Q4: Why do I need to add the disk to /etc/fstab?
    A: Editing /etc/fstab ensures that your new partition is mounted automatically each time the system reboots.
  • Q5: Can I mount a disk to any directory?
    A: Yes, in Linux you can mount a disk to any empty directory, but it’s common to use locations like /mnt or /media for organization.
  • Q6: Is it safe to perform these actions on a running production server?
    A: It’s safe if you are careful to not modify the system disk or partitions currently in use. Always verify the disk name (e.g., /dev/sdb) before proceeding.
Vote:
5 out of 5
Аverage rating : 5
Rated by: 1
33145 North Miami, FL 2520 Coral Way apt 2-135
+1 302 425-97-76
700 300
ITGLOBAL.COM CORP
700 300

You might also like...

We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.