Last active
December 20, 2023 18:21
-
-
Save dpavlin/35a952a946b40a51e859 to your computer and use it in GitHub Desktop.
mount Raspberry Pi image, copy qemu-arm-static and chroot into it to tweak it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -xe | |
# mount Raspberry Pi image, copy qemu-arm-static and chroot into it to tweak it | |
dir=/tmp/rpi | |
test "umount" = "$1" && sudo umount $dir/boot && sudo umount $dir | |
image=$1 | |
test -r "$image" || ( echo "Usage: $0 /path/to/rpi.img" && exit 1 ) | |
o_boot=`sudo sfdisk -l $image | grep FAT32 | awk '{ print $2 }'` | |
o_linux=`sudo sfdisk -l $image | grep Linux | awk '{ print $2 }'` | |
echo "mount $o_linux and $o_boot" | |
test -d $dir || mkdir $dir | |
sudo mount -o offset=`expr $o_linux \* 512`,loop $image $dir | |
sudo mount -o offset=`expr $o_boot \* 512`,loop $image $dir/boot | |
test -f $dir/usr/bin/qemu-arm-static || cp `which qemu-arm-static` $dir/usr/bin/ | |
sudo chroot $dir | |
sudo umount $dir/boot | |
sudo umount $dir | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment