I bought a GreenCloud (aff) Storage VPS on Black Friday!
A step-by-step walkthrough on using fdisk to partition disks on Linux (Ubuntu/Debian), formatting them to the Btrfs filesystem, and configuring /etc/fstab to ensure auto-mounting after reboots. This workflow can be used for all KVM-based VPS.
The following commands are run as root. If you don’t have sufficient permissions, remember to add sudo.
1. Use lsblk to see which disk needs partitioning
> lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 368K 1 disk
sr0 11:0 1 1024M 0 rom
vda 254:0 0 20G 0 disk
|-vda1 254:1 0 1M 0 part
|-vda2 254:2 0 122M 0 part /boot/efi
`-vda3 254:3 0 19.9G 0 part /
vdb 254:16 0 500G 0 disk
2. Use fdisk to create a partition
> fdisk /dev/vdb
- Command (m for help):
g - Command (m for help):
n
For one partition, just use the default values. - Command (m for help):
w
This writes the partition table changes stored in memory to the disk and then exitsfdisk. If you exit before typingw, no changes will be made.
Welcome to fdisk (util-linux 2.41).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS (MBR) disklabel with disk identifier 0x0c3294a3.
Command (m for help): g
Created a new GPT disklabel (GUID: E5606734-1335-4696-9501-B9A12D5B780B).
Command (m for help): n
Partition number (1-128, default 1): 1
First sector (2048-1048575966, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-1048575966, default 1048573951):
Created a new partition 1 of type 'Linux filesystem' and of size 500 GiB.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
3. To use btrfs, install btrfs-progs
> apt install btrfs-progs
4. Format as btrfs
At this point, the output of lsblk should look like this:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 368K 1 disk
sr0 11:0 1 1024M 0 rom
vda 254:0 0 20G 0 disk
|-vda1 254:1 0 1M 0 part
|-vda2 254:2 0 122M 0 part /boot/efi
`-vda3 254:3 0 19.9G 0 part /
vdb 254:16 0 500G 0 disk
`-vdb1 254:17 0 500G 0 part
Run the format command:
> mkfs.btrfs -f /dev/vdb1
btrfs-progs v6.14
See https://btrfs.readthedocs.io for more information.
Performing full device TRIM /dev/vdb1 (500.00GiB) ...
NOTE: several default settings have changed in version 5.15, please make sure
this does not affect your deployments:
- DUP for metadata (-m dup)
- enabled no-holes (-O no-holes)
- enabled free-space-tree (-R free-space-tree)
Label: (null)
UUID: 518709cc-6e80-43bf-afc9-bd2bd9a9791a
Node size: 16384
Sector size: 4096 (CPU page size: 4096)
Filesystem size: 500.00GiB
Block group profiles:
Data: single 8.00MiB
Metadata: DUP 1.00GiB
System: DUP 8.00MiB
SSD detected: no
Zoned device: no
Features: extref, skinny-metadata, no-holes, free-space-tree
Checksum: crc32c
Number of devices: 1
Devices:
ID SIZE PATH
1 500.00GiB /dev/vdb1
5. Mount to a specific path
I chose /mnt/backups.
> mkdir -p /mnt/backups
> mount -o compress=zstd /dev/vdb1 /mnt/backups
> lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 368K 1 disk
sr0 11:0 1 1024M 0 rom
vda 254:0 0 20G 0 disk
|-vda1 254:1 0 1M 0 part
|-vda2 254:2 0 122M 0 part /boot/efi
`-vda3 254:3 0 19.9G 0 part /
vdb 254:16 0 500G 0 disk
`-vdb1 254:17 0 500G 0 part /mnt/backups
To allow a regular (non-root) user to read and write to this directory, chown it to the actual username. For example, if the username is small:
> chown -R small:small /mnt/backups
6. Edit fstab
To keep the settings after a reboot, we need to add it to fstab.
Locate the UUID by:
> blkid /dev/vdb1
/dev/vdb1: UUID="518709cc-6e80-43bf-afc9-bd2bd9a9791a" UUID_SUB="6593363f-aee9-493d-b912-49f84f9effcc" BLOCK_SIZE="4096" TYPE="btrfs" PARTUUID="15bcaff2-b553-4711-94cd-95f81a2c9093"
Edit /etc/fstab:
> nano /etc/fstab
Add the following to the end of the file:
UUID=518709cc-6e80-43bf-afc9-bd2bd9a9791a /mnt/backups btrfs defaults,compress=zstd 0 0
- UUID=…: Identifies the disk accurately.
- /mnt/backups: Where it should live.
- btrfs: The filesystem type.
- defaults,compress=zstd: The options.
- 0 0: These last two numbers tell Linux not to “dump” the disk and not to scan it during boot (since Btrfs handles its own scanning).
7. Verify the fstab changes
> mount -a
Not output means it worked!
If there’s output, for example, if the UUID is wrong, the error message might look like this:
mount: /mnt/backups: can't find UUID=a1b2c3d4-1234-5678-9abc-def123456789.
8. Running YABS
If you want to run YABS (Yet Another Bench Script), cd into /mnt/backups and run YABS there to test this specific disk.