# E1 : create a blank image, of the size you want to expand the original (in my example I use 5GB) dd if=/dev/zero of=/path/to/temp_image bs=1048576 count=5000
# E2 : append this to the original image (rasperrypi.img) cat /path/to/temp_image >> /path/to/rasperrypi.img
# E3 : resize the filesystem that lives at the end of the disk (usually this is the one you want bigger) resize2fs -f /path/to/rasperrypi.img
Done! Your disk should now be 5GB bigger!
What we resize is the RASPBIAN partition. Each rasperrypi pi raspbian sdcard is structured with such a structure :
For example, my RBPI2 sdcard is structured like this :
+ Fat16 (0xc) : Contains : windows file and sdcard/os boot process (BIOS equivalent) first physical sector : 8192 last physical sector : 122879 + Ext4 (83) : Contains : raspbian OS, that will be booted first physical sector : 122880 last physical sector : 31152128
Remarque : Ici, les secteurs font 512octets.
⇒ La partition MS-DOS fait (122879-8192)*512=58.719 Mo environ
⇒ La partition RASPBIAN fait (31152128-122880)*512=15.9 Go environ
En effet, mes images de carte SD tenaient sur une clé de 16Go.
Pour aggrandir la partition RASPBIAN, il faut biensur comme prérequis avoir un SDCard qui était dans un RBPI. If you don't have one, use Rufus to burn the existing rasperrypi image (of whole sdcard) on a biggest sdcard.
Plug your sdcard on a linux PC, use GParted to resize Ext4 partition. Once done, put your sdcard back to your RBPI.
OUTFILE=....._backup_sdcard_allparts_mmcblk0p2_et_mmcblk0p1.img ... EMPTY_SPACE_AFTER=1000000 STARTP2=`sudo blockdev --report /dev/mmcblk0p2 | grep /dev/mmcb | sed -e "s/\s\+/ /g" | cut -d' ' -f5` SIZEP2=`sudo blockdev --getsize64 /dev/mmcblk0p2`; COUNT=1000000 SDSIZEINBYTE=$(($STARTP2+$SIZEP2+$EMPTY_SPACE_AFTER)) SDSIZE=$(( $SDSIZEINBYTE/$COUNT )) sudo pv -tpreb /dev/mmcblk0 -s $SDSIZEINBYTE | dd of=$OUTFILE bs=$SDSIZE count=$COUNT
⇒ Constuit une image du disque allant de l'octet 0 à EMPTY_SPACE_AFTER après la fin de la partition /dev/mmcblk0p2.
ou, alors plus simplement :
sudo pv -tpreb /dev/mmcblk0 -s $SDSIZE | dd of=$OUTFILE bs=1M conv=sync,noerror iflag=fullblock
# E1. Install and launch terminal emulator on your smartphone
# E2. resize the linux image (linux.img) (ajoute 1Go) dd if=/dev/zero bs=1048576 count=1000 >> /data/media/0/linux.img # E3. check filesystem e2fsck -f /data/media/0/linux.img
# E4. resize the filesystem resize2fs /data/media/0/linux.img
Done! Your disk should now be 1GB bigger!
On your smartphone, install “SSH server” apk, launch it, and make it listen on port 44444. Make your smartphone connect to your local network (your FAI box).
scp -P 44444 xavier@<IpAndroidPC>:/sdcard/linux.img.orig /home/pi/
ssh -p 44444 xavier@192.168.1.86 cd sdcard rm linux.img.orig
scp -P 44444 /home/pi/linux.img.orig xavier@<IpAndroidPC>:/sdcard/linux.img.orig