Links
Prepare image
The official image imx6ull-debian-buster-console-armhf-latest-2gb.img has a very small boot partition (40 MiB)
which makes it impossible to upgrade the kernel using apt commands.
Thus, we need to restructure the image in order to make room for upgrades.
First, under linux, we list the partitions:
fdisk -l imx6ull-debian-buster-console-armhf-latest-2gb.img
which will yield something like
Disk imx6ull-debian-buster-console-armhf-latest-2gb.img: 380 MiB, 398458880 bytes, 778240 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: 0x42e3fbe1
Device Boot Start End Sectors Size Id Type
imx6ull-debian-buster-console-armhf-latest-2gb.img1 * 8192 90111 81920 40M e W95 FAT16 (LBA)
imx6ull-debian-buster-console-armhf-latest-2gb.img2 90112 778239 688128 336M 83 Linux
With this information, we can extract the contents of the boot sector and the rootfs partitions to separate files:
dd if=imx6ull-debian-buster-console-armhf-latest-2gb.img of=imx6ull-uboot bs=512 count=8192
dd if=imx6ull-debian-buster-console-armhf-latest-2gb.img of=imx6ull-boot bs=512 skip=8192 count=81920
dd if=imx6ull-debian-buster-console-armhf-latest-2gb.img of=imx6ull-rootfs bs=512 skip=90112 count=688128
The boot partition (DOS filesystem), we need to mount and save the data:
mkdir mnt
sudo mount -o loop,offset=$((8192*512)) imx6ull-debian-buster-console-armhf-latest-2gb.img mnt
tar czf bootdata.tgz mnt/*
sudo umount mnt
Create a new disk image of a larger size, e.g. 512:
dd if=/dev/zero of=./imx6ull-aesrl.img bs=1M count=512
Copy the original boot sector (including the partition table):
dd if=imx6ull-uboot of=imx6ull-aesrl.img bs=512 count=8192 conv=notrunc
Partition the new disk image by deleting the original partitions and create new ones with larger size:
fdisk ./imx6ull-aesrl.img<<EOF
d
1
d
2
n
p
1
8192
270335
n
p
2
270336
a
1
t
1
0e
t
2
83
w
EOF
Mount the boot partition on the new image and copy back the data:
dd if=/dev/zero of=./imx6ull-boot bs=1M count=128
mkfs.fat ./imx6ull-boot
sudo mount -o loop imx6ull-boot mnt
sudo tar xzf bootdata.tgz
sudo umount mnt
Copy the contents of the partitions to the new image:
dd if=imx6ull-boot of=imx6ull-aesrl.img bs=512 seek=270336 conv=notrunc
dd if=imx6ull-rootfs of=imx6ull-aesrl.img bs=512 seek=270336 conv=notrunc
Optionally compress the new image with xz imx6ull-aesrl.img and flash it to the SD card.
When booting up the system, the root filesystem will be resized to maximum size (of the SD card).