Adding a 2nd disk to a Debian VM and formatting as a partition

In this guide I am going to set up a new disk 100GB disk in a VM called v-debian

After adding the disk to the VM log into the guest OS:

 

Check the output using the following command:

fdisk -l

You’ll noticed that /dev/sdb is free

 

Partition the new disk

cfdisk /dev/sdb

Select New -> Primary -> (Size – 100GB in this case) -> Write -> Quit

 

Format the disk using ext4

mkfs.ext4 /dev/sdb1

 

Create a mount point for the new disk (in this case I am using /data)

mkdir /data

Mount the drive

mount -t ext4 /dev/sdb1 /data

edit /etc/fstab so it will be visible after a reboot.

/dev/sdb1 /data ext4 defaults,errors=remount-ro 0 1