The Dirty Hack
NOTE: GParted was NOT used for Expanding the partitions. It was used only to graphically display partition details.
The trick is to set value of variable ROOT_DEV_SIZE in file /usr/lib/raspi-config/init_resize.sh to 4.5 Gb (converted to number of 512 byte blocks). Without this hack, its value is set by script equal to the size of microSD card.
1 - Slipped a 16 Gb microSD card in USB card reader, and pluged card reader to USB slot of Windows Desktop
2 - Wrote piaware image to microSD card by Win32DiskImager
3 - Started Debian 10.3 in VM on Windows, and attached microSd card to VM/Debian
4 - Started Gparted and checked partitions. These were as follows:
5 - Closed Gparted and started File explorer of Debian and clicked on attached devices “boot” and “rootfs”. This mounted the partitions.
6 - Started terminal and gave following command:
abcd@debian10:~$ sudo nano /media/abcd/rootfs/usr/lib/raspi-config/init_resize.sh
When the file opened in nano, pressed Ctrl+W, typed ROOT_DEV_SIZE and pressed Enter key. The cursor jumped to following line:
ROOT_DEV_SIZE=$(cat "/sys/block/${ROOT_DEV_NAME}/size")
TARGET_END=$((ROOT_DEV_SIZE - 1))
Commented out first line and inserted between first & second lines a new line, as shown below:
#ROOT_DEV_SIZE=$(cat "/sys/block/${ROOT_DEV_NAME}/size")
ROOT_DEV_SIZE=$((4500000000/512))
TARGET_END=$((ROOT_DEV_SIZE - 1))
Saved the file and closed the nano editor.
7 - Ejected microSD card from Debian and Windows, slipped into RPI, and performed first boot.
After boot checked partition sizes. The /root partition is only 4Gb:
pi@piaware:~ $ sudo fdisk -l | grep ^Device && sudo fdisk -l | grep ^/dev
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 8192 352900 344709 168.3M c W95 FAT32 (LBA)
/dev/mmcblk0p2 360448 8789061 8428614 4G 83 Linux
8 - Configured piaware. Installed and configured other feeders (Flightradar24, Radarbox24, Planefinder, Adsbexchange, OpenSky), and Wiedehopf’s Performance Graphs.
9 - Shutdown RPi, sliped out microSD card, slipped into Windows computer and attached to VM/Debian10. Fired Gparted and took a screenshot.
10 - Created backup image by Win32DiskImager, which is only 4.4 Gb
11 - Full expansion of microSD card after creating small backup:
11.1 - Closed Gparted and started File explorer of Debian and clicked on attached devices “boot” and “rootfs”. This mounted the partitions.
11.2 - Started terminal and gave following command:
abcd@debian10:~$ sudo nano /media/abcd/rootfs/usr/lib/raspi-config/init_resize.sh
When the file opened in nano, pressed Ctrl+W, typed ROOT_DEV_SIZE and pressed Enter key. The cursor jumped to followingline:
#ROOT_DEV_SIZE=$(cat "/sys/block/${ROOT_DEV_NAME}/size")
ROOT_DEV_SIZE=$((4500000000/512))
TARGET_END=$((ROOT_DEV_SIZE - 1))
Un-commented first line and deleted 2nd line, so it became as shown below (i.e. as it originally was):
ROOT_DEV_SIZE=$(cat "/sys/block/${ROOT_DEV_NAME}/size")
TARGET_END=$((ROOT_DEV_SIZE - 1))
Saved the file and closed the nano editor.
11.3 - Ejected microSD card from Debian and Windows, slipped into RPI, and powered up.
Checked partition sizes. Root partition is only 4 Gb.
pi@piaware:~ $ sudo fdisk -l | grep ^Device && sudo fdisk -l | grep ^/dev
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 8192 352900 344709 168.3M c W95 FAT32 (LBA)
/dev/mmcblk0p2 360448 8789061 8428614 4G 83 Linux
11.4 - Started raspi-config
pi@piaware:~ $ sudo raspi-config
Advance options > Expand File System > Reboot
11.5 - After reboot checked partition sizes. Root partition expanded to full capacity of microSD card
pi@piaware:~ $ sudo fdisk -l | grep ^Device && sudo fdisk -l | grep ^/dev
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 8192 352900 344709 168.3M c W95 FAT32 (LBA)
/dev/mmcblk0p2 360448 30277631 29917184 14.3G 83 Linux










