DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2011-01-20 23:06:34

dhub
Member
Registered: 2011-01-01
Posts: 112

Strange issue with mksquashfs

I have the following unfinished script, I am running in the debian squeeze chroot environment installed from my alt-f debian.ipk package.  The purpose of the script is to replace the alt-f kernel and the altf-kernel modules in the altf-intrd image with the kernel and kernel modules of the kernel in the debian chroot environment. 

I'm running into an issue rebuilding the squashfs.

Here is the script, so far:
root@nas02:~# cat reviseinitrd.sh
#!/bin/bash
DIR="/root/reviseinitrd"
OLDCWD="`pwd`"
DEPENDS="lzma squashfs-tools"

# Header functions so we can easily see where in the script
# output is coming from
header() {
        echo
        echo "------------------------------------------------------------------------------"
        echo $@
        echo "------------------------------------------------------------------------------"
}

subheader() {
        echo "    ------------------------------------------------------------------------------"
        echo "    $@"
        echo "    ------------------------------------------------------------------------------"



if [ -e "$DIR" ]; then
        header Removing build directory:  $DIR
        rm -r "$DIR"
fi
mkdir "$DIR"
cd "$DIR"

# Determine the initrd files to work with
# TODO write code to find the initrds to work on
INITRD_DEBIAN="/boot/initrd.img-2.6.32-5-orion5x"
INITRD_ALTF="/mnt/sda2/alt-f/rootfs.arm.cpio-sq.lzma"

# Make work directories
header Creating Work Directories
mkdir initrd_debian
mkdir initrd_altf

# Extract the initrds to their respective directories
header Extracting Debian
cd initrd_debian
gunzip -c $INITRD_DEBIAN | cpio -id

header Extracting Alt-F
cd "$DIR/initrd_altf"
lzcat $INITRD_ALTF | cpio -id
subheader Extracting squashfs
mount -t squashfs -o loop "$DIR/initrd_altf/usr.squashfs" "$DIR/initrd_altf/usr"
subheader Copying old squashfs into new work tree
mkdir "$DIR/initrd_altf/new.usr"
cp -a "$DIR/initrd_altf/usr/usr/"* "$DIR/initrd_altf/new.usr"
umount /root/reviseinitrd/initrd_altf/usr

header Copying debian modules into the new altf squashfs tree
cp -a "$DIR/initrd_debian/lib/modules/"* "$DIR/initrd_altf/new.usr/lib/modules/"

header Building new squashfs
mksquashfs "$DIR/initrd_altf/new.usr" "$DIR/initrd_altf/new.usr.squashfs"
#mksquashfs "$DIR/initrd_altf/new.usr/" "$DIR/initrd_altf/new.usr.squashfs" -comp lzma -b 131072 -always-use-fragments -keep-as-directory
mv "$DIR/initrd_altf/usr.squashfs" "$DIR/initrd_altf/old.usr.squashfs"

==========================================================================================================================
Here's the output from running the script:

# deb
root@nas02:~# ./reviseinitrd.sh

------------------------------------------------------------------------------
Removing build directory: /root/reviseinitrd
------------------------------------------------------------------------------

------------------------------------------------------------------------------
Creating Work Directories
------------------------------------------------------------------------------

------------------------------------------------------------------------------
Extracting Debian
------------------------------------------------------------------------------
25379 blocks

------------------------------------------------------------------------------
Extracting Alt-F
------------------------------------------------------------------------------
14381 blocks
    ------------------------------------------------------------------------------
    Extracting squashfs
    ------------------------------------------------------------------------------
    ------------------------------------------------------------------------------
    Copying old squashfs into new work tree
    ------------------------------------------------------------------------------

------------------------------------------------------------------------------
Copying debian modules into the new altf squashfs tree
------------------------------------------------------------------------------

------------------------------------------------------------------------------
Building new squashfs
------------------------------------------------------------------------------
Parallel mksquashfs: Using 1 processor
Creating 4.0 filesystem on /root/reviseinitrd/initrd_altf/new.usr.squashfs, block size 131072.
[==================================================================/] 534/534 100%
Exportable Squashfs 4.0 filesystem, data block size 131072
        compressed data, compressed metadata, compressed fragments
        duplicates are removed
Filesystem size 10649.37 Kbytes (10.40 Mbytes)
        42.40% of uncompressed filesystem size (25113.74 Kbytes)
Inode table size 7143 bytes (6.98 Kbytes)
        31.08% of uncompressed inode table size (22980 bytes)
Directory table size 6600 bytes (6.45 Kbytes)
        51.96% of uncompressed directory table size (12701 bytes)
Number of duplicate files found 0
Number of inodes 663
Number of files 415
Number of fragments 69
Number of symbolic links  139
Number of device nodes 0
Number of fifo nodes 0
Number of socket nodes 0
Number of directories 109
Number of ids (unique uids + gids) 1
Number of uids 1
        root (0)
Number of gids 1
        root (0)

============================================================================
Now here's the problem, at the end of the script I have 2 squashfs filesystems, the original alt-f one called old.usr.squashfs and the new one the script built that has the added debian kernel modules called new.usr.squashfs.

I can mount the old squashfs without a problem:
root@nas02:~/reviseinitrd/initrd_altf# mount -t squashfs -o loop old.usr.squashfs usr
root@nas02:~/reviseinitrd/initrd_altf# umount usr

However, I get an error mounting the new one:
root@nas02:~/reviseinitrd/initrd_altf# mount -t squashfs -o loop new.usr.squashfs usr
mount: /dev/loop1: can't read superblock

So the big question is, does anyone have any idea why the new squashfs isn't working?

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB