sdm: Error when running inside Docker
First of all, this looks like a great project! As someone who as created much of the code logic here independently, I know how much work was put into this project! Much appreciated!
We are currently using a custom preparation script to modify the pi lite os img pre distribution. We are trying to switch over to using sdm.
However when running sdm inside a docker container, we are getting the following error
* Mount IMG '/user/project/2023-12-11-raspios-bookworm-arm64-lite.img'
mount: /mnt/sdm: special device /dev/loop0p2 does not exist.
? Error mounting IMG '/user/project/2023-12-11-raspios-bookworm-arm64-lite.img'
Is sdm is using loop devices for mounting? It is definitely possible to mount the boot and main partition inside a docker container.
This might be an opportunity to solidify the code used for mounting in sdm. Would appreciate some feedback!
Here is the relevant (working) code from our script:
(code is broken, use this code below instead!)
Expand
# ...
echo "Analysing ISO..."
isoSectorSize=$(fdisk -l $ISO_FULL_PATH | sed -n -e '/^Sector size/p' | grep -o -E '[0-9]+' | head -1 | sed -e 's/^0\+//')
isoBootStart=$(fdisk -l $ISO_FULL_PATH | grep "FAT32" | awk '{print $2}')
isoBootEnd=$(fdisk -l $ISO_FULL_PATH | grep "FAT32" | awk '{print $3}')
isoBootOffset=$(($isoSectorSize*$isoBootStart))
isoBootSizeLimit=$(($isoSectorSize*$isoBootEnd))
isoMainStart=$(fdisk -l $ISO_FULL_PATH | grep "Linux$" | awk '{print $2}')
isoMainEnd=$(fdisk -l $ISO_FULL_PATH | grep "Linux$" | awk '{print $3}')
isoMainOffset=$(($isoSectorSize*$isoMainStart))
isoMainSizeLimit=$(($isoSectorSize*$isoMainEnd))
echo "Mounting Boot Partition..."
sudo mkdir /mnt/boot
sudo mount -v -o offset=$isoBootOffset,sizelimit=$isoBootSizeLimit -t auto $ISO_FULL_PATH /mnt/boot
# ...
echo "Unmounting..."
sudo umount /mnt/boot
sudo rm -rf /mnt/boot
echo "Mounting Main Partition..."
sudo mkdir /mnt/main
sudo mount -v -o offset=$isoMainOffset,sizelimit=$isoMainSizeLimit -t ext4 $ISO_FULL_PATH /mnt/main
# ...
echo "Unmounting..."
sudo umount /mnt/main
sudo rm -rf /mnt/main
# ...
About this issue
- Original URL
- State: closed
- Created 6 months ago
- Comments: 31 (15 by maintainers)
While I understand your point about explicitness, adding
--mount-point
without getting rid of--directory
doesn’t seem like a win to me. It adds yet another thing to test/document/explain with questionable value from my perspective.Someone else mentioned replacing switches with commands. I don’t disagree with the sentiment, but there are other commands that do this. For instance:
dpkg
andupdate-alternatives
.There’s nothing broken because of it and changing it would break literally everyone’s sdm scripts. IOW it’s a “How to piss users off and not create any new value for them” kind of change…Something that a certain company in Redmond has been known to do 🙄.
Thanks! Looks promising. Will have an in-depth look into it.
If you want to continue making progress/further testing of sdm in docker, you could copy the IMG contents to a directory accessible in docker and then use the
--directory
switch. sdm doesn’t use a loop device when mounting a directory.