Expanding the squashfs file system

I've been looking for a solution to the same problem lately, using the squashfs image for NanoPi R2S. I went through the same tutorial on the wiki as OP, which resulted in the same failed losetup command. Then i stumbled on this thread locating-config-files-on-sd-card/79648 which suggests using losetup with the -f flag instead of -d.

I know close to nothing about loop mounting, but It doesn't make sense to me to (-d = detach) the device i'm trying to mount, as suggested by the wiki. Maybe the -d flag did something else in previous versions of losetup? Hopefully someone who knows more can fill in on this.

Anyway i did the following today, which worked

# at OpenWrt device
root@OpenWrt:~# losetup > losetup-output

# at my laptop running linux i resized the ~100mb partition using cfdisk to a desired size and then did the following

scp root@<openwrt device ip>:/root/losetup-output .
cat losetup-output 
sudo losetup -f -o <offset from losetup-output> /dev/sdX

# above command defaults to a loop device at /dev/loop0
# from here on it's the same as in the wiki instructions

sudo fsck.f2fs /dev/loop0
sudo resize.f2fs /dev/loop0

# i also detached all loop devices with the -D flag according to losetup help before moving the sdcard back to the NanoPi R2S
sudo losetup -D
1 Like