Format + Mount HDD storage
Auto-Mount an Extra Disk to /mnt/hdd (ext4)
This script automatically finds the largest unpartitioned disk (commonly /dev/vdb on cloud VMs), creates a partition, formats it as ext4 with the label nova-hdd, and mounts it persistently at /mnt/hdd.
TL;DR (One-liner)
Run only after verifying which disk will be affected. The script always picks the largest unpartitioned
/dev/vd*disk.
bash <(wget -qO- https://bash.novacloud-hosting.com/mount.sh)cURL alternative
bash <(curl -fsSL https://bash.novacloud-hosting.com/mount.sh)What the script does
- Installs
partedif missing. - Scans all devices
/dev/vd[a-z]. - Selects the largest unpartitioned disk.
- Creates a GPT partition table and a single partition.
- Formats the partition as ext4 with label
nova-hdd. - Creates
/mnt/hddif missing. - Adds a persistent entry to
/etc/fstabusing LABEL=nova-hdd. - Mounts it immediately and prints a summary.
Pre-flight checks (highly recommended)
Before executing the script, double-check which disk will be picked:
lsblk -o NAME,SIZE,TYPE,MOUNTPOINTS,FSTYPE
sudo fdisk -l- Make sure the largest unpartitioned disk is truly the one you want formatted.
- Formatting will erase all data on the chosen disk.
Run the script
bash <(wget -qO- https://bash.novacloud-hosting.com/mount.sh)Expected outcome
- New partition:
/dev/vdb1(or whichever disk was selected) - Filesystem:
ext4with labelnova-hdd - Mount point:
/mnt/hdd /etc/fstabentry added usingLABEL=nova-hdd
You can now use /mnt/hdd for data.
Verify everything
# Mounted?
df -h | grep /mnt/hdd
# Label present?
blkid | grep nova-hdd
# fstab entry?
grep nova-hdd /etc/fstab
# Write/read test
sudo bash -c 'echo test > /mnt/hdd/.check && cat /mnt/hdd/.check && rm /mnt/hdd/.check'Troubleshooting
Problem: The wrong disk was selected. Fix: Stop, unmount, and wipe:
sudo umount /mnt/hdd
sudo sed -i.bak '/LABEL=nova-hdd/d' /etc/fstab
sudo wipefs -a /dev/vdX # Replace with the affected diskProblem: Device already had partitions. Fix: If it’s safe to wipe:
sudo wipefs -a /dev/vdX
sudo sgdisk --zap-all /dev/vdXRe-run the script.
Problem: Mount failed at boot.
Fix: Edit /etc/fstab and ensure the line matches the label:
LABEL=nova-hdd /mnt/hdd ext4 defaults,nofail 0 2Then test with mount -a.
Problem: Device busy during unmount. Fix:
sudo lsof +f -- /mnt/hdd | headStop the process, then unmount.
Safety & review
Piping to bash is convenient, but you can review the script first:
# View without running
wget -qO- https://bash.novacloud-hosting.com/mount.sh | less
# Or save locally
wget -O mount.sh https://bash.novacloud-hosting.com/mount.sh
chmod +x mount.sh
sudo ./mount.shUninstall / revert
# 1) Unmount
sudo umount /mnt/hdd
# 2) Remove fstab entry
sudo sed -i.bak '/LABEL=nova-hdd/d' /etc/fstab
# 3) (Optional) Wipe partition
sudo wipefs -a /dev/vdX1
sudo sgdisk --zap-all /dev/vdXFAQ
Q: Will this always use /dev/vdb?
A: Not necessarily. It picks the largest unpartitioned vd* disk. On many VMs this is /dev/vdb, but check first with lsblk.
Q: Why use LABEL instead of UUID?
A: The script sets LABEL=nova-hdd for readability and portability across environments.
Q: Can I run this multiple times?
A: If a disk with label nova-hdd is already set up, it will skip adding another fstab entry and just mount.
Manual steps (without the script)
# Partition disk
device=/dev/vdb # adjust accordingly
sudo parted -s $device mklabel gpt
sudo parted -s $device mkpart primary ext4 0% 100%
# Create filesystem with label
sudo mkfs.ext4 -L nova-hdd ${device}1
# Create mountpoint
sudo mkdir -p /mnt/hdd
# Add to fstab (by label)
echo "LABEL=nova-hdd /mnt/hdd ext4 defaults,nofail 0 2" | sudo tee -a /etc/fstab
# Mount
sudo mount -aLast updated: 2025‑08‑24