dhruvvyas90 / qemu-rpi-kernel

Qemu kernel for emulating Rpi on QEMU
2.06k stars 363 forks source link

After resizing raw image the filesystem remains 1.5G #113

Closed cmonty14 closed 4 years ago

cmonty14 commented 4 years ago

Hi,

the emulated system shows root filesystem with 1.5GB and 92% used:

pi@raspberrypi:~$ df -hT
Filesystem     Type      Size  Used Avail Use% Mounted on
/dev/root      ext4      1.5G  1.3G  115M  92% /
devtmpfs       devtmpfs  122M     0  122M   0% /dev
tmpfs          tmpfs     122M     0  122M   0% /dev/shm
tmpfs          tmpfs     122M  1.9M  120M   2% /run
tmpfs          tmpfs     5.0M     0  5.0M   0% /run/lock
tmpfs          tmpfs     122M     0  122M   0% /sys/fs/cgroup
/dev/vda1      vfat      253M   54M  199M  22% /boot
tmpfs          tmpfs      25M     0   25M   0% /run/user/1000

In order to increase the filesystem I resize the image using QEMU tools: qemu-img resize 2020-08-20-raspios-buster-armhf-lite.img +10G

The output of fdisk -l confirms the new size, however the partition size remains 1.5GB.

$ fdisk -l 2020-08-20-raspios-buster-armhf-lite.img 
Festplatte 2020-08-20-raspios-buster-armhf-lite.img: 11,72 GiB, 12582912000 Bytes, 24576000 Sektoren
Einheiten: Sektoren von 1 * 512 = 512 Bytes
Sektorgröße (logisch/physikalisch): 512 Bytes / 512 Bytes
E/A-Größe (minimal/optimal): 512 Bytes / 512 Bytes
Festplattenbezeichnungstyp: dos
Festplattenbezeichner: 0x907af7d0

Gerät                                     Boot Anfang    Ende Sektoren Größe Kn Typ
2020-08-20-raspios-buster-armhf-lite.img1        8192  532479   524288  256M  c W95 FAT32 (LBA)
2020-08-20-raspios-buster-armhf-lite.img2      532480 3604479  3072000  1,5G 83 Linux

Can you please advise how to resize the image?

THX

cmonty14 commented 4 years ago

Solved.

For those who are interested in the solution, here are the steps I executed:

1. fdisk 2020-08-20-raspios-buster-armhf-lite.img
2. Delete parition 2
3. Create new partition with starting sector 532480 and ending sector proposed by fdisk
4. kpartx -a -s -v 2020-08-20-raspios-buster-armhf-lite.img
5. e2fsck -f /dev/mapper/loop<n>p2
6. resize2fs /dev/mapper/loop<n>p2
7. kpartx -d 2020-08-20-raspios-buster-armhf-lite.img