Skip to content

Instantly share code, notes, and snippets.

@yzgyyang
Created June 28, 2017 20:46
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save yzgyyang/4965d5673b5c79c644a695dd75fa8e05 to your computer and use it in GitHub Desktop.
Save yzgyyang/4965d5673b5c79c644a695dd75fa8e05 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.

@Marietto2008
Copy link

this is wrong : mount -t ext2fs /dev/md0 /mnt and should be changed with this : lklfuse -o type=ext4 /dev/md0 /mnt/linux

@mexicarne
Copy link

pkg install fusefs-ext2 && fuse-ext2 /path/to/image.img /mnt

@sryze
Copy link

sryze commented Sep 9, 2023

is there a way to mount a disk image with multiple partitions?

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