I am having lots of trouble creating a working Knoppix
CD / filesystem. I can copy the various KNOPPIX/KNOPPIX files
(Knoppix lite, Luit Linux, Feather Linux) from the CD to a hard
drive partition, then boot them by unpacking the boot.img to a directory, configuring lilo
and running lilo, or else by using a boot floppy. However,
if I boot Knoppix from CD, copy the /cdrom/KNOPPIX partition
to (another) HD partition and directory e.g.,
/mnt/hda3/knx/source/KNOPPIX
and use this to make a new "big file", this file is different
from the original and generally (I've had one exception) won't boot.
(I also remade the boot directory and the boot floppy -- no joy.)

To try to get to the bottom of this (and to provide a didactic
tool for other folk that doesn't take a lot of time to run), I
created the following test. This example here was run under
Knoppix 3.3 Beta, booted from a HD partition. The tests were run
in a Reiserfs partition created by Xandros 2.0.

I'd really like to know how to mount my compressed filesystem --
Knoppix complains when I try -- see the /sbin/losetup below.
Any help much appreciated.

J C Nash, U. Ottawa 2004-5-11

Here's the example:

The 'filesystem' in 'rootdir' (under clooptest directory) is

rootdir (directory)
tt
john (directory)
john1
john2
john3
john4
mary (directory)
mary1
mary2
mary3
mary4

All files were small and plain text. They were created from my lilo.conf
file by putting the file name as the first and last line.

The output (comments in [] are NOT part of the output):

root@ttyp0[clooptest]# mkisofs -R rootdir >rootdir.iso
[ rootdir.iso is NOT an image, I just wanted a name for the file. ]
Total translation table size: 0
Total rockridge attributes bytes: 1279
Total directory bytes: 4096
Path table size(bytes): 34
Max brk space used 21224
186 extents written (0 Mb)
root@ttyp0[clooptest]# rm myrootdir
rm: remove regular file
yrootdir'? y
root@ttyp0[clooptest]# alias dir='ls -als'
root@ttyp0[clooptest]# dir
total 2216
1 drwxr-xr-x 4 root root 312 May 8 18:00 .
2 drwxr-xr-x 27 root root 1544 May 8 17:33 ..
1 drwxr-xr-x 4 root root 120 May 6 19:35 rootdir
372 -rw-r--r-- 1 root root 380928 May 8 18:00 rootdir.iso

root@ttyp0[clooptest]# create_compressed_fs rootdir.iso 65536 >rootdir.clp
Block# 0 size 65536 -> 1364 [compression ratio 2%, overall: 2%]
Block# 1 size 65536 -> 435 [compression ratio 0%, overall: 1%]
Block# 2 size 65536 -> 84 [compression ratio 0%, overall: 0%]
Block# 3 size 65536 -> 84 [compression ratio 0%, overall: 0%]
Block# 4 size 65536 -> 84 [compression ratio 0%, overall: 0%]
Partial read (53248 bytes of 65536), padding with zeros.
Block# 5 size 53248 -> 84 [compression ratio 0%, overall: 0%]
Block size 65536, number of blocks 6.
Done.
root@ttyp0[clooptest]# dir
total 392
1 drwxr-xr-x 4 root root 256 May 8 18:02 .
2 drwxr-xr-x 27 root root 1544 May 8 17:33 ..
1 drwxr-xr-x 4 root root 120 May 6 19:35 rootdir
4 -rw-r--r-- 1 root root 2327 May 8 18:02 rootdir.clp
372 -rw-r--r-- 1 root root 380928 May 8 18:00 rootdir.iso

root@ttyp0[clooptest]# mount
/dev/root on / type ext2 (rw)
/dev/cdrom on /cdrom type iso9660 (ro)
/dev/cloop on /KNOPPIX type iso9660 (ro)
/ramdisk on /ramdisk type tmpfs (rw,size=507760k)
usb on /proc/bus/usb type usbdevfs (rw,devmode=0666)
automount(pid706) on /mnt/auto type autofs
(rw,fd=4,pgrp=706,minproto=2,maxproto=4)
/dev/hda3 on /mnt/hda3 type ext3 (rw)
/dev/hdb1 on /mnt/hdb1 type reiserfs (rw)

[ The clooptest directory is on the hdb1 partition ]

[ Try to set up access to the cloop compressed file. ]
root@ttyp0[clooptest]# /sbin/losetup /dev/cloop3 rootdir.clp
ioctl: LOOP_SET_FD: Bad file descriptor

Attempts to expand:


root@ttyp0[clooptest]# dd if=rootdir.clp of=rootdir.exp
4+1 records in
4+1 records out
2327 bytes transferred in 0.000453 seconds (5137195 bytes/sec)
root@ttyp0[clooptest]# dir
total 412
1 drwxr-xr-x 4 root root 352 May 8 18:06 .
2 drwxr-xr-x 27 root root 1544 May 8 17:33 ..
1 drwxr-xr-x 4 root root 120 May 6 19:35 rootdir
4 -rw-r--r-- 1 root root 2327 May 8 18:02 rootdir.clp
4 -rw-r--r-- 1 root root 2327 May 8 18:06 rootdir.exp
372 -rw-r--r-- 1 root root 380928 May 8 18:00 rootdir.iso

[ Clearly did not work, so remove file. ]

root@ttyp0[clooptest]# rm rootdir.exp
rm: remove regular file rootdir.exp'? y

[ Try with extract_compressed_fs ]

root@ttyp0[clooptest]# extract_compressed_fs rootdir.clp >rootdir.exp
6 blocks of size 65536. Preamble:
#!/bin/sh
#V2.0 Format
insmod cloop.o file=$0 && mount -r -t iso9660 /dev/cloop $1
exit $?

Block 0 length 1364 => 65536
Block 1 length 435 => 65536
Block 2 length 84 => 65536
Block 3 length 84 => 65536
Block head:78DAEDC101010000
Block tail:0000000000000000
Block 4 length 84 => 65536
Block 5 length 84 => 65536

root@ttyp0[clooptest]# dir
total 792
1 drwxr-xr-x 4 root root 352 May 8 18:06 .
2 drwxr-xr-x 27 root root 1544 May 8 17:33 ..
1 drwxr-xr-x 4 root root 120 May 6 19:35 rootdir
4 -rw-r--r-- 1 root root 2327 May 8 18:02 rootdir.clp
384 -rw-r--r-- 1 root root 393216 May 8 18:06 rootdir.exp
372 -rw-r--r-- 1 root root 380928 May 8 18:00 rootdir.iso


[Seems it may have worked, but notice the different size.
And everything in one file still.]

[ Made a directory 'expanded', then ...]

root@ttyp0[clooptest]# losetup /dev/loop1 rootdir.exp
root@ttyp0[clooptest]# cp /dev/loop1 expanded/
root@ttyp0[clooptest]# dir expanded
total 385
1 drwxr-xr-x 2 root root 72 May 8 18:10 .
1 drwxr-xr-x 4 root root 352 May 8 18:06 ..
384 -rw------- 1 root root 393216 May 8 18:10 loop1

[ Not what we wanted. ]

root@ttyp0[clooptest]# mount /dev/loop1 /mnt/test

root@ttyp0[clooptest]# cp -Rp /mnt/test/* expanded

[ Works, as confirmed by recursive rm. ]

root@ttyp0[clooptest]# rm -R expanded/*
rm: descend into directory xpanded/john'? y
rm: remove regular file xpanded/john/john1'? y
rm: remove regular file xpanded/john/john2'? y
rm: remove regular file xpanded/john/john3'? y
rm: remove regular file xpanded/john/john4'? y
rm: remove directory xpanded/john'? y
rm: remove regular file xpanded/loop1'? y
rm: descend into directory xpanded/mary'? y
rm: remove regular file xpanded/mary/mary1'? y
rm: remove regular file xpanded/mary/mary2'? y
rm: remove regular file xpanded/mary/mary3'? y
rm: remove regular file xpanded/mary/mary4'? y
rm: remove directory xpanded/mary'? y
rm: remove regular file xpanded/tt'? y