microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.55k stars 823 forks source link

WSL --import returns Unspecified error #4735

Closed yphillip closed 1 year ago

yphillip commented 4 years ago

I had to get my computer replaced because of a hardware problem, and I backed up my wsl distro in preparation for moving it to the new computer. When I copy the tar file over to the new computer and try wsl --import, I get an Unspecified error.

Windows version / build number

Both computers: Windows [Version 10.0.18362.476]

Steps required to reproduce

On the old computer: wsl --export Ubuntu ubuntu_backup_2019_12_04.tar

On the new computer: Enable WSL (Enable developer mode, turn on WSL in Windows Features) wsl --import Ubuntu C:\Users\yphillip\AppData\Local\Packages\Ubuntu C:\Users\yphillip\wsl_backup\2019_12_04\ubuntu_backup_2019_12_04.tar The only output I get from this is Unspecified error.

The tar file is about 16 GB, and I have no problems sharing it if it might help someone debug my problem. Just let me know. Hoping I can salvage my old setup so I don't have to re-setup everything from scratch on the new computer.

therealkenc commented 4 years ago

Not a fan of the unspecified error myself.

Practical suggestion is to install a fresh distro on your new box. Unpack your tarball there. Cherry pick the stuff you care about, notably your /home. Then apt install your favorite stuff.

yphillip commented 4 years ago

Yeah makes sense, thanks. I've given up on trying to get wsl --import to work (tried Powershell vs cmd, admin vs without admin, all with the same result).

dleslie commented 4 years ago

Please re-open; the underlying issue persists. I am experiencing it on one of my devices.

dleslie commented 4 years ago

Enabling/Disabling the WSL feature doesn't even fix it. Some state is corrupted that doesn't get reset on removal of WSL.

Congee commented 4 years ago

if --import is not supposed to work reliably, what's the point of using it? I have a 56GB tar ball. sigh

yuis-ice commented 4 years ago

same issue here.

antonymarion commented 4 years ago

same error.

Could you please re-open the issue ?

Thks

jbdamiano commented 4 years ago

Same issue here. The import failed

4iter4life commented 4 years ago

same issue here! I understand that wsl2 is in preview.. but why is it so difficult to export just the vhd for wsl2 to make it migratable to new hardware?

kennystrawnmusic commented 4 years ago

Same issue. There was absolutely no reason to close this.

jozefizso commented 4 years ago

wsl --import does not work for me on Windows 10 (release 10.0.19041.207)

torvnen commented 4 years ago

Had this same issue after exporting/importing a fairly new Ubuntu 18.04, with a Windows reset in between.

Fixed the issue by importing(installing) the distribution with LxRunOffline.

Ron2014 commented 4 years ago

Same error.

I'v tried many versions of backups. If the size of imported file ---- ext4.vhdx is under 8G (mine is 7,829,504KB) can work.

Check this out.

Ron

hbhbts commented 4 years ago

Same issue. Is there some update about the bug?

therealkenc commented 4 years ago

Please collect WSL logs and post the backlink to the feedback item here.

nijave commented 4 years ago

You may be able to solve this yourself... Follow the instructions here to start logging https://github.com/microsoft/WSL/blob/2cb110aba644d0bb3ff8d6445448d4e08e11df78/CONTRIBUTING.md#8-detailed-logs

While logman is running, try the import and wait for it to fail Stop logman and open the .etl files. I had Windows Performance Analyzer already installed https://docs.microsoft.com/en-us/windows-hardware/test/wpt/windows-performance-analyzer I opened lxcore_service.etl since it was the biggest--figured there might be something useful

I doubled-clicked the tile in the top left where it says "Generic Events" and was able to get a trace that seems to indicate my particular issue image

This rootfs I generated from the Fedora Live CD rootfs.img using guestfish with xattrs:true so I suppose that did it

nijave commented 4 years ago

Actually to reproduce this shouldn't be too terribly difficult...

I downloaded the Fedora Workstation iso and extracted the squashfs. From that, I extract rootfs.img. I opened that with guestfish and did tar-out-opts / rootfs.tar xattrs:true selinux:true acls:true

Not sure if others are getting the same error, but seems likely depending on how they've tarred up their OS

I also fixed my tar using $ bsdtar --no-xattrs --format=gnutar -cf rootfs2.tar @rootfs.tar (I'm told Windows ships with bsdtar now?). Credit goes to some people in freenode ##linux

Here are the commands I ran (which created the broken tarball)

wget https://download.fedoraproject.org/pub/fedora/linux/releases/32/Workstation/x86_64/iso/Fedora-Workstation-Live-x86_64-32-1.6.iso
isoinfo -i Fedora-Workstation-Live-x86_64-32-1.6.iso -R -x /LiveOS/squashfs.img > squashfs.img
unsquashfs squashfs.img
LIBGUESTFS_BACKEND=direct guestfish -a squashfs-root/LiveOS/rootfs.img <<EOF
launch
mount /dev/sda /
tar-out-opts / rootfs.tar xattrs:true selinux:true acls:true
EOF
jbarrella commented 4 years ago

Had the same issue. I exported two WSL 2 distros and then did a clean install of my Windows OS. "Unspecified error" came up when I tried to import them.

I fixed it by downloading the Linux kernel update package referred to at https://docs.microsoft.com/en-us/windows/wsl/install-win10 and then running the command wsl --set-default-version 2.

After this, my two distros imported without error.

RSpliet commented 4 years ago

@jbarrella Thanks for those hints, this did the trick for me too.

I'm sorry, but I strongly feel like trying to make a point. 16 years ago I abandoned Windows XP in favour of Red Hat 9. My primary motivation back then was that I found it impossible to debug all the random problems that you can encounter: poor error messages, obscure logs, condescending "please contact your administrator" dialogues. Don't get me wrong, Linux back then had many many flaws and shortcomings, but it treated me maturely with log files and descriptive error messages in predictable places. 16 years later and situations like these make me feel like little has improved in Windows-land. "Unspecified error" is next-to-useless. Obviously this is not all the WSL devs' fault (so don't take it personal!), but it is something that genuinely puts me off from trying to use software. I appreciate that errors happen everywhere, but please give me the necessary information and tools to solve them on my own rather than leaving me guessing and trying one after the other random seemingly-unrelated thing I find off the internet.

nijave commented 4 years ago

@jbarrella Thanks for those hints, this did the trick for me too.

It must be something in the air (perhaps COVID), but I strongly feel like trying to make a point. 16 years ago I abandoned Windows XP in favour of Red Hat 9. My primary motivation back then was that I found it impossible to debug all the random problems that you can encounter: poor error messages, obscure logs, condescending "please contact your administrator" dialogues. Don't get me wrong, Linux back then had many many flaws and shortcomings, but it treated me maturely with log files and descriptive error messages in predictable places. 16 years later and situations like these make me feel like little has improved in Windows-land. "Unspecified error" is next-to-useless. Obviously this is not all the WSL devs' fault (so don't take it personal!), but it is something that genuinely puts me off from trying to use software. I appreciate that errors happen everywhere, but please give me the necessary information and tools to solve them on my own rather than leaving me guessing and trying one after the other random seemingly-unrelated thing I find off the internet.

See my comment above--you can use Windows Performance Analyzer https://github.com/microsoft/WSL/issues/4735#issuecomment-708050588

Usually the hex looking 0x00000000 error messages can be looked up in the DLL concerning the functionality although I don't remember off the top of my head

Edit: Here is some info on the hex codes https://blog.sqlauthority.com/2018/07/15/how-to-convert-hex-windows-error-codes-to-the-meaningful-error-message-0x80040002-and-0x80040005-and-others-interview-question-of-the-week-182/

But yeah, not sure why they chose to capture that exception and repackage it as something more generic

mslinn commented 3 years ago

Very unhappy with this problem. I tried @jbarrella's workaround but "Unspecified error" came back. No hex code. Nothing to work with. Seriously, Microsoft, you need to do better than this lame error message!

timkscripts commented 3 years ago

After creating the wslconfig file in my $HOME directory and also checking '/etc/wsl.conf.' inside the TAR file to be sure of no conflicts, setting my RAM etc did not resolve the 'unspecified error' issue. Using logman.exe as noted above didn't populate my etl files either. I have tried every solution in this thread and a few other threads. It turns out I opened my .tar file with 7-zip and it said it was corrupted with no end-of-file. I extracted the TAR and it extracted with 1 error. Data error in ".\version-pack-data...\docker...\diff\binaries\crictl" File is broken.

Unfortunately, re-taring my broken .tar does import after doing wsl --import again, however it does not boot when calling WSL. so its broken. I already unregistered the image after exporting it thinking it was backed up. And I do not see it anymore under the /local/ folders. So, I think I lost my image. I guess its good to learn this lesson early on that if something zips or tars, check it somehow.

teenphly commented 3 years ago

Had this same issue after exporting/importing a fairly new Ubuntu 18.04, with a Windows reset in between.

Fixed the issue by importing(installing) the distribution with LxRunOffline.

Thank you so much! This is the only fix in my case. running LxRunOffline.exe install -n <distro name> -d <installation directory> -f <full path to the tarball> in powershell did the magic.

Afterwards, Ubuntu1804.exe(your distro) config --default-user <user name> sets the right user.

jiceorange commented 3 years ago

Not a fan of the unspecified error myself.

Practical suggestion is to install a fresh distro on your new box. Unpack your tarball there. Cherry pick the stuff you care about, notably your /home. Then apt install your favorite stuff.

I'm also seeing "unspecified". Can you be a bit more detailed about the cherry pick process? Do you mean to hand copy the files into the newly installed distro? What's a safe way to do that that preserves ownership and permissions?

jiceorange commented 3 years ago

Not a fan of the unspecified error myself. Practical suggestion is to install a fresh distro on your new box. Unpack your tarball there. Cherry pick the stuff you care about, notably your /home. Then apt install your favorite stuff.

Oh, you mean unpack it inside of the the newly created distro. Got it.

JackHunt commented 3 years ago

I can confirm that the issue shows with a Gentoo stage3 tarball.

Yogurt4 commented 3 years ago

Having the same problem. Tried all tips, including the ones at the similar issue #4835.

When I did a logging session, WPA showed me that the import failed at one of the ./isocache/...iso files. "Truncated tar archive". However, I could untar the file perfectly.

It seems the problem lays somewhere at the 8 GB working memory limit. My .tar is 7.7 GB, the total file size is 8.4 GB. wsl --import starts to eat memory then suddenly releases all when ~8 GB is reached, and prints the error message.

So I've removed one file from the .tar (to decrease the total file size under 8 GB). Voila! Now it worked. And I added the removed file manually to the new data root.

Kif11 commented 3 years ago

My 25GB tar fails with this error aprox. after unpacking 29GB.

haosmos commented 3 years ago

Exactly the same error: My .tar file weighs 12.7 gb. When the unpacking reaches 13.8gb, the following error occurs: Unspecified error

I applied different memory limit values in .wslconfig: 8gb, 10gb, 16gb, 22gb - nothing works. I have 32gb of RAM and there is a lot of free RAM left when unpacking the archive. But every time unpacking reaches about 13.8gb an Unspecified error is thrown.

ricardoboss commented 3 years ago

I got the same error. To get my WSL back somehow, I used DDoSolitary/LxRunOffline to install it. I didn't specify a version and it actually managed to restore the file system in version 1 (so no .vdhx yet). Then I was able to get WSL to update this WSL instance to version 2. This time, I got a specific error message about some hard links not being available. After I went into the rootfs of the version 1 WSL and deleted said files and folders manually from the Explorer, I tried it again; and voilà! My WSL successfully updated to version two and instead of the rootfs living on NTFS I now got my ext4.vdhx on the correct drive.

MiloDC commented 2 years ago

In case anyone cares, I see this problem of a corrupted .TAR file only when I export a container (docker export) from PowerShell.

When I export from a regular command prompt, it's fine.

hluengas commented 2 years ago

In case anyone cares, I see this problem of a corrupted .TAR file only when I export a container (docker export) from PowerShell.

When I export from a regular command prompt, it's fine.

This fixed it for me!

Importing WSL in powershell... getting unspecified error... tried doing the docker export with CMD instead of powershell, now the import works perfectly!

Marin-Kitagawa commented 2 years ago

I have the same problem while trying to use Gentoo Stage 3 Tarball

Change all the extensions to .etl I started logging and ran the command

wsl --import Gentoo C:\Users\quant\AppData\Local\WSL\Gentoo\ .\stage3-amd64-openrc-20220130T170547Z.tar.xz --version 2

lxcore_service.txt lxcore_user.txt lxcore_kernel.txt

moyans commented 2 years ago

wsl --import Ubuntu-20.04 D:\wsl2_ubuntu\wsl2tar\Ubuntu-20.04.tar --version 2 failed

Please run in the current directory cd D:\wsl2_ubuntu\wsl2tar\ wsl --import Ubuntu-20.04 ./ .\Ubuntu-20.04.tar

Marin-Kitagawa commented 2 years ago

@moyans This didn't work either. The issue still exists

moyans commented 2 years ago

@moyans This didn't work either. The issue still exists

add memory and swap in .wslconfig

image

I tried these two schemes and finally succeeded.

Marin-Kitagawa commented 2 years ago

I solved this problem by doing this (for Gentoo)

  1. Extracted .tar.xz file to get the actual .tar file
  2. Imported using wsl --import Gentoo path\to\Gentoo\WSL\storage path\to\the\tar\file

Now, no errors

adrndev commented 2 years ago

In my case it works while changing from: wsl --import Ubuntu "C:\Users\{userName}" fileName.tar to: wsl --import Ubuntu "C:\Users\{userName}" .\fileName.tar

hakumcentral commented 2 years ago

Unspecified error wins Nothing above worked for me, I think I lost everything I had configured in my wsl instance. I have the TAR, and it is not corrupted, I tried to get logs during the process but after following https://github.com/microsoft/WSL/blob/2cb110aba644d0bb3ff8d6445448d4e08e11df78/CONTRIBUTING.md#8-detailed-logs the files

lxcore_kernel.etl
lxcore_service.etl
lxcore_user.etl

never been filled.

Seems there is a problem with the vdhx size for WSL2, all the time the error came after the vdhx size reaches 256GB, mine is bigger than that. I unregistered the WSL instance after exporting it using the wsl command, I'm not able to compress or try to resize the vdhx to a smaller size.

DON'T try to move your vdhx to another drive if your current one is bigger than 256GB, I tried everything, and looks like there is no solution and no one knows exactly how to solve it. I saw comments on many places that few were able to solve the problem when instances are less than 256Gb.

Importing the instance as WSL1 completes the process but the Ubuntu system now is corrupted and nothing is working as expected, errors are everywhere on almost every command. Trying to set the WSL1 to WSL2 is not working, again fails when the vdhx reaches the 256GB.

Just don't bother yourself trying to move your instance to another ssd/hdd.

0xbillw commented 2 years ago

Same issue here. The import failed: Unspecified error Microsoft Windows [Version 10.0.19044.1706] tar ball size: 175GB

janschristensen commented 2 years ago

I was playing around with making a script that download image and run command "wsl --import".

Some time after download was disabled in the script I started seeing "Unspecified error".

I unregistered and redownloaded the image, and after that it worked again.

soseki-angfa commented 2 years ago

I am having exacty the same issue. But, I am not sure of the same issue or not.

What I did is that I export Ubuntu 20.04 image to my laptop and I import it to different PC today.

Then, it gives me Unspecified error.

Are we not allowed to do this?

I tried followings already. But, it dose not work for me.

wsl –-import Ubuntu2004 %HOMEPATH% Ubuntu-2004.tar
wsl –-import Ubuntu2004 %HOMEPATH% ./Ubuntu-2004.tar
wsl –-import Ubuntu2004 %HOMEPATH% ./Ubuntu-2004.tar --version 2

Also, I checked kernel version as well like wsl --status. Both are the same kernel version.

But, it did not work...

flexchar commented 2 years ago

I've had a .wslconfig with the following contents:

[wsl2]
memory=25GB
swap=0
localhostForwarding=true

after temporarily deleting the file, restarting PC, I was able to successfully import 19GB tar file of Ubuntu distro. Hope that saves someone a few hours!

elhigu commented 2 years ago

As a workaround I was able to do the import (moving system to other location) by importing original 135GB vhdx file directly instead of 95GB .tar file:

wsl --import Ubuntu-20.04-d D:\WSL\Ubuntu-20.04\ C:\Users\user\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState\ext4.vhdx --vhd
OneBlue commented 2 years ago

Thanks everyone who shared logs on this issue.

What appears in most of them are IO errors inside WSL2, with entries like this in dmesg:

3469.886243] blk_update_request: I/O error, dev sde, sector 0 op 0x1:(WRITE) flags 0x800 phys_seg 0 prio class 0 ""
vmId:   {a0eb4f74-c92d-44f3-8a78-d9ebfb49d5dd}"             9336    19336   5       00000000-0000-0000-0000-000000000000        

To help root cause this, the best way would be to collect detailed storvsp logs.

To do this , run (elevated powershell):

curl.exe https://raw.githubusercontent.com/microsoft/WSL/storvsp-logs/diagnostics/wsl_storage.wprp -o profile.wprp
curl.exe https://raw.githubusercontent.com/microsoft/WSL/storvsp-logs/diagnostics/collect-wsl-logs.ps1 -o collect-wsl-logs.ps1 
.\collect-wsl-logs.ps1 -LogProfile .\profile.wprp

If you can reproduce the problem, please collect those detailed logs and share them on this issue.

buliaoyin commented 1 year ago

Unspecified error wins Nothing above worked for me, I think I lost everything I had configured in my wsl instance. I have the TAR, and it is not corrupted, I tried to get logs during the process but after following https://github.com/microsoft/WSL/blob/2cb110aba644d0bb3ff8d6445448d4e08e11df78/CONTRIBUTING.md#8-detailed-logs the files

lxcore_kernel.etl
lxcore_service.etl
lxcore_user.etl

never been filled.

Seems there is a problem with the vdhx size for WSL2, all the time the error came after the vdhx size reaches 256GB, mine is bigger than that. I unregistered the WSL instance after exporting it using the wsl command, I'm not able to compress or try to resize the vdhx to a smaller size.

DON'T try to move your vdhx to another drive if your current one is bigger than 256GB, I tried everything, and looks like there is no solution and no one knows exactly how to solve it. I saw comments on many places that few were able to solve the problem when instances are less than 256Gb.

Importing the instance as WSL1 completes the process but the Ubuntu system now is corrupted and nothing is working as expected, errors are everywhere on almost every command. Trying to set the WSL1 to WSL2 is not working, again fails when the vdhx reaches the 256GB.

Just don't bother yourself trying to move your instance to another ssd/hdd.

Exactly the same situation. A lot of my work in ubuntu lost. Hope feature version could restore my .tar.

I'm thinking make another basic ubuntu distro, then extract my .tar inside. Hope me have luck.

OneBlue commented 1 year ago

/logs

ghost commented 1 year ago

Hello! Could you please provide more logs to help us better diagnose your issue?

To collect WSL logs, download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1

The scipt will output the path of the log file once done.

Once completed please upload the output files to this Github issue.

Click here for more info on logging

Thank you!

buliaoyin commented 1 year ago

Unspecified error wins Nothing above worked for me, I think I lost everything I had configured in my wsl instance. I have the TAR, and it is not corrupted, I tried to get logs during the process but after following https://github.com/microsoft/WSL/blob/2cb110aba644d0bb3ff8d6445448d4e08e11df78/CONTRIBUTING.md#8-detailed-logs the files

lxcore_kernel.etl
lxcore_service.etl
lxcore_user.etl

never been filled. Seems there is a problem with the vdhx size for WSL2, all the time the error came after the vdhx size reaches 256GB, mine is bigger than that. I unregistered the WSL instance after exporting it using the wsl command, I'm not able to compress or try to resize the vdhx to a smaller size. DON'T try to move your vdhx to another drive if your current one is bigger than 256GB, I tried everything, and looks like there is no solution and no one knows exactly how to solve it. I saw comments on many places that few were able to solve the problem when instances are less than 256Gb. Importing the instance as WSL1 completes the process but the Ubuntu system now is corrupted and nothing is working as expected, errors are everywhere on almost every command. Trying to set the WSL1 to WSL2 is not working, again fails when the vdhx reaches the 256GB. Just don't bother yourself trying to move your instance to another ssd/hdd.

Exactly the same situation. A lot of my work in ubuntu lost. Hope feature version could restore my .tar.

I'm thinking make another basic ubuntu distro, then extract my .tar inside. Hope me have luck.

It seems worked, first make a new ubuntu distro, then migrate to new disk, enlarge to 1T, at last extract tar file in the new ubuntu distro to replace all of the files.

ghost commented 1 year ago

This issue has been automatically closed since it has not had any author activity for the past 7 days. If you're still experiencing this issue please re-open it.

Thank you!