Expanding OpenWrt squashfs image? (SDcard)

Hi,

I just installed openwrt-19.07.2-sunxi-cortexa7-sun7i-a20-lamobo-r1-squashfs-sdcard.img.gz from

https://openwrt.org/toh/hwdata/lamobo/lamobo_bananapi_r1
https://openwrt.org/toh/lamobo/bananapi_r1

and it works pretty well. Thanks for that really good work. :slight_smile:

But one question remains open:

How to expand the disk space to the sd card size?

There's heaps of descriptions, but none seems applicable. Most descriptions cover the basic scheme (like with raspberry pi and similar devices) to expand the second partition with parted or fdisk and then resize2fs, but that does not work with this image, since the second partition is a squashfs.

What's the recommended procedure to use the full sd card?

regards

The sauashfs partition is read-only and normally you will have a writeable jffs or ext4 partition as writeable overlay.
This one should be resizeable with the common tools.

1 Like

I have the same question. Which partition should i resize?

Sorry, but that reply is useless.

"Should" doesn't help.

I see a vfat on partition 1 and a squashfs on partition 2.

In the running system I see /dev/root mounted as squashfs on /rom,

while on the other hand, /dev/loop0 mounted as f2fs on /overlay where /dev/loop0 is allegedly set to the 'file' /mmcblk0p2, which does not even exist, while /dev/mmcblk0p2 is actually the squashfs.

Something is really, really broken here, path names and device names confused.

I managed to resize the overlay.

The tricky (nasty) part is that there's two filesystems in the second partition. There's a squashfs and right after the squashfs a hidden f2fs. A loopmount with an offset is needed. One needs to install losetup and use it to display the offset on the running system, but I don't know how to tell the offsetz from a given image directly).

Then do the same loop mount on a linux system and do a resize.f2fs.

Why are two filesystems (squashfs and f2fs) put in the same partition? Why doesn't the f2fs have it's own partition?

I just encounter the same problem when installing squashfs images on raspberry pi sdcard, can you explain the detail on how to expand the partition? thank you.

I follow the instructions here with some modification.

  1. Install required PKGs
opkg update && opkg install block-mount kmod-fs-ext4 kmod-usb-storage kmod-usb-ohci kmod-usb-uhci e2fsprogs fdisk
  1. Create new partition, /dev/mmcblk0p3, and reboot
root@Rpi3:~# fdisk /dev/mmcblk0

Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/mmcblk0: 14.43 GiB, 15485370368 bytes, 30244864 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: 0x5452574f

Device         Boot Start    End Sectors  Size Id Type
/dev/mmcblk0p1 *     8192  49151   40960   20M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      57344 581631  524288  256M 83 Linux

Command (m for help): n 
Partition type
   p   primary (2 primary, 0 extended, 2 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (3,4, default 3): 
First sector (2048-30244863, default 2048): 5811632
Last sector, +/-sectors or +/-size{K,M,G,T,P} (5811632-30244863, default 30244863): 

Created a new partition 3 of type 'Linux' and of size 11.7 GiB.

Command (m for help): p
Disk /dev/mmcblk0: 14.43 GiB, 15485370368 bytes, 30244864 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: 0x5452574f

Device         Boot   Start      End  Sectors  Size Id Type
/dev/mmcblk0p1 *       8192    49151    40960   20M  c W95 FAT32 (LBA)
/dev/mmcblk0p2        57344   581631   524288  256M 83 Linux
/dev/mmcblk0p3      5811632 30244863 24433232 11.7G 83 Linux

Command (m for help): w
The partition table has been altered.
Syncing disks.

root@Rpi3:~# reboot
  1. Format new partition
root@Rpi3:~# mkfs.ext4 /dev/mmcblk0p3 
mke2fs 1.44.5 (15-Dec-2018)
Discarding device blocks: done                            
Creating filesystem with 3054154 4k blocks and 764032 inodes
Filesystem UUID: 8f3f385e-2ee5-4618-b2e2-e5be282acef9
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done 
  1. Configuring rootfs_data, extroot, transferring the data and reboot
root@Rpi3:~# DEVICE="/dev/mmcblk0p3"
root@Rpi3:~# eval $(block info "${DEVICE}" | grep -o -e "UUID=\S*")
root@Rpi3:~# uci -q delete fstab.overlay
root@Rpi3:~# uci set fstab.overlay="mount"
root@Rpi3:~# uci set fstab.overlay.uuid="${UUID}"
root@Rpi3:~# uci set fstab.overlay.target="/overlay"
root@Rpi3:~# uci commit fstab
root@Rpi3:~# 
root@Rpi3:~# mount /dev/mmcblk0p3 /mnt
root@Rpi3:~# cp -a -f /overlay/. /mnt
root@Rpi3:~# umount /mnt
root@Rpi3:~# reboot
  1. Preserving software package lists across boots
root@Rpi3:~# sed -i -r -e "s/^(lists_dir\sext\s).*/\1\/usr\/lib\/opkg\/lists/" /etc/opkg.conf
root@Rpi3:~# opkg update

Or, modify /etc/opkg.conf in Web interface

  1. That's it and have a nice day
3 Likes

Hello hc62,
A very big thank you for your great and super helpful tip!
May I point out a small typo?
When specifying the start sector 5811632 you are wasting about 2.5 GB of the SD card because there is a gap of 5,230,000 sectors ...
That's just a minor thing, no question about it!
I just wanted to use this message to express my thanks to you.

regards!

-==[Schubsi]==-


I have tried this approach, but for some reason it keeps mounting the old partition through /dev/loop0 on to /overlay. Has anyone else had success with this? I am using the current snapshot build on a Pi 4.

Using this commands is Linux routine - to those who know how -
but how it goes to access a console in the firmware?
I tried to add the 2nd avail overlay but its gone after a reboot.
And that internal storage (WG 3526 16M) is very tiny. How
much storage in total can such firmware handle?
tempfs on /tmp is 250 MB (wow!) and still empty - no mount/
unmount button avail. Im on 18.06 and the newer rev.'s caused
more troubles so i keep this.

I found this bug related to the problem:

2 Likes

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.