Disk Mounting and Partitioning in Linux

The hard drive installed in the system may not be enough and sometimes the question arises of adding additional media. Consider how to mount a disk on Virtual Private Server (VPS), Virtual (), and Standalone Server.


Before starting work, you should make sure that the disk exists in the system. Sometimes having the device in the BIOS may not be enough. Available drives are checked 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 disk is the system one. We will work with the second disk (sda).

is important to remember that Linux systems can be damaged by incorrectly specifying a drive, such as a system drive. Media selection should be carefully checked and rechecked. The fact that the new disk (out of the box) does not have a file system and partitions comes to the rescue.

Disk layout.

To partition a disk, run the fdisk utility with the path to the disk:

fdisk //sdb

By pressing “” and confirming the input with the Enter key, the program will provide a page of available commands:

Reference: DOS (MBR) a toggle a bootable flag b edit nested BSD disklabel c toggle DOS compatibility flag  General d delete partition 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 partition table i print information about a partition  Miscellaneous m show this menu u change display/input units x additional features (experts only)   I load disk layout from sfdisk script file Dump disk layout to sfdisk script file  Save and exit w save table to disk and exit q exit without saving changes  Create a new label 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 all the , press the “n” key and Enter.
The system will ask about the type of partition – select p (primary) – primary.

Section 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 disks, then in response to the last sector, you should specify the size in kilo-, mega-, giga-, tera-, petabytes. Accordingly, if a partition is needed with a size of 2 gigabytes, then we specify 2G.

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

Disk formatting.

After performing the operation described above, the /dev/sdb1 device will be created in the system – in essence, this is the partition on the disk. Now let’s format.

Modern Linux offers several options for file systems to choose from. The file system is created by executing the mkfs command with the keys specified, or by executing one of the programs:














Formatting is done with the command:

sudo mkfs.ext4 /dev/sdb1

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

Mounting a disk

A feature of the Linux OS is that it is possible to mount a disk (or other block device) to any of the directories, the main thing is that the directory is empty.

Create a directory in the /mnt directory:

sudo mkdir /mnt/1

Change directory permissions. Only root and and only read and write.

sudo chmod -R 660 /mnt/1

Actually, we mount:

sudo mount /dev/sdb1 /mnt/1

To mount the disk automatically at system boot, edit the /etc/fstab file. Open with any text editor, nano:

sudo nano /etc/fstab

Insert the following line at the very end of the file:

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

We save the file.


Welcome to the world of DomainRooster, where roosters (and hens) rule the roost! We're a one-stop shop for all your entrepreneurial needs, bringing together domain names and website hosting, and all the tools you need to bring your ideas to life. With our help, you'll soar to new heights and hatch great success. Think of us as your trusty sidekick, always there to lend a wing and help you navigate the sometimes-complex world of domain names and web hosting. Our team of roosters are experts in their fields and are always on hand to answer any questions and provide guidance. So why wait? Sign up today and join the ranks of the world's greatest entrepreneurs. With DomainRooster, the sky's the limit! And remember, as the saying goes, "Successful people do what unsuccessful people are not willing to do." So don't be afraid to take that leap of faith - DomainRooster is here to help you reach for the stars. Caw on!