I’ve been using ChromeOS on an ARM powered Lenovo Duet for a couple of months now. I must say that I’m not sold on the whole thing, mostly from a stability and access perspective. I can’t even get sublime text to run because of the processor. I am keen to try the OS with an Intel processor, as I think that would fix a lot of compatibility issues, but the stability problems I see, especially on a non dev branch, leaves a lot to be desired.
I’ve had linux crash and burn twice now. The first time I was just getting setup and I think may have been my fault. This time, a crash of the linux container caused LXD to not be accessible. I managed to get into the Termina VM (without the container running) via crosh, but wasn’t able to launch the penguin container or repair LXD.
You may be able to repair LXD if you have root access, which I was not able to obtain. Apparently, the root user has no password by default. A blank password will not work to su root. I believe you can become root if you previously became root and changed the password in the penguin container which may allow you to repair LXD or whatever issue is plaguing the VM. I have not tested this yet and hope I will not have to.
There wasn’t a lot of comprehensive info I found for what to do if Crostini fails to launch and you need to recover files from the image, hence this article.
Install Crosh (optional)
As some readers have mentioned, you can consider this step optional. Crosh is available by default by pressing control + alt + t.
If you can’t get into the penguin container, you won’t be able to access or use any of the native ChromeOS linux backup functionality. Luckily, you should be able to backup the image via crosh.
Setting up crosh is very straightforward. Download the Chrome extension here. You will also need SecureShell installed, which can be downloaded here.
Now press Control + Alt + t to launch crosh.
If you haven’t already, I highly suggest you try recovering by vmc stop termina / vmc start termina in crosh, as well as restarting several times, before proceeding.
Backing up the VM
To create a backup image of the entire linux disk, run the following command. You may want to slim down the size of the disk, making sure you keep it above the amount of data on the disk, in the Chrome OS linux settings menu. The backup will be the entire size available, even if it’s not filled up with data, and you will need about double the space free on your main disk unless you’re planning to use an external drive. Depending on the size of your linux disk, you may need to use an external drive/system anyway.
vmc export termina oldLinux.tar.gz
This will create a file in your Downloads directory in ChromeOS called oldLinux.tar.gz. You can now safely remove linux and reinstall via the ChromeOS menus. We can now move on to the arduous process of finding your files.
Extracting the Image
I ran into trouble here. Something about how the disk was corrupted meant I was unable to use the -z flag in tar.
Try the first command. If it fails, try the following set of commands.
tar -xzvf /mnt/chromeos/MyFiles/Downloads/oldLinux.tar.gz
zcat /mnt/chromeos/MyFiles/Downloads/oldLinux.tar.gz > /mnt/chromeos/MyFiles/Downloads/oldLinux.tar
tar -xvf /mnt/chromeos/MyFiles/Downloads/oldLinux.tar
Now, you should have the uncompressed image in your Downloads folder. You may want to rename it something else for ease of use.
Mount the Image
If you’re able to (which you may not depending on how corrupt the filesystem is) mount the image to access your files.
mount <path-to-image-file> /mnt/chrome
Your files should now be available at /mnt/chrome/lxd/storage-pools/default/containers/penguin/rootfs/home/
If this command fails, you can still use PhotoRec to pull your files out.
PhotoRec
This was my first time recovering files in this way, so there may be a better way to do things. This worked pretty well for me however and I was able to grab everything I needed, even autosaved .swp files of some things.
To install PhotoRec, you’ll need to install testdisk
sudo apt-get install testdisk
photorec <path-to-image-file>
If this fails for some reason, you may want to look at testdisk and see if you can repair the disk enough to continue. Testdisk step by step.
There are a lot of settings you can mess with in PhotoRec if you want to spend less time combing through data or keep the output size small. I only selected txt files (which includes all kinds of txt files) and continued with the other defaults.
More information here on options and setup.
Once PhotoRec completes, you should have a bunch of folders with unhelpfully named files containing everything it was able to pull off your old linux disk.
Finding your files
My needs here were relatively simple. I knew the files I needed and enough of the text they contained to get away with using grep here exclusively.
cd <path-to-photorec-folders-directory>
grep -r "searchterm" .
If you have more sophisticated needs, the PhotoRec wiki has some good information and python scripts for use.
Final Thoughts
That’s about it. Once you find your files, simply move them to the new filesystem.
I will now be automating and making backups for ChromeOS linux and may even abandon ship if things continue to be so unstable with such little effort.