Last active
November 7, 2015 16:14
-
-
Save Lewiscowles1986/b5ce901a48dba3f6d4e6 to your computer and use it in GitHub Desktop.
Resizing 8GB Jessie rPi image to 4GB
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/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 |
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/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 |
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/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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Weird... I Just downloaded Jessie Raspbian and it seems to be < 4GB anyway...