PiShrink: PiShrink Fails running in WSL Ubuntu 18.04
I have installed PiShrink on WSL Ubuntu 18.04. I tried to run it with ‘sudo pishrink.sh RPi-backup-Hipot-18-07-19-shrunk.img’ . When I run it I receive the following error.
Kernel not configured for semaphores (System V IPC). Not using udev synchronisation code. losetup: cannot find an unused loop device losetup: : failed to use device: No such device tune2fs: No such file or directory while trying to open Couldn't find valid filesystem superblock. losetup: : failed to use device: No such device mount: /tmp/tmp.vgF8KzVyQs: unknown filesystem type. losetup: : failed to use device: No such device md5sum: /tmp/tmp.vgF8KzVyQs/etc/rc.local: No such file or directory /usr/local/bin/pishrink.sh: line 78: [: !=: unary operator expected umount: /tmp/tmp.vgF8KzVyQs: not mounted. losetup: : failed to use device: No such device ext2fs_check_if_mount: Can't check if filesystem is mounted due to missing mtab file while determining whether is mounted. e2fsck: No such file or directory while trying to open Possibly non-existent device? losetup: : failed to use device: No such device resize2fs 1.44.1 (24-Mar-2018) ext2fs_check_mount_point: Can't check if filesystem is mounted due to missing mtab file while determining whether is mounted. ERROR: Image already shrunk to smallest size losetup: : failed to use device: No such device losetup: : failed to use device: No such device
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 19 (2 by maintainers)
Thanks for sticking with me!
I still see the old kernel (transcript below)
To install the new kernel I simply double clicked the .msi from Windows Explorer, the same as I would for other software. Is that correct? Do I need to do it from a particular directory? Or some different way?
Okay, this we should be able to solve.
I just completed these steps to update my 20.04 WSL installation to the 5.4.72 kernel and re-ran PiShrink to verify it still works.
Debian or Ubuntu (and likely other images) fail in WSL2 with pishrink because pishrink looks for the /etc/mtab file to determine mounts.
Before I explain this, the quick solution (assuming you’ve already mounted the drive where your image is stored) is to create a symlink between the /proc/self/mounts file and /etc/mtab
sudo ln -s /proc/self/mounts /etc/mtabOnce this is done, you should not get the “ext2fs_check_if_mount: Can’t check if filesystem is mounted due to missing mtab file while determining whether /dev/loop0 is mounted” error any more.
You can check my page for this, and the step by step of upgrading to WSL2, installing Debian and PiShrink, mounting a USB drive with the image, the symlink, and running PiShrink if you want more info at: https://news.timekills.info/pishrink-using-windows-10-windows-subsystem-for-linux-2-wsl-2/
Short background: the mtab file (/etc/mtab) is a legacy from Unix to store mounted locations. It was included in many (most) Linux distros to ensure backward compatibility and Posix/Unix compatibility. More recently, most Linux distros create a symlink between the replacement file (/proc/self/mounts) and the legacy /etc/mtab. Windows Subsystem for Linux (1 and 2) do not include that symlink, which is why you must create yourself.