Skip to content

Instantly share code, notes, and snippets.

@Martinfx
Forked from yzgyyang/FreeBSD_mount_img_files.md
Created January 25, 2020 19:24
Show Gist options
  • Save Martinfx/1a63938a0d63cd51c26de71c8353da4a to your computer and use it in GitHub Desktop.
Save Martinfx/1a63938a0d63cd51c26de71c8353da4a to your computer and use it in GitHub Desktop.
FreeBSD mount img files

Determine the file system by using the file-utility.

file image.img

Use mdconfig to link the IMG image to a virtual device.

mdconfig -a -t vnode -f /path/to/image.img -u 0

The image will now be connected to the virtual device /dev/md0.

Now mount the virtual device. This example mounts an ext2 image:

mount -t ext2fs /dev/md0 /mnt
You can now see the contents of the image in /mnt.

To unmount the image:

umount /mnt
mdconfig -d -u 0

ISO images can be mounted using this way as well, using the file system cd9660 or UDF and mounting it in /cdrom instead of /mnt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment