Closed sytzemeijer closed 11 months ago
I was using the standard Ubuntu from the app store
If guestmount isn't working, you can try replacing the commands with the traditional mount and umount in image/SConscript (the sh library basically lets you call shell commands as if they were functions in python, you can find more details in the documentation for the sh library ).
Note that guestmount is doing 2 steps here... it is reading the disk image and searching for the partition, and then it is mounting the partition from the disk image. This would be done in 2 steps:
losetup -Pf disk_image
# parse the output of the losetup command to see which /dev/loop<num> device it assigned
mount /dev/loop<num>p0 <mount_directory>
And for unmounting:
umount <mount_directory>
losetup -d /dev/loop<num>
Also note that you will need to run the scons
command with sudo, which isn't great. To make things a bit better, I would change the Default target from here to contain all the other stuff (stage1, stage2, kernel), and only run scons image
with sudo.
While using sudo
is generally not recommended in scripts, I think it is probably fine in this case... It's even better because you only use it with the commands that actually need it.
@chibicitiberiu
I have found another fix for WSL it is to install the linux-image-generic
with sudo apt install linux-image-generic
. found at Álvaro González's comment.
However I have this error libguestfs: error: mount_options: mount_options_stub: /dev/sda1: No such file or directory guestmount: ‘/dev/sda1’ could not be mounted. guestmount: Did you mean to mount one of these filesystems? guestmount: /dev/sda (unknown)
. I don't have a /dev/sda1. Would using /dev/sda overwrite my main partition?
I found a way to address this issue by doing a mount instead. I will post it soon.
I am planning on covering this in a future livestream/video, so I created a gist with the changes that need to be done to fix the problem: https://gist.github.com/chibicitiberiu/6ab664feda5b508cedb35fe4ce62bed3
After modifying the image/SConscript
file, you can use the mountMethod
option in build_scripts/config.py
. The main disadvantage of using mount
instead of guestfs
is it requires typing the sudo password every time the image is built.
Also note that I haven't done a lot of testing, some things might be broken.
I've done it, you can see how in this livestream, the code is in the cpp-refactoring branch,
windows cannot mount the image and wsl2 gives this error