Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@
cd edu-image
./resize.sh
```
1. A backup of the image will be created in ~/backups that can be used to create new cards if needed.
1. A backup of the image will be created in ~/backups that can be used to create new cards if needed. If you're running this script on a Pi or a Desktop running Raspbian, then you'll need to install pv first:
``` bash
sudo apt-get install pv
```
12 changes: 10 additions & 2 deletions resize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,16 @@ echo "The following filesystems have been found:"
lsblk
read -e -p "Which blockdevice: " -i "mmcblk0" myblkdev
read -e -p "Which partition do you want to shrink: " -i "2" targetpartnr
targetpart="${myblkdev}p${targetpartnr}"

if [ -e /etc/os-release ]
then
echo 'os-release found'
if grep -q Raspbian /etc/os-release; then
echo 'Looks like this is Raspbian'
targetpart="${myblkdev}${targetpartnr}"
else
targetpart="${myblkdev}p${targetpartnr}"
fi
fi
# Unmount directories, otherwise online shrinking from resize2fs would be
# required but this throws an error.
if grep -s "${myblkdev}" /proc/mounts
Expand Down