Baadal
Guide

Using an extra disk on a Linux VM

After an extra disk is attached, format and mount it as a separate directory, or add it to the root volume with LVM.

Baadal team · 13 November 2026 · 6 min read

When an extra disk is attached to your VM, Linux sees a new, empty device. Before you can store files on it, you create a file system on it and mount it. There are two ways to use it:

  • A separate directory such as /data (recommended). Simple, and the disk stays independent of the system.
  • More space for the root file system, by adding the disk to the existing LVM volume. Useful when / is full, but the system then depends on both disks.
Check the device name before every command. Formatting the wrong disk erases it. Take a snapshot first if the VM holds data you care about.

Step 1: find the new disk

Connect over SSH and list the disks:

lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINT

The output looks like this:

NAME                  SIZE TYPE FSTYPE      MOUNTPOINT
vda                    80G disk
├─vda1                  1M part
├─vda2                  2G part ext4        /boot
└─vda3                 78G part LVM2_member
  └─ubuntu--vg-root    78G lvm  ext4        /
vdb                    50G disk

The new disk is the one with no partitions and no mount point, here vdb (50 GB). The rest of this guide uses /dev/vdb; replace it with your disk's name.

Option A: mount the disk as /data

Create one partition covering the disk, and an ext4 file system on it:

sudo parted /dev/vdb --script mklabel gpt mkpart data ext4 0% 100%
sudo mkfs.ext4 -L data /dev/vdb1

Mount it, and add it to /etc/fstab so it is mounted again after a restart. The file system's UUID is used rather than the device name, which can change:

sudo mkdir -p /data
UUID=$(sudo blkid -s UUID -o value /dev/vdb1)
echo "UUID=$UUID  /data  ext4  defaults,nofail  0  2" | sudo tee -a /etc/fstab
sudo systemctl daemon-reload
sudo mount -a
df -h /data

nofail lets the VM start even if the disk is missing, instead of stopping at an emergency prompt. To let your user write there without sudo:

sudo chown "$USER": /data

Option B: add the space to the root file system (LVM)

Baadal's Linux templates keep the root file system on LVM. Find the volume group and logical volume that hold /:

sudo vgs
sudo lvs

On recent Ubuntu templates the group is usually ubuntu-vg and the volume ubuntu-lv or root; older templates use baadalvm-vg. Use the names your VM shows. Then make the new disk an LVM physical volume, add it to the group, and grow the root volume and its file system in one step:

sudo parted /dev/vdb --script mklabel gpt mkpart lvm 0% 100% set 1 lvm on
sudo pvcreate /dev/vdb1
sudo vgextend ubuntu-vg /dev/vdb1
sudo lvextend -r -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
df -h /

-r resizes the file system too (ext4 or XFS), while it is in use.

With option B, the root file system spans both disks. The extra disk can then no longer be detached without losing data, so prefer option A unless you specifically need more space in /.

Checking the result

lsblk
df -h

Restart the VM once to make sure the disk comes back on its own.

Need help?

See the FAQ or write to baadalsupport@cc.iitd.ac.in with your VM's name.