Use growpart instead of parted for auto expanding the image #10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The original backup script works great for storing the SD card contents in a disk image file. However, when I wrote the image back to the new SD card, the filesystem did not automatically expand on the first boot.
The service that runs the auto-expand script on the first boot (
backup-sh/rockpi-backup.sh
Line 105 in 7a464e3
I don't know exactly what seems to be the problem, but it is probably somewhere in these two lines:
backup-sh/rockpi-backup.sh
Lines 130 to 132 in 7a464e3
Both commands run without errors. However,
resizepart ... 100%writes the end of the current partition instead of the end of the available free space - resulting in no changes to the partition size.I found a tool
growpartfrom the Ubuntu packagecloud-guest-utilsthat seems to do a better job (also reported here) and replaced the correspondingpartedline with this command. The only downside of this approach is thatgrowpartmust be installed on the system that is being backed up before the backup.My filesystem expanded automatically on the first boot without any noticeable problems. After the first boot, I removed the SD card from Rock Pi, inserted it into my computer, and ran a filesystem check in GParted. It didn't detect any errors.
Tested with: