docker-rpi-emu
docker-rpi-emu copied to clipboard
expand rpi image
Hi, I'm trying to expand an existing image (latest raspberry jessie), with these commands adapted from your makefile:
docker run -it --rm --privileged=true -v $PATH_TO_IMAGES:/usr/rpi/images -w /usr/rpi ryankurte/docker-rpi-emu ./expand.sh images/2016-09-23-ra
spbian-jessie-lite.img 4096
[...output...]
The filesystem is already 322048 (4k) blocks long. Nothing to do!
Essentially, I want to compile stuff in a fresh jessie-lite and than write it on SD in qemu, but it doesn't fit the image size as it is.
I'm on mac with Docker.app , version 1.12.1, build 6f9534c
.
Thank you for the nice docker image!
I found a nice way to do it here Resizing a filesystem using qemu-img and fdisk . My disk image is bigger now (~3.3G) and fdisk -l
confirm, but if I boot the system in qemu it says:
df -h /
/bin/df: Warning: cannot read table of mounted file systems: No such file or directory
Filesystem Size Used Avail Use% Mounted on
- 1.2G 813M 316M 73% /
still the original size. Am I missing something?
Have you run resize2fs? You first have to increase the partition size then tell the file system to expand to fill it.
Actually, this is the only point I miss.
Following also this RaspberryPi/qemu-user-static (Debian Wiki) guide, when I do
losetup -f -P --show 2015-11-21-raspbian-jessie.img
This should set up /dev/loop0 as the whole image and /dev/loop0p2 as the partition we're expanding
it doesn't mount the two partitions of the image. I solved mounting explicitly the second partition with an offset to /dev/loop0
:
# fdisk -lu 2016-09-23-raspbian-jessie-lite.img
Disk 2015-11-21-raspbian-jessie.img : 2.3 GiB, 2463105024 bytes, 4810752 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: 0x5a7089a1
Device Boot Start End Sectors Size Id Type
2015-11-21-raspbian-jessie.img1 8192 137215 129024 63M c W95 FAT32 (LBA)
2015-11-21-raspbian-jessie.img2 137216 2713599 2576384 1.2G 83 Linux
# 137216* 512 = 70254592
losetup --offset 70254592 /dev/loop0 2016-09-23-raspbian-jessie-lite.img
now it works
# e2fsck -f /dev/loop0
e2fsck 1.42.13 (17-May-2015)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/loop0: 35460/80640 files (0.1% non-contiguous), 202598/322048 blocks
# resize2fs /dev/loop0
resize2fs 1.42.13 (17-May-2015)
Resizing the filesystem on /dev/loop0 to 584192 (4k) blocks.
The filesystem on /dev/loop0 is now 584192 (4k) blocks long.
I'm working in the ubuntu container you based your image on.
Any clue?
I know this is old, but I just got this working for reference.
dd if=/dev/zero bs=1M count=4096 >> images/2020-02-13-raspbian-buster.img
docker run -it --rm --privileged=true -v $(pwd)/images:/usr/rpi/images \
-w /usr/rpi ryankurte/docker-rpi-emu /bin/bash -c './expand.sh images/2020-02-13-raspbian-buster.img 4096'