Skip to content

Instantly share code, notes, and snippets.

@sarog
Forked from yzgyyang/FreeBSD_mount_img_files.md
Created July 28, 2021 21:31
Show Gist options
  • Select an option

  • Save sarog/8d66350673bacead68015fbcb2aeba4b to your computer and use it in GitHub Desktop.

Select an option

Save sarog/8d66350673bacead68015fbcb2aeba4b 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