How to Mount Vultr Block Storage Volume on FreeBSD

Updated on December 3, 2024

Mounting Vultr Block Storage volume on FreeBSD provides flexible and scalable file storage for Vultr Cloud Compute instances. FreeBSD supports NVMe and HDD-based Vultr Block Storage volumes.

Follow this guide to mount Vultr Block Storage volume on FreeBSD.

Warning
The following commands may destroy data on existing volumes. Use a new Vultr Block Storage volume to avoid data loss due to file system changes and partitioning.
  1. Attach Vultr Block Storage volume to FreeBSD.

  2. List all VirtIO Block Devices (vtbd) attached to FreeBSD.

    console
    $ ls -al /dev/vtbd*
    

    Output:

    crw-r-----  1 root operator 0x58 Oct 29 14:17 /dev/vtbd0
    crw-r-----  1 root operator 0x59 Oct 29 14:17 /dev/vtbd0p1
    crw-r-----  1 root operator 0x5a Oct 29 14:17 /dev/vtbd0p2
    crw-r-----  1 root operator 0x65 Oct 29 14:30 /dev/vtbd1

    The Vultr Block Storage volume attaches as /vtbd1 based on the above output. The first Vultr Block Storage volume attaches to FreeBSD as /dev/vtdb1 and additional volume disk names increment in a numeric order, such as /dev/vtdb2 and /dev/vtdb3.

  3. View all active partitions and verify the root filesystem disk name.

    console
    $ gpart show
    

    Output:

    =>      40  52428720  vtbd0  GPT  (25G)
            40      1024      1  freebsd-boot  (512K)
          1064  52427696      2  freebsd-ufs  (25G)

    vtbd0 is the root filesystem disk with two active storage partitions based on the above output.

  4. Create a new GPT partition table for the vtbd1 Vultr Block Storage volume.

    console
    $ sudo gpart create -s GPT vtbd1
    

    Output:

    vtbd1 created
  5. Create a new partition with the UFS2 partition and a label such as vultr_block_storage.

    console
    $ sudo gpart add -t freebsd-ufs -l vultr\\_block\\_storage vtbd1
    

    Output:

    vtbd1p1 added
  6. Initialize the UFS2 filesystem on the new Vultr Block Storage volume partition.

    console
    $ sudo newfs -U vtbd1p1
    

    Output:

    /dev/vtbd1p1: 40960.0MB (83886000 sectors) block size 32768, fragment size 4096
            using 66 cylinder groups of 625.22MB, 20007 blks, 80128 inodes.
            with soft updates
    super-block backups (for fsck_ffs -b #) at:
     192, 1280640, 2561088, 3841536, 5121984, 6402432, 7682880, 8963328, 10243776, 11524224,
     12804672, 14085120, 15365568, 16646016, 17926464, 19206912, 20487360, 21767808, 23048256,
     24328704, 25609152, 26889600, 28170048, 29450496, 30730944, 32011392, 33291840, 34572288,
     35852736, 37133184, 38413632, 39694080, 40974528, 42254976, 43535424, 44815872, 46096320,
     47376768, 48657216, 49937664, 51218112, 524985
  7. Create a new mount point directory for the Vultr Block Storage volume partition.

    console
    $ sudo mkdir /mnt/blockstorage
    
  8. Mount the Vultr Block Storage volume partition.

    console
    $ sudo mount -t ufs /dev/vtbd1p1 /mnt/blockstorage
    
  9. View all active partitions to verify the new partition is available.

    console
    $ sudo gpart show
    

    Output:

    =>      40  52428720  vtbd0  GPT  (25G)
            40      1024      1  freebsd-boot  (512K)
          1064  52427696      2  freebsd-ufs  (25G)
    
    =>      40  83886000  vtbd1  GPT  (40G)
            40  83886000      1  freebsd-ufs  (40G)

    The vtbd1 Vultr Block Storage volume partition is active on FreeBSD based on the above output.

  10. List the Vultr Block Storage volume partition information and note the rawuuid value in the command output.

    console
    $ gpart list /dev/vtbd1
    

    Output:

    Geom name: vtbd1
    modified: false
    state: OK
    fwheads: 16
    fwsectors: 63
    last: 83886039
    first: 40
    entries: 128
    scheme: GPT
    Providers:
    1. Name: vtbd1p1
       Mediasize: 42949632000 (40G)
       Sectorsize: 512
       Stripesize: 0
       Stripeoffset: 20480
       Mode: r1w1e1
       efimedia: HD(1,GPT,e805ef8b-9618-11ef-bc70-315e9870b088,0x28,0x4ffffb0)
       rawuuid: e805ef8b-9618-11ef-bc70-315e9870b088
       rawtype: 516e7cb6-6ecf-11d6-8ff8-00022d09712b
       label: vultr\_block\_storage
       length: 42949632000
       offset: 20480
       type: freebsd-ufs
       index: 1
       end: 83886039
       start: 40
    ..........

    e805ef8b-9618-11ef-bc70-315e9870b088 is the Vultr Block Storage volume partition UUID based on the above output. You can use the UUID value to mount the Vultr Block Storage volume partition when FreeBSD restarts.

  11. Add a new entry to /etc/fstab to automatically mount the Vultr Block Storage volume partition at boot. Replace UUID-VALUE with the actual Vultr Block Storage volume UUID.

    console
    $ sudo echo >> sudo /etc/fstab
    $ sudo echo "/dev/gptid/UUID-VALUE /mnt/blockstorage  ufs  rw  0  0" >> sudo /etc/fstab
    
  12. View the Vultr Block Storage volume usage.

    console
    $ df -h /mnt/blockstorage
    

    Output:

    Filesystem      Size    Used   Avail Capacity  Mounted on
    /dev/vtbd1p1     39G    8.0K     36G     0%    /mnt/blockstorage