Skip to content

Instantly share code, notes, and snippets.

@Lewiscowles1986
Last active November 7, 2015 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lewiscowles1986/b5ce901a48dba3f6d4e6 to your computer and use it in GitHub Desktop.
Save Lewiscowles1986/b5ce901a48dba3f6d4e6 to your computer and use it in GitHub Desktop.
Resizing 8GB Jessie rPi image to 4GB
#!/bin/bash
# Root Check
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
# Get rid of Wolfram
sudo apt-get purge wolfram-engine
# Get rid of Libreoffice :`[
sudo apt-get purge libreoffice*
sudo apt-get purge libreoffice-base libreoffice-impress libreoffice-writer libreoffice-calc libreoffice-draw libreoffice-math
# Clean up a bit
apt-get clean
apt-get autoremove
echo "We are now going to power off your Pi, you'll need another PC for the next bit\r\n"
echo "Press CTRL+C to cancel at this point\r\n"
pause
poweroff
#!/bin/bash
# Root Check
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
if [[ -z "$1" ]]; then
echo "No valid arguments supplied, argument 1 must be block device"
fi
DEVICE = $1
sudo e2fsck -f ${DEVICE}
sudo resize2fs ${DEVICE} 3500M
# Fdisk delete partition 2, then create a new partition 2 from 122880 - 7710719 (figures from http://richardhayler.blogspot.co.uk/2015/10/squeezing-raspbian-jessie-on-to-4gb-sd.html)
fdisk -u -p ${DEVICE} <<EOF
d
2
n
p
2
122880
7710719
w
EOF
echo "We are now going to power down, check your 8GB card still boots (if it doesn't something is wrong)\r\n"
echo "If it reboots, then proceed to the next stage...\r\n"
echo "Press CTRL+C to cancel poweroff at this point\r\n"
pause
poweroff
#!/bin/bash
# Root Check
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
echo "What is the path to the 8GB memory Card?\r\n"
read MEMCARD8
mkdir -p ~/tmp
dd if=${MEMCARD8} of=~/tmp/image4GB-p1.img
dd if=${MEMCARD8} of=~/tmp/image4GB-p2.img
echo "Backed up 8GB, please take this time to eject the 8GB and replace with the 4GB"
pause
echo "What is the path to the 4GB memory Card?\r\n"
read MEMCARD4
dd if=~/tmp/image4GB-p1.img of=${MEMCARD4}
dd if=~/tmp/image4GB-p2.img of=${MEMCARD4}
echo "All done; we should be able to let you power-down, switch to the 4GB memory card, and run Jessie on your rPi\r\n"
@Lewiscowles1986
Copy link
Author

Weird... I Just downloaded Jessie Raspbian and it seems to be < 4GB anyway...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment