About Blog Contact

Backing Up dual-boot Linux Drive on Windows with WSL

My Linux machine broke down, but its disk is intact. It’s a dual-boot setup with NTFS and ext4 partitions. Since my Windows machine has an extra NVMe M.2 SSD slot, I connected the disk there to back it up.

What my drive looks like in Disk Management
What my drive looks like in Disk Management

I wanted to create a backup of both partitions. My first thought was to use dd, but Windows does not include dd by default. Instead, I discovered VHDX, a virtual hard disk format used by Microsoft. Unlike dd, which performs a raw byte-for-byte disk backup, VHDX operates at the filesystem level, making backups more space-efficient and easier to mount later.

The way to backup the NTFS parition are ext4 partition are different.

Backing Up NTFS Partition

For the NTFS partition, Disk2vhd provides a straightforward solution. It’s a Sysinternals tool that converts an existing partition into a virtual disk (VHD/VHDX). It even allows for a hot backup without requiring the disk to be taken offline. Select the Volume to include and click Create

Disk2vhd interface
Disk2vhd interface

After creating the VHDX, it can be mounted in Windows by simply double clicking on the file.

Backing Up ext4 Partition in WSL

Since Windows does not have dd, an alternative is using Windows Subsystem for Linux (WSL), which supports mounting raw disks.

  1. Identify the Disk

    Run this in PowerShell:

     PS C:\Users\yibai> GET-CimInstance -query "SELECT * from Win32_DiskDrive"
    
     DeviceID           Caption                               Partitions Size          Model
     --------           -------                               ---------- ----          -----
     \\.\PHYSICALDRIVE0 CT2000P5PSSD8                         3          2000396321280 CT2000P5PSSD8
     \\.\PHYSICALDRIVE1 SAMSUNG MZVLB512HBJQ-000L2            5          512105932800  SAMSUNG MZVLB512HBJQ-000L2
    

    This will display all connected drives. Find the DeviceID of the target disk, PHYSICALDRIVE1 in this case.

  2. Mount the Disk in WSL

    Run the following in an Administrator PowerShell window:

     wsl --mount  \\.\PHYSICALDRIVE0--bare
    

    Note: No other process should be using this disk. Once mounted, it will disappear from File Explorer.

  3. Locate the Partition in WSL

    The block device for this disk is now visible in WSL:

     $ lsblk
     NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
     sdd      8:48   0 476.9G  0 disk
     ├─sdd1   8:49   0   260M  0 part
     ├─sdd2   8:50   0    16M  0 part
     ├─sdd3   8:51   0   100G  0 part
     ├─sdd4   8:52   0 190.7G  0 part
     ├─sdd5   8:53   0   185G  0 part
     └─sdd6   8:54   0  1000M  0 part
    

    The partition in question is /dev/sdd4.

  4. Convert to VHDX

    Use qemu-img to create a VHDX file from the ext4 partition:

     sudo qemu-img convert -f raw /dev/sdd4 -O vhdx output.vhdx
    

    This creates a filesystem-level backup, which can later be mounted as a virtual disk.

  5. Unmount the Disk

    After completing the backup, unmount the disk:

     wsl --unmount  \\.\PHYSICALDRIVE0
    

    This makes the drive visible again in Windows.

Restoring & Accessing the Backup

To mount the backup later in WSL:

wsl --mount --vhd /path/to/output.vhdx

Since this is an ext4 filesystem, WSL will automatically mount it under /mnt/wsl, making it accessible.

Alternatively, use qemu to interact with the VHDX file directly.