Steps to Add New Disk to Ubuntu Server

How to Add New Disk to Ubuntu Server?

Adding a new disk to an Ubuntu Server involves several steps, including formatting, partitioning, and mounting the disk.

This process ensures that the disk is ready for use and can be accessed for storing data.

Whether you are expanding storage capacity or setting up a new drive, follow this guide to review all the required steps to add new disk to Ubuntu Server.

Ubuntu Server disk setup tutorial comes with two below methods:

  • Command-line: Identifying the disk with fdisk, creating partitions, formatting with mkfs, and mounting it to a directory.
  • GUI: Use the “Disks” utility to format and partition the disk with a graphical interface. This method involves opening the utility, formatting the disk, and creating partitions through on-screen options.

Prerequisites to Add New Disk to Linux Ubuntu Server

Before you jump in, ensure your PC meets the following:

  • A Linux VPS running Ubuntu.
  • A non-root user with sudo privileges.
  • Access to Command line/Terminal.

Method 1: Using Command Line to Add New Disk to Ubuntu

Let’s go through the steps of this guide to learn how to format the disk in Ubuntu and mount it to add new disk.

Step 1: Format and Partition a Disk

First, identify the new disk you want to format. Open a terminal and run the following command:

sudo fdisk -l

This command lists all disks and partitions. Locate your new disk, which should be listed as /dev/sdX, where X is a letter assigned to your disk.

Step 2: Create a New Partition

To create a new partition, use the fdisk utility:

sudo fdisk /dev/sdX

Step 3: Working with fdisk utility

The fdisk utility does different functions. Use the commands below to:

  • Create a new partition: Press n
  • Create a primary partition: Press p
  • Partition number, first sector, and last sector:
    Partition number (1-4, default 1): 
    First sector (2048-104857599, default 2048): 
    Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-104857599, default 104857599):
  • Write the changes to the disk: Press w.

Step 4. Format the Disk

Once the partitioning is done, format the new partition with a file system. For instance, using ext4:

sudo mkfs -t ext4 /dev/sdX1

Replace /dev/sdX1 with your partition’s actual path.

Step 5: Mount the Disk

To mount the new disk, you need to create a directory:

sudo mkdir -p /media/disk

Run the command below to mount the partition:

sudo mount /dev/sdX1 /media/disk

You can now access your disk at /media/disk.

To ensure the disk mounts automatically at boot, add it to the /etc/fstab file.

Method 2: Add New Disk to Ubuntu Server via GUI

This method explains Using GUI to add a new disk Ubuntu. To format and partition a Disk using GUI, follow the below steps:

Step 1: Open Disk Utility

In Ubuntu, open the “Disks” utility from the application launcher.

Open Disk Utility

Step 2: Format the Disk

To pass this step:

  • Select the new disk from the list.

Select the new disk

  • Click on the gear icon and choose “Format Disk.”

Format Disk

  • You can select a quick format or securely erase the disk.

Earase and Partition New Disk

  • Follow the prompts to complete the formatting.

Final format

Step 3: Create a Partition

After formatting, create a partition if necessary.

The GUI will guide you through partitioning options. Choose the file system and apply the changes.

How to Identify new disk on Ubuntu?

To identify your new disk on Ubuntu, run the command below to list all disks and partitions:

sudo fdisk -l

Then, look for the new disk, usually listed as /dev/sdX.

What file system should I use when formatting a new disk?

For most purposes, ext4 is a good choice due to its balance of performance and reliability. Other options include xfs and btrfs, depending on your needs.

How to partition a new disk using fdisk?

  • Start fdisk with sudo fdisk /dev/sdX.
  • Use n to create a new partition.
  • p for a primary partition.
  • w to write changes.

How to ensure that my new disk mounts automatically on boot?

Edit the /etc/fstab file to include an entry for your new disk, specifying the mount point and file system type.

Why new disk is not showing up?

  • Check connections and ensure the disk is properly connected.
  • Use dmesg | grep sd to view kernel messages related to disk detection.

Why disk is not automatically mounting after reboot?

To troubleshoot it, ensure the /etc/fstab entry is correctly formatted. Common issues include incorrect UUID or file system type.

Conclusion

In this tutorial, we covered two different methods to Add New Disk to Ubuntu Server.

Adding a new disk to an Ubuntu Server can be accomplished efficiently through either command-line or GUI methods.

The command-line approach offers more control and is universally applicable across various Linux distributions, while the GUI method provides a more user-friendly experience.

Both methods ultimately achieve the same result, a new disk formatted, partitioned, and mounted for use.

Choose the method that best fits your comfort level and needs to expand your server’s storage capabilities.

Leave a Reply

Your email address will not be published. Required fields are marked.