diff --git a/README.md b/README.md index ffc378f..6008ba5 100644 --- a/README.md +++ b/README.md @@ -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 + ``` diff --git a/resize.sh b/resize.sh index 5903c6f..2b40ae7 100755 --- a/resize.sh +++ b/resize.sh @@ -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