How to mount openwrt-x86-64-generic-squashfs-combined.img?

Dear OpenWrt folks,

I have an image dump of an image that bases on openwrt-x86-64-generic-squashfs-combined.img and I need to extract some user data from it. Unfortunately, I have difficulties to understand the image layout.

The basic layout is clear to me and I can mount the boot partition as well as the squashfs partition. But the user data is stored in an ext4 filesystem and I don't know how to locate and access it.

# fdisk squashfs-combined-2df1bc5b-f442-4821-8740-191c79c879f3.img 

Command (m for help): p
Disk squashfs-combined-2df1bc5b-f442-4821-8740-191c79c879f3.img: 120 MB, 126353408 bytes, 246784 sectors
15 cylinders, 255 heads, 63 sectors/track
Units: sectors of 1 * 512 = 512 bytes

Device                                                    Boot StartCHS    EndCHS        StartLBA     EndLBA    Sectors  Size Id Type
squashfs-combined-2df1bc5b-f442-4821-8740-191c79c879f3.img1 *  0,8,9       33,0,16            512      33279      32768 16.0M 83 Linux
Partition 1 has different physical/logical end:
     phys=(33,0,16) logical=(2,18,16)
squashfs-combined-2df1bc5b-f442-4821-8740-191c79c879f3.img2    33,8,25     244,13,13        33792     246783     212992  104M 83 Linux
Partition 2 has different physical/logical start (non-Linux?):
     phys=(33,8,25) logical=(2,26,25)
Partition 2 has different physical/logical end:
     phys=(244,13,13) logical=(15,92,13)

Command (m for help):

Binwalk shows that the ext4 filesystem is behind the squashfs filesystem. It seems that both filesystems are located in partiton 2.

#binwalk squashfs-combined-2df1bc5b-f442-4821-8740-191c79c879f3.img 

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
262144        0x40000         Linux EXT filesystem, blocks count: 4096, image size: 4194304, rev 2.0, ext2 filesystem data (mounted or unclean), UUID=84173db5-fa99-e35a-95c6-28613cc73cc7, volume name "kernel"
6389952       0x6180C0        xz compressed data
17301504      0x1080000       Squashfs filesystem, little endian, version 4.0, compression:xz, size: 4333142 bytes, 1400 inodes, blocksize: 262144 bytes, created: 2024-09-23 12:34:46
21692416      0x14B0000       Linux EXT filesystem, blocks count: 102208, image size: 104660992, rev 1.0, ext4 filesystem data, UUID=93b0e514-9ff4-11ef-8fb5-525400120012, volume name "rootfs_data"

Mounting the ext4 filesystem with the offset 21692416 fails.

# mount -o 21692416 squashfs-combined-2df1bc5b-f442-4821-8740-191c79c879f3.img /mnt
mount: mounting /dev/loop38 on /mnt failed: Invalid argument

Do you have a hint how to mount the ext4 filesystem?

write it to a flash drive, boot it, and extract the data you need ?

1 Like

Use binwalk -e -M

Thanks for your quick answers. I forgot to mention that I would like to mount both squashfs and ext4 and apply a OverlayFS in order to replicate the rootfs as OpenWrt would see it.

So extracting the data via binwalk wouldn't work because I see only the differences to the rootfs there.

So, how is OpenWrt detecting and mounting the ext4 filesystem?

the more reason to boot the squashfs, then mount and transfer everything to the ext4.

UUID in grub ?

No mention of mounting anything?
You can boot other OpenWRT in a VM and connect image and mount the root+overlay from that image.

UUID in grub ?

Grub boots the squashfs filesystem from partition 2. The ext4 filesystem will be mounted later. But I don't know how.

You can boot other OpenWRT in a VM and connect image and mount the root+overlay from that image.

I don't think this will work because the squashfs filesystem and ext4 filesystem are located in the same partition. Then we will be in the exact same position that we are already.

Interesting is when I'm dumping the ext4 filesystem via dd the mounting is working fine then.

# dd if=squashfs-combined-2df1bc5b-f442-4821-8740-191c79c879f3.img of=test.img bs=1 skip=$((0x14B0000))
104660992+0 Datensätze ein
104660992+0 Datensätze aus
104660992 Bytes (105 MB, 100 MiB) kopiert, 571,312 s, 183 kB/s
# sudo mount test.img /mnt
# ls /mnt/
upper  work

Update: It was my fault. mount is working. I missed to add offset= to the mount options.

# sudo mount -o offset=21692416 squashfs-combined-2df1bc5b-f442-4821-8740-191c79c879f3.img /mnt
# ls /mnt
upper  work

But the next question is how to get the offset 21692416 (bin) or 0x14B0000 (hex) without binwalk?

Question:

Answer:

There is no problem accessing squashfs, it does not care about what is written after in partition.
You extracted ext4 -> now changed files are in ./upper
And you have mounted squash
Just copy one directories contents over another and you have full picture.
Maybe it goes faster if you tell what you are trying to achieve instead of saying all answers are wrong.

1 Like

Maybe it goes faster if you tell what you are trying to achieve instead of saying all answers are wrong.

I would like to mount the ... generic-squashfs-combined.img for x86_64 and armsr on a Linux system to get the OpenWrt config backup file of .

Anyway, I wrote a shell script that find the offsets for the squashfs start, ext4 startstart and j2fs start, mounts it and adds an overlay to it. If I did more testing with this script, I will share it here.

Both ext4 and jffs2 are nicely extracted using binwalk btw...

Here is the script that mounts openwrt-armsr-armv8-generic-squashfs-combined.img or openwrt-x86-64-generic-squashfs-combined.img filesystem images.

It serves my purpose to run sysupgrade in a chroot environment. Maybe it helps also others.