Expand pi image
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
#sudo bash expand-pi-image.sh <img-file> | |
#sudo setup-chroot.sh <img-file> | |
#run changes and type exit | |
if [ "$1" ]; then | |
real_file_path=`realpath "${1}"` | |
echo "Img File: ${real_file_path}" | |
dd if=/dev/zero bs=1M count=1024 >> $real_file_path | |
sudo kpartx -v -a $real_file_path | |
loop_device=`losetup --list | grep "${real_file_path}" | cut -d ' ' -f1 | cut -d'/' -f3` | |
echo "Loop Device => /dev/${loop_device}" | |
sudo parted --script "/dev/${loop_device}" "resizepart 2 -1s" | |
sudo kpartx -d $real_file_path | |
sudo kpartx -v -a $real_file_path | |
loop_device=`losetup --list | grep "${real_file_path}" | cut -d ' ' -f1 | cut -d'/' -f3` | |
mapper_loop_device="/dev/mapper/${loop_device}p2" | |
echo "Mapper loop device ${mapper_loop_device}" | |
sudo e2fsck -f $mapper_loop_device | |
sudo resize2fs $mapper_loop_device | |
sudo kpartx -d $real_file_path | |
else | |
echo "Please Provide img file" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment