[Azure] Temporary disk on a FreeBSD VM

The FreeBSD image on VM depot works great but lack an essential feature: the temporary disk of the virtual machine is not mounted!

How to mount disk once

The VM temporary drive is formatted in NTFS, so we need to install NTFS driver:

# pkg install fusefs-ntfs

Then load the driver:

# kldload fuse

And mount the drive:

# mkdir /mnt/vmtmpdrive
# ntfs-3g /dev/ad1s1 /mnt/vmtmpdrive

Now we can check that the drive is mounted properly:

$ df -h
Filesystem         Size    Used   Avail Capacity  Mounted on
/dev/gpt/rootfs     19G    4.7G     13G    26%    /
devfs              1.0K    1.0K      0B   100%    /dev
/dev/fuse          135G    108M    135G     0%    /mnt/vmtmpdrive

How to mount disk at each boot

Optionally, if you want to mount the temporary disk each time the machine start, you can create a service.

First you need to enable the NTFS driver at boot time. Edit /boot/loader.conf and add:


Then, create /etc/rc.d/vmtmpdrive and paste:

# PROVIDE: vmtmpdrive
# REQUIRE: waagent

case $1 in
        echo "Mounting VM temporary drive..."
        /usr/local/bin/ntfs-3g /dev/ad1s1 /mnt/vmtmpdrive

        echo "Unmounting VM temporary drive..."
        umount /mnt/vmtmpdrive

Then run:

# chmod 755 /etc/rc.d/vmtmpdrive

That’s it!