NovaCloud-Hosting Docs

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

  1. Installs parted if missing.
  2. Scans all devices /dev/vd[a-z].
  3. Selects the largest unpartitioned disk.
  4. Creates a GPT partition table and a single partition.
  5. Formats the partition as ext4 with label nova-hdd.
  6. Creates /mnt/hdd if missing.
  7. Adds a persistent entry to /etc/fstab using LABEL=nova-hdd.
  8. Mounts it immediately and prints a summary.

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: ext4 with label nova-hdd
  • Mount point: /mnt/hdd
  • /etc/fstab entry added using LABEL=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 disk

Problem: Device already had partitions. Fix: If it’s safe to wipe:

sudo wipefs -a /dev/vdX
sudo sgdisk --zap-all /dev/vdX

Re-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 2

Then test with mount -a.

Problem: Device busy during unmount. Fix:

sudo lsof +f -- /mnt/hdd | head

Stop 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.sh

Uninstall / 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/vdX

FAQ

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 -a

Last updated: 2025‑08‑24

On this page