SquashFS: modifying rootsquash file

esuhl
esuhl Posts: 9,409 Forumite
Part of the Furniture 1,000 Posts Name Dropper
I have a bootable Linux CD with a rootsquash file in the root directory. I understand that this is a compressed file that contains a file system which is (somehow) unsquashed and mounted during boot.

I want to make some changes to the files contained in the rootsquash file.

I've read the documentation here:
http://tldp.org/HOWTO/SquashFS-HOWTO/mksqoverview.html

And I've managed to unsquash the file, and make the necessary changes. But when I use mksquashfs with default options to create the modified rootsquash file, the CD fails to boot with the message:
Accessing KnoppiXMAME CDROM at /dev/hda...mount: Mounting /cdrom/rootsquash on /KNOPPIX failed: Invalid argument
Can't find KNOPPIX filesystem, sorry.
There seem to be a lot of different options available for mksquashfs. Would anyone know which ones I need to set to get the CD to boot...?

Thanks in advance! :)
«1

Comments

  • debitcardmayhem
    debitcardmayhem Posts: 12,522 Forumite
    Part of the Furniture 10,000 Posts Name Dropper Photogenic
    edited 26 August 2018 at 6:43PM
    Try looking unsquashfs -s to see the block size etc the default blocksize may not be correct (131072)
    Found a valid little endian SQUASHFS 1:0 superblock on /run/media/rob/KnoppiXMAME 1.3b19/rootsquash.
    Creation or last append time Sat May  8 07:17:52 2004
    Filesystem size 114335.76 Kbytes (111.66 Mbytes)
    Block size 32768
    Filesystem is not exportable via NFS
    Inodes are compressed
    Data is compressed
    Check data is not present in the filesystem
    Duplicates are removed
    Number of inodes 19081
    Number of uids 2
    Number of gids 10
    
    4.8kWp 12x400W Longhi 9.6 kWh battery Giv-hy 5.0 Inverter, WSW facing Essex . Aint no sunshine ☀️ Octopus gas fixed dec 24 @ 5.74 tracker again+ Octopus Intelligent Flux leccy
  • esuhl
    esuhl Posts: 9,409 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    edited 27 August 2018 at 2:47AM
    Thanks! I wondered if there was a way to see what settings were used to create the rootsquash file. :)

    [STRIKE]Alas, the unsquashfs -s option shows the block size to be 131072, and all the other settings seem to be the defaults too:[/STRIKE]
    (deleted code)
    
    [STRIKE]I tried specifying the block size with mksquashfs anyway, but (as it seems to be the default setting), the same boot error appeared.[/STRIKE]

    [STRIKE]Any other idea? :o[/STRIKE]
  • debitcardmayhem
    debitcardmayhem Posts: 12,522 Forumite
    Part of the Furniture 10,000 Posts Name Dropper Photogenic
    Erm are you using sudo for both un/mk steps and the other changes?
    4.8kWp 12x400W Longhi 9.6 kWh battery Giv-hy 5.0 Inverter, WSW facing Essex . Aint no sunshine ☀️ Octopus gas fixed dec 24 @ 5.74 tracker again+ Octopus Intelligent Flux leccy
  • esuhl
    esuhl Posts: 9,409 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    Erm are you using sudo for both un/mk steps and the other changes?


    Aw crap -- I'm getting my file versions mixed up. Sorry!


    Let me try again with the right files... :o
  • esuhl
    esuhl Posts: 9,409 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    Hmm... Still not working. :(

    The -le and -be options (to specify little- or big-endian encoding) in the documentation I linked to aren't available in the version of mksquashfs I have installed (v4.0 as opposed to 2.x).

    So I tried:
    # mksquashfs ./squashfs-root ./rootsquash -b 32768 -no-exports
    
    But this creates a 4.0 filesystem (instead of 1.0); there's no mention of it being little-endian (if that matters), and it seems to take user and group IDs (uids/gids) from my PC instead of the ones needed to boot the CD:
    # mksquashfs ./squashfs-root ./rootsquash -b 32768 -no-exports
    Parallel mksquashfs: Using 8 processors
    Creating 4.0 filesystem on ./rootsquash, block size 32768.
    [===========================================================|] 18440/18440 100%
    
    Squashfs 4.0 filesystem, gzip compressed, data block size 32768
        compressed data, compressed metadata, compressed fragments, compressed xattrs
        duplicates are removed
    Filesystem size 113965.89 Kbytes (111.29 Mbytes)
        39.26% of uncompressed filesystem size (290301.41 Kbytes)
    Inode table size 187199 bytes (182.81 Kbytes)
        30.09% of uncompressed inode table size (622084 bytes)
    Directory table size 161054 bytes (157.28 Kbytes)
        42.07% of uncompressed directory table size (382827 bytes)
    Number of duplicate files found 862
    Number of inodes 19389
    Number of files 11832
    Number of fragments 2193
    Number of symbolic links  815
    Number of device nodes 4969
    Number of fifo nodes 3
    Number of socket nodes 0
    Number of directories 1770
    Number of ids (unique uids + gids) 13
    Number of uids 3
        unknown (1001)
        root (0)
        esuhl (1000)
    Number of gids 13
        unknown (1001)
        root (0)
        tty (5)
        unknown (44)
        unknown (15)
        disk (6)
        esuhl (1000)
        anon (43)
        unknown (2000)
        unknown (42)
        games (50)
        unknown (40)
        adm (4)
    




    Until now, I'd been creating a new output file -- by unsquashing the file to a new directory, and squashing the whole directory back to a new (not already existing) file.

    But I tried overwriting the original rootsquash file, and instead mksquashfs tried to append the new content (creating lots of duplicates).

    So I tried pointing mksquashfs to the original rootsquash file, and appending a directory structure containing just the new files I wanted to add. But I get this error:
    # mksquashfs ./squashfs-root ./rootsquash -b 32768 -no-exports
    Filesystem on ./rootsquash is a SQUASHFS 1.0 filesystem.  Appending to SQUASHFS 1.0 filesystems is not supported.  Please convert it to a SQUASHFS 4 filesystem
    Failed to read existing filesystem - will not overwrite - ABORTING!
    To force Mksquashfs to write to this block device or file use -noappend
    
    If I use -noappend, it takes the user/group IDs from my system (and doesn't boot -- always with the same error as before).

    Maybe I should try converting to SquashFS 4, then back to 1.0...? Or try to find an old version of SquashFS v1.0...?
  • I am just about to zzzz but will look again tomorrow, but did you unsquash as root ditto for mksquashfs? Also what have you changed in the rootfs? why not try just add the roms in the roms dir of the ISO sorry buddy am not at my best right now
    4.8kWp 12x400W Longhi 9.6 kWh battery Giv-hy 5.0 Inverter, WSW facing Essex . Aint no sunshine ☀️ Octopus gas fixed dec 24 @ 5.74 tracker again+ Octopus Intelligent Flux leccy
  • esuhl
    esuhl Posts: 9,409 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    I am just about to zzzz but will look again tomorrow, but did you unsquash as root ditto for mksquashfs?

    I did both using sudo. I presume there's no need to su...?
    Also what have you changed in the rootfs? why not try just add the roms in the roms dir of the ISO sorry buddy am not at my best right now

    I'm not adding ROMs -- I can do that successfully now. (yay!) :D

    The ROMS appear as a text list in the GUI. But there's also an option to display them as "tiles" (in-game snapshots). Unfortunately the tiles are blank for all my games. Only the few free ROMs included with KnoppiXMAME have tile images.

    I've explored the CD contents, and found that the free game tile images appear to be compressed in the rootsquash file as /home/snap/<game>.png.

    So I just want to add some more snapshot images to that rootsquashed directory.

    I really appreciate your help, and there's no rush. This is literally just "fun and games"!

    Sleep well... :)

    P.S. The fact that mksquashfs is using the user/group IDs from my system makes me wonder if I need to squash the filesystem from within KnoppiXMAME (which seems impossible)... Could I do something clever with an old version of Knoppix and chroot... or if I'm barking up the wrong tree there...? :-/

    I think I need to sleep on it too... :o Zzzzz....
  • esuhl wrote: »
    I have a bootable Linux CD with a rootsquash file in the root directory. I understand that this is a compressed file that contains a file system which is (somehow) unsquashed and mounted during boot.

    It doesn't need to be unsquashed - the files are uncompressed on the fly by the filesystem support compiled into the kernel.
    Accessing KnoppiXMAME CDROM at /dev/hda...mount: Mounting /cdrom/rootsquash on /KNOPPIX failed: Invalid argument
    Can't find KNOPPIX filesystem, sorry.
    

    ...
    But this creates a 4.0 filesystem (instead of 1.0); there's no mention of it being little-endian (if that matters), and it seems to take user and group IDs (uids/gids) from my PC instead of the ones needed to boot the CD:

    Yeah, that's going to be a problem - IIRC it's a very old kernel you are using, so it won't recognise a squashfs with a version higher than it is expecting. I think the CD gave you the option to drop to a limited shell after it fails to find the filesystem - does that let you ask the kernel questions about level of support or anything ?

    source for versions back to 1.3 are available from http://squashfs.sourceforge.net/
  • esuhl
    esuhl Posts: 9,409 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    It doesn't need to be unsquashed - the files are uncompressed on the fly by the filesystem support compiled into the kernel.

    Well... I needed to unsquash it to examine the file structure to see the path where I need to add the new files.

    But, yes -- now I know the path, it seems that I can add the new files to the existing rootsquash file without needing to unsquash it.
    Yeah, that's going to be a problem - IIRC it's a very old kernel you are using, so it won't recognise a squashfs with a version higher than it is expecting.

    Yeah -- it's Linux 2.6, with SquashFS 1.x, from around 2004.
    I think the CD gave you the option to drop to a limited shell after it fails to find the filesystem - does that let you ask the kernel questions about level of support or anything ?

    The on-screen message says that it'll drop me into a limited shell, but it doesn't. I can type and hit enter, but there's no response or shell prompt. I just see whatever I type.

    The CD is based on Knoppix, but has been stripped of anything that's not needed to boot into GXMAME (a frontend menu for MAME).
    source for versions back to 1.3 are available from http://squashfs.sourceforge.net/

    Thanks -- I think that's my best bet. :) Either that or find an old Linux distro with squashfs-tools preinstalled.

    I've downloaded the source and have been trying to wrap my head round creating a PKGBUILD file (for Arch's package manager).

    Cheers :beer:
  • esuhl
    esuhl Posts: 9,409 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    esuhl wrote: »
    I've downloaded the source and have been trying to wrap my head round creating a PKGBUILD file (for Arch's package manager).

    Hmm... Unless I'm mistaken, building squashfs-tools v1.3 requires a kernel patch provided in the source download... The latest supported kernel being 2.6.1.

    From the INSTALL file:
    1. Patching the kernel


    There are six kernel patch directories depending on your linux kernel version. In each directory there are patches to provide squashfs1.3 release 3 support from a base kernel, and an incremental upgrade patch that upgrades a squashfs1.3r2 patched kernel to a squashfs1.3r3 kernel (except for 2.4.24 and 2.6.1).

    To patch your kernel, cd into the top level directory, and run the "patch" comand, e.g. assuming linux-2.4.20

    %cd /usr/src/linux-2.4.20
    %patch -p1 < location-of-squashfs/linux-2.4.20/squashfs1.3r3-patch

    Where "location-of-squashfs" is the path to the squashfs1.3r3 source directory.

    The squashfs patches patch the relevant kernel files to add configure support, initrd support, include files, and the squashfs directory under linux/fs/. Once patched, the kernel must be reconfigured, with squashfs support turned on (either Y/M) to ensure that inflate support is built into the kernel. The squashfs kernel option can be found in the filesystems submenu of the configure menus. In the 2.6.1 kernel, the squashfs option is hiding in the new miscellaneous filesystems submenu near the bottom of the filesystems submenu.
    So... somehow I need to set up a build system with Linux 2.6.1, patch the kernel, then compile rootsquashfs-tools v1.3 from source...

    Hmmm...
This discussion has been closed.
Meet your Ambassadors

🚀 Getting Started

Hi new member!

Our Getting Started Guide will help you get the most out of the Forum

Categories

  • All Categories
  • 350K Banking & Borrowing
  • 252.7K Reduce Debt & Boost Income
  • 453.1K Spending & Discounts
  • 243K Work, Benefits & Business
  • 619.9K Mortgages, Homes & Bills
  • 176.5K Life & Family
  • 255.9K Travel & Transport
  • 1.5M Hobbies & Leisure
  • 16.1K Discuss & Feedback
  • Read-Only Boards

Is this how you want to be seen?

We see you are using a default avatar. It takes only a few seconds to pick a picture.