0

I have a FreeBSD 11 qcow2 image that I would like to mount in my Debian Jessie machine. I have other qcow2 images that have Debian Jessie on them, and I am able to mount partitions in the image on the host using libguestfs-tools. In the Debian Jessie qcow2 case, I normally do something like this, and it works as expected:

guestmount -a <qcow2 image> -m <parition to mount in the image> --ro <mount point>

However, when I do the same for a FreeBSD image, I get an error:

root@bonddtest:/home/igw/bondd_testbed/ooo# guestmount -a ../shaper.qcow2 -m /dev/gpt/rootfs --ro /mnt
libguestfs: error: mount_options: mount_options_stub: /dev/gpt/rootfs: No such file or directory
guestmount: '/dev/gpt/rootfs' could not be mounted.
guestmount: Did you mean to mount one of these filesystems?
guestmount:     /dev/sda1 (unknown)
guestmount:     /dev/sda2 (unknown)
guestmount:     /dev/sda3 (ufs)

I have tried the other three partition suggestions, but they all result in the same error. Is this not working due to differences in the file system types? The FreeBSD partition I am trying to mount is UFS, whereas the mount point is in an EXT4 partition.

2
  • Did you make sure UFS is supported by your kernel? Try sudo modprobe ufs. Then /dev/sda3 should be the correct device to mount. See also kernel.org/doc/Documentation/filesystems/ufs.txt for mount options.
    – ridgy
    Commented Apr 28, 2017 at 18:00
  • ufs module is loaded in my case.
    – Waqas
    Commented Apr 28, 2017 at 18:15

1 Answer 1

1

I figured out how to do this, and it is combination of ridgy's suggestion above and using the qemu-nbd utility as suggested in this blog:

  1. Connect FreeBSD qcow2 file to NBD device:

    qemu-nbd -c /dev/nbd0 qcow2_file

  2. Determine partition to mount of the NBD device. I used lslbk:

root@host:# lsblk 
NAME     MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sr0       11:0    1  1024M  0 rom  
nbd0      43:0    0    21G  0 disk 
├─nbd0p3  43:3    0    20G  0 part 
├─nbd0p1  43:1    0  62.5K  0 part 
└─nbd0p2  43:2    0     1G  0 part

My qcow2 image has a 20G size, so I picked nbd0p3 to mount

  1. Mount NBD device parition to a mount point:

    mount -r -t ufs -o ufstype=ufs2 /dev/nbd0p3 /mnt

Note: It is best to mount the qcow2 image as read-only or it may get corrupted.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .