Tuesday, June 01, 2021

Mount your Virtualbox OS Guest file system as a Hard Drive in Ubuntu

In case something is broken within your VirtualBox Guest OS or if you just want to access the files, the following will allow you to mount your VirtualBox Guest OS disk images in your Ubuntu (Host) like it's an attached hard drive or just another directory.  This access will have full read/write permissions so you'll be able to copy files to/from it, delete files, or change files on your VirtualBox Guest OS.

Make sure your VirtualBox Guest OS is shutdown and the virtual disk image is NOT in use. 

NOTE: Remember to UN-MOUNT it once your finished accessing the Guest OS files (see below).


Let's get started:

1.  Open a Terminal Window. Run the following command:

vboximg-mount --list

vboximg-mount  is how you make your VirtualBox Disk Images (Guests) available to the Host. The --list option will list all VirtualBox Disk Images along with their UUID.

2.  Next perform a FUSE mount of the virtual disk image:

Create a folder as a mount point. In this case let's use vboxdisc:

mkdir vboxdisc

Then enter the following command:

vboximg-mount -i UUID -o allow_root vboxdisc

NOTE: (remember to replace the UUID with your own in the above command): 

NOTE: You might need to edit the “/etc/fuse.conf” to allow the -o allow_root flag to work. To do this run the command sudo gedit /etc/fuse.conf and enable, by remove # at it's beginning, “user_allow_other” line.

3.  Now mount your partition (vol2 for instance) to /mnt by typing the following command:

sudo mount vboxdisc/vol2 /mnt

NOTE: change vol2 to match your partition name.

4.  Finally go to the /mnt directory to see your Guest OS files.


*************************************************************

Remember to UN-MOUNT once your finished accessing the Guest OS files.


How to Unmount:

To unmount the VirtualBox Guest OS file system, run the following command:

sudo umount /mnt

To unmount the VirtualBox Disk Image, run the following command:

umount ~/vboxdisc

And finally to remove ~/vboxdisc  folder run the following command:

rm -r ~/vboxdisc