🎉 Announcing new lower pricing — up to 40% lower costs for Cloud Servers and Cloud SQL! Read more →

Contents

Manually Formatting Volumes

Volumes created without specifying a filesystem must be manually formatted before they can be used.

If you specified an ext4 or xfs filesystem during volume creation, you won’t need to format it manually, so you can skip this guide.

View attached devices

We can use lsblk -f to view existing devices and filesytems:

$ lsblk -f

NAME    FSTYPE   FSVER LABEL           UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
loop0   squashfs 4.0                                                              0   100% /snap/core20/1405
loop1   squashfs 4.0                                                              0   100% /snap/lxd/22923
loop2   squashfs 4.0                                                              0   100% /snap/snapd/15177
loop3   squashfs 4.0                                                              0   100% /snap/snapd/15534
loop4   squashfs 4.0                                                              0   100% /snap/core20/1434
vda
├─vda1  ext4     1.0   cloudimg-rootfs 0522e6b3-8d40-4754-a87e-5678a6921e37   36.7G     5% /
├─vda14
└─vda15 vfat     FAT32 UEFI            184A-7E18                              99.1M     5% /boot/efi
vdb

Here we can see on the last line a device called vdb which doesn’t have a filesystem and isn’t currently mounted.

By default, lsblk doesn’t output enough information here for us to make use of the persistent block device naming features, but we can use /dev/disk/by-id/ to correlate the OS-assigned vdb name with the volume vol-1bcta we’ve attached:

$ ls -la /dev/disk/by-id/ | grep vol-1bcta

lrwxrwxrwx 1 root root   9 Apr 29 11:57 virtio-vol-1bcta -> ../../vdb

Format with ext4

To format the new volume with an ext4 filesystem:

$ sudo mkfs -t ext4 /dev/disk/by-id/virtio-vol-1bcta

mke2fs 1.46.5 (30-Dec-2021)
Creating filesystem with 10485760 4k blocks and 2621440 inodes
Filesystem UUID: 0ef26a3c-0b51-48f0-8b22-86d1bed6e0a6
Superblock backups stored on blocks:
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
    4096000, 7962624

Allocating group tables: done
Writing inode tables: done
Creating journal (65536 blocks): done
Writing superblocks and filesystem accounting information: done

Format with XFS

To format the new volume with an xfs filesystem:

$ sudo mkfs -t xfs /dev/disk/by-id/virtio-vol-1bcta

meta-data=/dev/disk/by-id/virtio-vol-1bcta isize=512    agcount=4, agsize=2621440 blks
        =                       sectsz=512   attr=2, projid32bit=1
        =                       crc=1        finobt=1, sparse=1, rmapbt=0
        =                       reflink=1    bigtime=0 inobtcount=0
data     =                       bsize=4096   blocks=10485760, imaxpct=25
        =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=5120, version=2
        =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

Next steps

Now that the volume has been formatted, it can be mounted ready for use.

Last updated: 12 May 2022 at 12:08 UTC

Try Brightbox risk-free with £50 free credit Sign up takes just two minutes...