WSL icon indicating copy to clipboard operation
WSL copied to clipboard

Wsl2 restore after formatting windows

Open GXC2356 opened this issue 3 years ago • 3 comments

Hey guys, how to restore wsl2 after formatting windows?

After formatting only ext4.vhdx is there but distro won't be erased coz windows is formatted, there's important files there and I don't want to lose it I would be thankful if somebody told me a solution

Additional information:

  • ext4 disk is in D drive not c
  • ext4 and distro size is already expanded to 920 gb
  • using Ubuntu 22.04 (in distro itself version is 23.04)

GXC2356 avatar Oct 15 '23 14:10 GXC2356

So to clarify you have the vhd that contains the distro? If so you can use:

    --import-in-place <Distro> <FileName>
        Imports the specified .vhdx file as a new distribution.
        This virtual hard disk must be formatted with the ext4 filesystem type.

You may then need to change your default user via /etc/wsl.conf

[user]
default=username

benhillis avatar Oct 16 '23 17:10 benhillis

So to clarify you have the vhd that contains the distro? If so you can use:

    --import-in-place <Distro> <FileName>
        Imports the specified .vhdx file as a new distribution.
        This virtual hard disk must be formatted with the ext4 filesystem type.

You may then need to change your default user via /etc/wsl.conf

[user]
default=username

Ok thx

GXC2356 avatar Oct 17 '23 00:10 GXC2356

Closing since the issue seems resolved.

OneBlue avatar Oct 19 '23 16:10 OneBlue