Skip to main content

Format Volume

This guide will help you format a volume in Vietnix Cloud.

Prerequisites

  • A volume attached to your instance
  • SSH access to your instance
  • Root or sudo privileges

Steps to Format Volume

Step 1: Identify the Volume

First, identify the volume device name:

# List all block devices
lsblk

# Or use fdisk to list devices
sudo fdisk -l

The volume will typically appear as /dev/vdb, /dev/vdc, etc.

Step 2: Create Partition (Optional)

If the volume doesn't have a partition table:

# Create a new partition table
sudo fdisk /dev/vdb

# Follow the prompts:
# 1. Type 'n' for new partition
# 2. Type 'p' for primary partition
# 3. Press Enter for default values
# 4. Type 'w' to write changes

Step 3: Format the Volume

For ext4 filesystem
# Format with ext4
sudo mkfs.ext4 /dev/vdb1

# Or if no partition table:
sudo mkfs.ext4 /dev/vdb
For XFS filesystem
# Format with XFS
sudo mkfs.xfs /dev/vdb1

# Or if no partition table:
sudo mkfs.xfs /dev/vdb
For NTFS (Windows)
# Format with NTFS
sudo mkfs.ntfs /dev/vdb1

Step 4: Create Mount Point

# Create mount directory
sudo mkdir /mnt/myvolume

# Or use any directory you prefer
sudo mkdir /data

Step 5: Mount the Volume

# Mount the volume
sudo mount /dev/vdb1 /mnt/myvolume

# Verify the mount
df -h

Auto-mount on Boot

To automatically mount the volume on boot:

Step 1: Get Volume UUID

# Get the UUID of the volume
sudo blkid /dev/vdb1

Step 2: Add to fstab

# Edit fstab file
sudo nano /etc/fstab

# Add this line (replace UUID with actual UUID):
UUID=your-uuid-here /mnt/myvolume ext4 defaults 0 2

Important Notes

  • Data Loss Warning: Formatting will erase all data on the volume
  • Backup First: Always backup important data before formatting
  • Device Names: Device names may change after instance reboot
  • File System Choice: Choose the appropriate file system for your use case

Troubleshooting

Common Issues

  1. Permission denied: Use sudo for all commands
  2. Device not found: Check if volume is properly attached
  3. Mount failed: Verify file system type and device name

Commands for Troubleshooting

# Check disk usage
df -h

# Check mounted filesystems
mount | grep vdb

# Check file system
sudo fsck /dev/vdb1
Support

If you encounter any issues, contact our support team at support.vietnix.vn

Maybe You Need This