I have an 8GB image that is burned to a 32GB USB drive.
How can I automate this filesystem expansion process? Is there a script I can create to expand the USB correctly and fully? How can I find the exact partition size needed? I noticed when I manually expand the filesystem it only increases the size in /dev/sda2 not /dev/sda1.
1) I have seen a suggestion to use
parted /dev/sda resizepart 1 102400 # resize /dev/sda1 to 100GB
resize2fs /dev/sda1 # resize filesystem
In this method, I am unsure how to calculate the value needed to ensure full expansion. I have used fdisk -l
but unsure how to use the data here for the command above.
2) I have looked at the /usr/bin/raspi-config file and don't fully understand what I need to extract from the --expand-rootfs
section of the file for my needs.
--- RESULTS FROM fdisk -l
---
8GB Image manually expanded on 32GB USB
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 2048 62332927 62330880 29.7G c W95 FAT32 (LBA)
Disk /dev/sda: 28.7 GiB, 30752000000 bytes, 60062500 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x8f1eafaf
Device Boot Start End Sectors Size Id Type
/dev/sda1 8192 131071 122880 60M c W95 FAT32 (LBA)
/dev/sda2 131072 60062499 59931428 28.6G 83 Linux
8GB Image awaiting expansion on 32GB USB
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 8192 62333951 62325760 29.7G c W95 FAT32 (LBA)
Disk /dev/sda: 28.7 GiB, 30752636928 bytes, 60063744 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xb9da48fc
Device Boot Start End Sectors Size Id Type
/dev/sda1 8192 131071 122880 60M c W95 FAT32 (LBA)
/dev/sda2 131072 15523839 15392768 7.3G 83 Linux