Updating to WSL 2 (Ubuntu 20.04) and mounting an image on a Raspberry Pi
June 06, 2020
I want to see the contents of the image of Raspberry, and I tried to mount it with WSL, but it didn’t work.
It is good timing because I am using Windows Sbusystem for Linux recently and WSL2 became an official version.
The Windows Subsystem for Linux BUILD 2020 Summary has a ,
It says that if you are installing WSL for the first time, you just need to
wsl --install to get WSL 2, but that didn’t apply in my case, so I proceeded with the following page.
You must have Windows 10 version 2004 or higher. When I checked, version 2004 is not yet delivered to my PC, so I went to get it myself. You can download it from the Get Windows Update Assistant link.
Once Windows 10 is updated, run the commands as described.
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestartdism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestartwsl --set-default-version 2
When I ran
wsl --set-default-version 2, it said that the WSL 2 Linux kernel needs to be updated, so I downloaded and installed it from Updating the WSL 2 Linux kernel.
wsl --set-default-version 2 again and it passed.
As I already had Ubuntu installed, I ran the following command to change it to WSL 2.
wsl --set-version Ubuntu-20.04 2
It took a few minutes, but it was done.
I tried to mount it as a loopback device, but it didn’t work.
mount -t ext4 -o loop raspbian.img /mnt/imagemount: /mnt/image: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error.
If you specify offset directly, you can mount it.
partx --show raspbian.imgNR START END SECTORS SIZE NAME UUID1 8192 96042 87851 42.9M a50165a4-012 98304 25264127 25165824 12G a50165a4-02
START 98304 multiplied by 512 bytes of sector size will be the value of the offset. In this case, it is
98304 * 512 = 50331648.
It works well when you mount it with this value.
sudo mount -v -t ext4 -o offset=50331648 raspbian.img /mnt/image
Considering the time alone, it was faster to burn it to an SD card and mount it on Linux.