Adding extra virtual hard disks to a VirtualBox VM is something you will do regularly – whether you need more storage, want to test disk management, or are simulating multi-disk setups. This guide covers every step in VirtualBox 7.1: creating and attaching disks through the GUI and command line, partitioning, formatting, mounting, automounting via fstab, LVM configuration, resizing existing disks, and using shared folders as an alternative.
Prerequisites
- VirtualBox 7.1 installed on your host system
- An existing VM with a Linux guest OS (this guide uses Ubuntu/Debian and RHEL-based examples)
- The VM should be powered off before adding disks
Method 1: Add a Disk via the VirtualBox GUI
This is the most straightforward approach for quick setups.
- Open VirtualBox Manager and select your VM.
- Click Settings – Storage.
- Under the Controller: SATA (or SCSI), click the Add Hard Disk icon (the small disk icon with a plus sign).
- Select Create a new disk.
- Choose the disk format. VDI (VirtualBox Disk Image) is the default and works well for most cases. VMDK is useful if you plan to move disks between VirtualBox and VMware.
- Choose between Dynamically allocated (grows as needed) or Fixed size (pre-allocates full space on host). Dynamically allocated saves host disk space but has a slight performance overhead.
- Set the disk size and file location, then click Finish.
- Click OK to save the VM settings.
The new disk will appear under the storage controller. Boot the VM and proceed to partitioning.
Method 2: Add a Disk via VBoxManage CLI
If you prefer the command line or need to script disk creation, VBoxManage is your tool. First, create a new virtual disk:
VBoxManage createmedium disk --filename ~/VirtualBox\ VMs/myvm/extra_disk.vdi \
--size 20480 --format VDI --variant Standard
This creates a 20 GB dynamically allocated VDI file. The --size value is in megabytes. For a fixed-size disk, change --variant Standard to --variant Fixed.
Next, attach the disk to your VM. You need to know the storage controller name – check it with:
VBoxManage showvminfo "myvm" | grep "Storage Controller"
Then attach the disk:
VBoxManage storageattach "myvm" \
--storagectl "SATA" \
--port 1 \
--device 0 \
--type hdd \
--medium ~/VirtualBox\ VMs/myvm/extra_disk.vdi
Use --port 1 because port 0 is typically occupied by the primary disk. Increase the port number for each additional disk.
Verify the attachment:
VBoxManage showvminfo "myvm" | grep "SATA"
Partition the New Disk Inside the VM
Boot the VM and identify the new disk:
lsblk
You should see a new device – typically /dev/sdb – with no partitions. You can partition it using fdisk or parted.
Using fdisk
sudo fdisk /dev/sdb
Inside the fdisk prompt:
- Type
gto create a new GPT partition table. - Type
nto create a new partition. Accept defaults to use the entire disk. - Type
wto write changes and exit.
Using parted
sudo parted /dev/sdb --script mklabel gpt mkpart primary 0% 100%
Verify the partition was created:
lsblk /dev/sdb
You should now see /dev/sdb1.
Format the Partition
Choose a filesystem based on your needs. ext4 is the safe default for most Linux systems. XFS performs better with large files and is the default on RHEL-based distributions.
Format with ext4
sudo mkfs.ext4 /dev/sdb1
Format with XFS
sudo mkfs.xfs /dev/sdb1
After formatting, verify the filesystem:
sudo blkid /dev/sdb1
Note the UUID from the output – you will need it for fstab configuration.
Mount the Disk Manually
Create a mount point and mount the partition:
sudo mkdir -p /mnt/extra_disk
sudo mount /dev/sdb1 /mnt/extra_disk
Verify the mount:
df -hT /mnt/extra_disk
This confirms the disk is mounted, shows the filesystem type, and reports available space. This mount is temporary and will not survive a reboot.
Configure Automount with /etc/fstab
To make the mount persistent across reboots, add an entry to /etc/fstab. Always use the UUID rather than the device path, because device names like /dev/sdb can change between boots.
Get the UUID:
sudo blkid /dev/sdb1
Add the following line to /etc/fstab (replace the UUID with your actual value):
UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /mnt/extra_disk ext4 defaults 0 2
For XFS, replace ext4 with xfs. The last two fields control dump backups (0 to skip) and fsck order (2 for non-root filesystems).
Test the fstab entry without rebooting:
sudo umount /mnt/extra_disk
sudo mount -a
If the mount succeeds without errors, the fstab entry is correct. Verify:
df -hT /mnt/extra_disk
LVM Setup on the New Disk
LVM (Logical Volume Manager) gives you flexibility to resize volumes later without unmounting. This is valuable in lab environments where storage requirements change often.
Install LVM tools if not present:
# Debian/Ubuntu
sudo apt install -y lvm2
# RHEL/Rocky/Alma
sudo dnf install -y lvm2
Create a physical volume on the new disk (use the whole disk, not a partition):
sudo pvcreate /dev/sdb
Create a volume group:
sudo vgcreate vg_extra /dev/sdb
Create a logical volume using all available space:
sudo lvcreate -l 100%FREE -n lv_data vg_extra
Format and mount the logical volume:
sudo mkfs.ext4 /dev/vg_extra/lv_data
sudo mkdir -p /mnt/lvm_data
sudo mount /dev/vg_extra/lv_data /mnt/lvm_data
For fstab, use the LVM path:
/dev/vg_extra/lv_data /mnt/lvm_data ext4 defaults 0 2
Verify the setup:
sudo pvs
sudo vgs
sudo lvs
Resize an Existing Virtual Disk
Sometimes instead of adding a new disk, you just need to make an existing one larger. Shut down the VM first, then resize the disk from the host:
VBoxManage modifymedium disk ~/VirtualBox\ VMs/myvm/myvm_disk.vdi --resize 40960
This expands the disk to 40 GB. The --resize value is in megabytes and represents the new total size, not additional space.
After booting the VM, extend the partition and filesystem. If you use LVM:
# Extend the partition (assuming /dev/sda2 is the LVM partition)
sudo growpart /dev/sda 2
# Resize the physical volume
sudo pvresize /dev/sda2
# Extend the logical volume
sudo lvextend -l +100%FREE /dev/mapper/vg_name-lv_name
# Resize the filesystem
sudo resize2fs /dev/mapper/vg_name-lv_name # for ext4
sudo xfs_growfs /mnt/mountpoint # for XFS
Verify with df -h to confirm the filesystem reflects the new size.
Shared Folders as an Alternative
If you only need to exchange files between the host and guest, VirtualBox shared folders are simpler than adding a virtual disk. They require Guest Additions to be installed in the VM.
Add a shared folder via CLI:
VBoxManage sharedfolder add "myvm" \
--name "shared" \
--hostpath "/home/user/shared_folder" \
--automount \
--auto-mount-point "/mnt/shared"
Inside the guest VM, the shared folder will appear at /mnt/shared after reboot. If it does not mount automatically, mount it manually:
sudo mount -t vboxsf shared /mnt/shared
To give your user access without sudo, add yourself to the vboxsf group:
sudo usermod -aG vboxsf $USER
Log out and back in for the group change to take effect.
Conclusion
VirtualBox 7.1 makes it easy to expand your VM’s storage. For most use cases, adding a virtual disk through the GUI, partitioning with fdisk or parted, formatting, and configuring fstab gives you a reliable persistent mount. LVM adds flexibility if you anticipate future resizing. And for quick host-guest file sharing, shared folders avoid the overhead of managing extra virtual disks altogether. Whichever method you choose, always verify each step – check lsblk, df -h, and test fstab entries with mount -a before relying on them in production.