Skip to content

Instantly share code, notes, and snippets.

@John2143
Created October 7, 2021 22:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save John2143/0d7160b6ade5881f11db77d752377219 to your computer and use it in GitHub Desktop.
Save John2143/0d7160b6ade5881f11db77d752377219 to your computer and use it in GitHub Desktop.
Mount a wsl2 debian image in arch linux
[18:53 PM] john@arch ~[1]
$ qemu-img create -F vhdx -f qcow2 -o backing_file=/mnt/c/Users/John/debian/ext4.vhdx ./overlay1.qcow2
Formatting './overlay1.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=274877906944 backing_file=/mnt/c/Users/John/debian/ext4.vhdx backing_fmt=vhdx lazy_refcounts=off refcount_bits=16
[18:54 PM] john@arch ~
$ sudo modprobe nbd max_part=8
[18:55 PM] john@arch ~[1]
$ sudo qemu-nbd --connect=/dev/nbd0 ./overlay1.qcow2
[18:55 PM] john@arch ~[1]
$ sudo fdisk -l /dev/nbd0
Disk /dev/nbd0: 256 GiB, 274877906944 bytes, 536870912 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
[18:55 PM] john@arch ~[32]
$ sudo mount /dev/nbd0 /mnt/deb/
[18:55 PM] john@arch ~
$ ls -la /mnt/deb/
drwxr-xr-x - root 2 May 01:12 bin
drwxr-xr-x - root 26 Jun 2018 boot
drwxr-xr-x - root 14 Aug 2018 dev
drwxr-xr-x - root 2 Oct 02:24 etc
drwxr-xr-x - root 11 Nov 2018 home
.rwxr-xr-x 0 root 2 Oct 02:24 init
drwxr-xr-x - root 25 Nov 2020 lib
drwxr-xr-x - root 13 Sep 2020 lib32
drwxr-xr-x - root 13 Sep 2020 lib64
drwx------ - root 10 Apr 2019 lost+found
drwxr-xr-x - root 14 Aug 2018 media
drwxr-xr-x - root 5 Nov 2020 mnt
drwxr-xr-x - root 11 Jun 15:49 opt
drwxr-xr-x - root 26 Jun 2018 proc
drwx------ - root 13 Sep 2020 root
drwxr-xr-x - root 14 Aug 2018 run
drwxr-xr-x - root 13 Apr 17:33 sbin
drwxr-xr-x - root 14 Aug 2018 srv
drwxr-xr-x - root 26 Jun 2018 sys
drwxrwxrwt - root 1 Oct 13:17 tmp
drwxr-xr-x - root 13 Sep 2020 usr
drwxr-xr-x - root 14 Aug 2018 var
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment