Last active
October 15, 2021 06:35
-
-
Save davidmroth/c3bed9d36b892eea9daeab0ade14b4bf to your computer and use it in GitHub Desktop.
RESIZE SDCARD EXT4 IMAGE
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
#RESIZE SDCARD IMAGE | |
# $ fdisk -l img/2021-05-07-raspios-buster-armhf-lite.img | |
# Disk img/2021-05-07-raspios-buster-armhf-lite.img: 1.76 GiB, 1874853888 bytes, 3661824 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: 0x9730496b | |
# Device Boot Start End Sectors Size Id Type | |
# img/2021-05-07-raspios-buster-armhf-lite.img1 8192 532479 524288 256M c W95 FAT32 (LBA) | |
# img/2021-05-07-raspios-buster-armhf-lite.img2 532480 3661823 3129344 1.5G 83 Linux | |
dd if=/dev/zero of=img/2021-05-07-raspios-buster-armhf-lite.img bs=1 count=1 seek=$((512 * 9388032)) | |
mknod /dev/loop0p1 b 259 0 | |
mknod /dev/loop0p2 b 259 1 | |
losetup --find --show --partscan img/2021-05-07-raspios-buster-armhf-lite.img | |
# Expand FS | |
fdisk /dev/loop0 <<EOF | |
d | |
2 | |
n | |
p | |
2 | |
532480 | |
+3G | |
n | |
w | |
EOF | |
# Deallocate | |
losetup -D | |
# Fix | |
losetup --find --show --partscan img/2021-05-07-raspios-buster-armhf-lite.img | |
e2fsck -f /dev/loop0p2 | |
resize2fs /dev/loop0p2 | |
# $ fdisk -l img/2021-05-07-raspios-buster-armhf-lite.img | |
# Disk img/2021-05-07-raspios-buster-armhf-lite.img: 4.79 GiB, 5120000000 bytes, 10000000 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: 0x9730496b | |
# Device Boot Start End Sectors Size Id Type | |
# img/2021-05-07-raspios-buster-armhf-lite.img1 8192 532479 524288 256M c W95 FAT32 (LBA) | |
# img/2021-05-07-raspios-buster-armhf-lite.img2 532480 9999999 9467520 4.5G 83 Linux |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment