How do I use Block Storage with FreeBSD?
I have FreeBSD 12.1 deployed on a Linode. I've created a volume via the Block Storage service and have attached it to my Linode. It is not showing up. The howto references /dev/disk/ but there is no /dev/disk tree and the drive is not visible. Is there an additional step I have to do?
1 Reply
While we don't have a supported FreeBSD image (yet), you can still use Block Storage volumes with a custom FreeBSD installation.
NOTE: You'll need to reboot your Linode after you've attached the Block Storage volume. The volume should be assigned to a mountpoint (for example, /dev/sdb or /dev/sdc) — you can confirm this from your Linode's Disks/Configs tab by selecting "Edit" from the meatball menu next to its configuration profile and looking under "Block Device Assignment".
1. Determine where your volumes are located
From your Linode's shell, you can confirm that the volume is available by listing all detected disks with this command:
$ egrep 'da[0-9]|cd[0-9]' /var/run/dmesg.boot
Any drives containing "Linode Volume" are associated with Block Storage volumes. Here's an example output from my test system, which has two 20 GB volumes attached to it:
$ egrep 'da[0-9]|cd[0-9]' /var/run/dmesg.boot
acpi_syscontainer1: <System Container> port 0xcd8-0xce3 on acpi0
da0 at vtscsi0 bus 0 scbus0 target 0 lun 0
da0: <QEMU QEMU HARDDISK 2.5+> Fixed Direct Access SPC-3 SCSI device
da0: 300.000MB/s transfers
da0: Command Queueing enabled
da0: 40000MB (81920000 512 byte sectors)
da2 at vtscsi2 bus 0 scbus2 target 2 lun 3
da2: <Linode Volume 2.5+> Fixed Direct Access SPC-3 SCSI device
da2: 300.000MB/s transfers
da2: Command Queueing enabled
da2: 20480MB (41943040 512 byte sectors)
da1 at vtscsi1 bus 0 scbus1 target 1 lun 2
da1: <Linode Volume 2.5+> Fixed Direct Access SPC-3 SCSI device
da1: 300.000MB/s transfers
da1: Command Queueing enabled
da1: 20480MB (41943040 512 byte sectors)
Accordingly, you'll find these drives in the /dev
folder of your system. Following the above output, my volumes are located at /dev/da1
and /dev/da2
.
2. Create a filesystem for your volume and mount it to a directory
From here, you'll need to create a filesystem for your volume and mount it as detailed in our general guide, however you'll need to use FreeBSD commands for adding disks. You'll also need to log in as the root user (such as with su -
) or otherwise have required permission to access your volume. The following examples assume your volume is located at /dev/da1
.
- Create a partition scheme and add the partition to your drive, with the following expected outputs:
# gpart create -s GPT /dev/da1
# gpart add -t freebsd-ufs -a 1M /dev/da1
A new partition should be created at /dev/da1p1
.
- Next, create a file system in this partition:
# newfs -U /dev/da1p1
- Create a directory to serve as a mountpoint:
# mkdir -p /mnt/BlockStorage1
- Using a file editor such as
vi
, add the following line to the end of your/etc/fstab
file so the disk will be mounted automatically at startup:
/dev/da1p1 /mnt/BlockStorage1 ufs rw 2 2
- Finally, mount your volume:
# mount /mnt/BlockStorage1
You can now write and read files on your volume at /mnt/BlockStorage1
.