Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mount disk image on WSL (Windows subsystem for Linux)? [closed]

Tags:

I'm using Ubuntu and I have created a full copy of my system SSD hard drive with the following command:

dd if=/dev/sda of=ubuntu.iso 

and saved it on a backup HDD which is an NTFS drive.

I'm now on Windows 10 PRO and want to mount this image using WSL (Ubuntu 18.04). This is the command I'm using:

sudo mount -o ro,loop,offset=1048576 /mnt/a/ubuntu.iso /mnt/ubuntu_backup 

This is the error that I get:

 mount: /mnt/ubuntu_backup: mount failed: Operation not permitted. 

This same command worked on Ubuntu.

Is it possible to mount this image using WSL?

like image 459
userQWERTY Avatar asked Dec 20 '18 18:12

userQWERTY


People also ask

Where is MNT in WSL?

When you see /mnt/ in the file path of a WSL command line, it means that you are working from a mounted drive. So the Windows file system C:/ drive ( C:\Users\<user name>\Project ) will look like this when mounted in a WSL command line: /mnt/c/Users/<user name>/Project$ .

Does wsl2 require admin rights?

Administrator privileges in Windows are required to run OpenSSH in WSL. To run an OpenSSH server, run your WSL distribution (ie Ubuntu) or Windows Terminal as an administrator.

Where are WSL images stored?

It's usually in C:\Users\YOURNAME\AppData\Local\Docker\wsl\data and you can often reclaim some of the space if you've cleaned up (pruned your images, etc) with Optimize-Vhd under an administrator PowerShell shell/prompt.


1 Answers

Try copying the ISO file into a folder on your computer (not inside WSL) and then mount the ISO using Windows Explorer. After that, use

sudo mount -t drvfs [drive letter of your ISO]: /where/you/want/to/mount/it 

For you that would be

cp /mnt/a/ubuntu.iso /mnt/[home drive letter, most likely C, lowercase]/wherever/you/want/to/put/it 

Then run explorer.exe, navigate to the folder you copied the ISO to, mount the ISO, record the drive letter, and then type

sudo mount -t drvfs [drive letter of your ISO]: /where/you/want/to/mount/it 

This should give you the same functionality. After that, it will say

mount: /home/vishal/custom-iso/mnt: WARNING: device write-protected, mounted read-only.

This is in WSL 1, not WSL 2, but I suspect that it will work the same way. In fact, I think WSL 2 will be easier to mount the ISO because it is essentially its own self-contained virtual machine. Using Powershell, I was able to mount physical drives to it, so I see no problem with getting an ISO to mount properly in WSL 2

like image 150
Vishal Avatar answered Oct 23 '22 22:10

Vishal