# How to mount disk

Remember that to execute the commands you must be logged in as the root user or use the sudo command.

# Step 1: Verify

First, we are going to check which disk we need to mount. Run the following command:

sudo fdisk -l

Usually we need to mount the one with largest storage. You can also identify the disk that needs to be mounted because it will not have any partitions. It will probably be /dev/sda or /dev/sdb

⚠️ Important: The entire guide assumes you want to mount /dev/sda. If that is not your case, replace it with /dev/sdb or the disk you want to mount

# Step 2: Partition disk

Now we will proceed to prepare it so that it can be used, for this we will start by partitioning the new disk.

To start with partitioning, run:

sudo fdisk /dev/sda

Now it will ask you a couple questions. Answer this:

  • Step 1: n (new partition)
  • Step 2: p (primary)
  • Step 3: 1 (only one partition)
  • Step 4: ENTER (default value)
  • Step 5: ENTER (default value)
  • Step 6: w (wirte to save)

# Step 3: Verify

To verify that the process has been executed correctly, you can write the following command again in the console:

sudo fdisk -l

You should now see the disk with 1 partition. This partition can be named /dev/sda1 or /dev/sdb1, depending on the disk you used

# Step 4: Format disk

Once the disk is partitioned, it must be formatted (we are going to use the ext4 file system)

To format the disk with the ext4 extension, execute the following command:

sudo mkfs.ext4 /dev/sda1

# Step 5: Mount disk

To start we have to create a new directory that will be the location where we will mount the disk (/disk)

sudo mkdir /disk

To mount a disk we must execute the following command:

sudo mount /dev/sda1 /disk

When executing the previous command the new disk will be mounted and ready to be used, you can check it by executing the following command:

sudo df -h

# Step 6: Mount disk permanent

In order for the new disk that we have added to be mounted permanently, you must edit the fstab file adding the location of the new disk. To achieve this, run the commands below:

sudo nano /etc/fstab

Add the following line at the bottom of the file

/dev/sda1          /disk               ext4               defaults             0 0

To exit and save press CTRL+X, then Y and finally ENTER

# CONGRATULATIONS

Congratulations! Now you have a large drive or disk at /disk. We recommend you to store most of the files, especially the largest ones, there.

Keep in mind that the entire guide is made assuming that the disk we want to mount is in the path /dev/sda, if this is not your case you just have to change that path to yours (or open a ticket and we will help you)