Let's understand Disks and create partitions in the Ubuntu 22.04 LTS server.

Manikanta Suru
3 min readFeb 28, 2023
  1. Connect the new disk to your server. If you are using a virtual machine, you may need to add a new virtual disk to the VM.

2. Once the disk is connected, check that Ubuntu recognizes it by running the command sudo fdisk -l. You should see the new disk listed, along with any other disks that are already connected to your server.

Use the LSBLK command to list all of the available block devices and their mount points.

3. Use the fdisk command to partition the new disk. For example, if your new disk is located at /dev/sdb, run the following command:

sudo fdisk /dev/sdb

4) This will open the fdisk tool. From here, you can create partitions by following the on-screen instructions. When you’re finished, save your changes and exit fdisk.

5) Format the new partition with a file system of your choice. For example, if you want to use the Ext4 file system, run the following command:

sudo mkfs.ext4 /dev/sdb1

sudo mkfs.ext4 /dev/sdb2

sudo mkfs.ext4 /dev/sdb3

6) This will create an Ext4 file system on the first partition of your new disk.

7) Create a mount point for the new partition. For example, if you want to mount the new partition at /mnt/newdisk, run the following command: sudo mkdir /mnt/newdisk

8) Mount the new partition to the mount point you just created. For example, to mount the first partition of the new disk to /mnt/newdisk, run the following command.

9) To make the mount permanent across reboots, add an entry to the /etc/fstab file. For example, add the following line to the /etc/fstab file to mount the new partition at boot time:

/dev/sdb1 /mnt/newdisk ext4 defaults 0 2

/dev/sdb2 /mnt/newdisk ext4 defaults 0 2

/dev/sdb3 /mnt/newdisk ext4 defaults 0 2

10) This will mount the new partition at /mnt/newdisk with the ext4 file system and default options

11)Finally, run the command df -h to verify that the new partition is mounted and available for use.

If the mount not shows reboot the server and check

That’s it! You have successfully added a new disk and created partitions in Ubuntu 22.04 LTS server

--

--

Manikanta Suru

👩🏻‍💻 Senior Cloud Engineer & AWS Community Builder👩🏻‍💻 https://manikanta-suru.github.io/