PDA

View Full Version : Mounting self-made cloop file - how?



DirkS
03-04-2017, 10:48 PM
I create a cloop file using the following commands:\n XXX\nYYY I

root@Microknoppix:/media/sdc2# ddrescue /dev/sda1 /media/sdc2/sda1_2017-03-04.img ... root@Microknoppix:/media/sdc2# create_compressed_fs -L -1 sda1_2017-03-04.img /media/sdc2/sda1_2017-03-04.cloop ... root@Microknoppix:/media/sdc2# ls -l sda1_2017-03-04.* -rwxrwxrwx 1 knoppix knoppix 266178504 Mär 4 21:35 sda1_2017-03-04.cloop -rwxrwxrwx 1 knoppix knoppix 314572800 Mär 4 21:31 sda1_2017-03-04.img Looks OK. Now I can mount the uncompressed image: root@Microknoppix:/media/sdc2# mkdir /media/img-test /media/cloop-test root@Microknoppix:/media/sdc2# mount -r -o,loop -t ntfs /media/sdc2/sda1_2017-03-01.img /media/img-test/ root@Microknoppix:/media/sdc2# df | grep test /dev/loop0 307196 233384 73812 76% /media/img-test OK. Then I wanted to mount the cloop file... The file itself contains the following lines of script: #!/bin/sh #V2.0 Format modprobe cloop file=$0 && mount -r -t iso9660 /dev/cloop $1 exit $? So I tried: root@Microknoppix:/media/sdc2# modprobe -v cloop file=/media/sdc2/sda1_2017-03-04.cloop which outputs nothing. Did it work so far? No idea. Trying anyway: root@Microknoppix:/media/sdc2# mount -r -t ntfs /dev/cloop /media/cloop-test NTFS signature is missing. Failed to mount '/dev/cloop0': Das Argument ist ungültig The device '/dev/cloop0' doesn't seem to have a valid NTFS. Maybe the wrong device is used? Or the whole disk instead of a partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around? hmmm... root@Microknoppix:/media/sdc2# mount | grep cloop /dev/cloop0 on /KNOPPIX type iso9660 (ro,relatime) /dev/cloop1 on /KNOPPIX1 type iso9660 (ro,relatime) So /dev/cloop0 and /dev/cloop1 are in use (telling me that KNOPPIX itself managed to mount its files just fine. Trying /dev/cloop2 instead: root@Microknoppix:/media/sdc2# mount -r -t ntfs /dev/cloop2 /media/cloop-test Failed to read bootsector (size=0) Failed to mount '/dev/cloop2': Das Argument ist ungültig The device '/dev/cloop2' doesn't seem to have a valid NTFS. Maybe the wrong device is used? Or the whole disk instead of a partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around? This might suggest that the modprobe command silently failed. Trying the losetup method, mentioned in /usr/share/doc/cloop-utils/README: root@Microknoppix:/media/sdc2# losetup /dev/cloop3 /media/sdc2/sda1_2017-03-04.cloop losetup: /dev/cloop3: Loop-Gerät konnte nicht eingerichtet werden: Das Dateisystem ist nur lesbar (Translation: Loop device could not get created. The filesystem is readonly.) Hmmm... root@Microknoppix:/media/sdc2# ls -l /dev/cloop* lrwxrwxrwx 1 root root 6 Mär 4 20:38 /dev/cloop -> cloop0 brw-rw---- 1 root disk 240, 0 Mär 4 20:38 /dev/cloop0 brw-rw---- 1 root disk 240, 1 Mär 4 20:38 /dev/cloop1 brw-rw---- 1 root disk 240, 2 Mär 4 20:38 /dev/cloop2 brw-rw---- 1 root disk 240, 3 Mär 4 20:38 /dev/cloop3 brw-rw---- 1 root disk 240, 4 Mär 4 20:38 /dev/cloop4 brw-rw---- 1 root disk 240, 5 Mär 4 20:38 /dev/cloop5 brw-rw---- 1 root disk 240, 6 Mär 4 20:38 /dev/cloop6 brw-rw---- 1 root disk 240, 7 Mär 4 20:38 /dev/cloop7 root@Microknoppix:/media/sdc2# rm -f /dev/cloop6 root@Microknoppix:/media/sdc2# ll /dev/cloop* lrwxrwxrwx 1 root root 6 Mär 4 20:38 /dev/cloop -> cloop0 brw-rw---- 1 root disk 240, 0 Mär 4 20:38 /dev/cloop0 brw-rw---- 1 root disk 240, 1 Mär 4 20:38 /dev/cloop1 brw-rw---- 1 root disk 240, 2 Mär 4 20:38 /dev/cloop2 brw-rw---- 1 root disk 240, 3 Mär 4 20:38 /dev/cloop3 brw-rw---- 1 root disk 240, 4 Mär 4 20:38 /dev/cloop4 brw-rw---- 1 root disk 240, 5 Mär 4 20:38 /dev/cloop5 root@Microknoppix:/media/sdc2# losetup /dev/cloop6 /media/sdc2/sda1_2017-03-04.cloop losetup: /dev/cloop6: Loop-Gerät konnte nicht eingerichtet werden: Datei oder Verzeichnis nicht gefunden (Translation: Loop device could not get created. File or directory not found.) root@Microknoppix:/media/sdc2# losetup -f /dev/loop0 Why /dev/loop0, that one should be in use! How can I do this? What am I overlooking? It it impossible to do with a poor-man's-installation of Knoppix? Has anyone managed to do this using Knoppix 7.7.1? Please help!

DirkS
03-04-2017, 11:05 PM
WTF. Again:

I create a cloop file using the following commands:

root@Microknoppix:/media/sdc2# ddrescue /dev/sda1 /media/sdc2/sda1_2017-03-04.img
...
root@Microknoppix:/media/sdc2# create_compressed_fs -L -1 sda1_2017-03-04.img /media/sdc2/sda1_2017-03-04.cloop
...
root@Microknoppix:/media/sdc2# ls -l sda1_2017-03-04.*
-rwxrwxrwx 1 knoppix knoppix 266178504 Mär 4 21:35 sda1_2017-03-04.cloop
-rwxrwxrwx 1 knoppix knoppix 314572800 Mär 4 21:31 sda1_2017-03-04.img

Looks OK. Trying to mount the uncompressed image:

root@Microknoppix:/media/sdc2# mkdir /media/img-test /media/cloop-test
root@Microknoppix:/media/sdc2# mount -r -o,loop -t ntfs /media/sdc2/sda1_2017-03-01.img /media/img-test/
root@Microknoppix:/media/sdc2# df | grep test /dev/loop0 307196 233384 73812 76% /media/img-test

OK. Then I wanted to mount the cloop file... The file itself contains the following lines of script:
#!/bin/sh
#V2.0 Format
modprobe cloop file=$0 && mount -r -t iso9660 /dev/cloop $1
exit $?

So I tried:

root@Microknoppix:/media/sdc2# modprobe -v cloop file=/media/sdc2/sda1_2017-03-04.cloop

which outputs nothing. Did it work so far? No idea. Trying anyway:

root@Microknoppix:/media/sdc2# mount -r -t ntfs /dev/cloop /media/cloop-test
NTFS signature is missing. Failed to mount '/dev/cloop0': Das Argument ist ungültig
The device '/dev/cloop0' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?

hmmm...

root@Microknoppix:/media/sdc2# mount | grep cloop
/dev/cloop0 on /KNOPPIX type iso9660 (ro,relatime)
/dev/cloop1 on /KNOPPIX1 type iso9660 (ro,relatime)

So /dev/cloop0 and /dev/cloop1 are in use (telling me that Knoppix itself managed to mount its files just fine. Trying /dev/cloop2 instead:

root@Microknoppix:/media/sdc2# mount -r -t ntfs /dev/cloop2 /media/cloop-test
Failed to read bootsector (size=0)
Failed to mount '/dev/cloop2': Das Argument ist ungültig
The device '/dev/cloop2' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?

This might suggest that the modprobe command silently failed. Trying the losetup method, mentioned in /usr/share/doc/cloop-utils/README:

root@Microknoppix:/media/sdc2# losetup /dev/cloop3 /media/sdc2/sda1_2017-03-04.cloop
losetup: /dev/cloop3: Loop-Gerät konnte nicht eingerichtet werden: Das Dateisystem ist nur lesbar (Translation: Loop device could not get created. The filesystem is readonly.)

Hmmm...

root@Microknoppix:/media/sdc2# ls -l /dev/cloop*
lrwxrwxrwx 1 root root 6 Mär 4 20:38 /dev/cloop -> cloop0
brw-rw---- 1 root disk 240, 0 Mär 4 20:38 /dev/cloop0
brw-rw---- 1 root disk 240, 1 Mär 4 20:38 /dev/cloop1
brw-rw---- 1 root disk 240, 2 Mär 4 20:38 /dev/cloop2
brw-rw---- 1 root disk 240, 3 Mär 4 20:38 /dev/cloop3
brw-rw---- 1 root disk 240, 4 Mär 4 20:38 /dev/cloop4
brw-rw---- 1 root disk 240, 5 Mär 4 20:38 /dev/cloop5
brw-rw---- 1 root disk 240, 6 Mär 4 20:38 /dev/cloop6
brw-rw---- 1 root disk 240, 7 Mär 4 20:38 /dev/cloop7
root@Microknoppix:/media/sdc2# rm -f /dev/cloop6 /dev/cloop7
root@Microknoppix:/media/sdc2# ll /dev/cloop*
lrwxrwxrwx 1 root root 6 Mär 4 20:38 /dev/cloop -> cloop0
brw-rw---- 1 root disk 240, 0 Mär 4 20:38 /dev/cloop0
brw-rw---- 1 root disk 240, 1 Mär 4 20:38 /dev/cloop1
brw-rw---- 1 root disk 240, 2 Mär 4 20:38 /dev/cloop2
brw-rw---- 1 root disk 240, 3 Mär 4 20:38 /dev/cloop3
brw-rw---- 1 root disk 240, 4 Mär 4 20:38 /dev/cloop4
brw-rw---- 1 root disk 240, 5 Mär 4 20:38 /dev/cloop5
root@Microknoppix:/media/sdc2#

They are gone. Doesn't look readonly to me. Anyway:

root@Microknoppix:/media/sdc2# losetup /dev/cloop6 /media/sdc2/sda1_2017-03-04.cloop
losetup: /dev/cloop6: Loop-Gerät konnte nicht eingerichtet werden: Datei oder Verzeichnis nicht gefunden (Translation: Loop device could not get created. File or directory not found.)

root@Microknoppix:/media/sdc2# losetup -f
/dev/loop0

Why /dev/loop0, that one should be in use!

How can I do this? What am I overlooking?
It it impossible to do with a poor-man's-installation of Knoppix?
Has anyone managed to do this using Knoppix 7.7.1?
Please help!

DirkS
03-05-2017, 01:30 AM
Meanwhile I found a way to mount a cloop-image that works under Knoppix 7.0 but not under 7.7.1, so now I suspect that something is broken in 7.7.1.

fredvej
03-05-2017, 11:28 AM
I make a cloop file directly from the mounted file system like this:

$ genisoimage -input-charset ISO-8859-15 -R -l -D -V KNOPPIX_FS -quiet \
-no-split-symlink-components -no-split-symlink-fields \
-hide-rr-moved -cache-inodes /path/to/cloop/filesystem/root/directory \
| create_compressed_fs -q -B 65536 -t 8 -L 9 \
-f /tmp/isotemp - /path/to/created/cloop/file
I don't know if your creation method with ddrescue and create_compressed_fs does the same.
Does the method below work for you?

$ sudo losetup --verbose --read-only /dev/cloop7 /mnt-system/KNOPPIX/KNOPPIX1
losetup: /mnt-system/KNOPPIX/KNOPPIX1: Warning: file does not fit into a 512-byte sector; the end of the file will be ignored.

$ sudo mount --verbose /dev/cloop7 /mnt-user
mount: /dev/cloop7 is write-protected, mounting read-only
mount: /dev/cloop7 mounted on /mnt-user.

$ sudo blkid | grep cloop7
/dev/cloop7: UUID="2016-10-22-16-00-20-00" LABEL="KNOPPIX_ADDONS1" TYPE="iso9660"

$ df | grep cloop7
/dev/cloop7 1033766 1033766 0 100% /mnt-user
Since Knoppix 7 I cannot find a way to detach the cloop device again, so I have to reboot to release the device.

$ sudo umount --verbose /dev/cloop7
umount: /mnt-user (/dev/cloop7) unmounted

$ sudo losetup --verbose --detach /dev/cloop7
losetup: /dev/cloop7: failed to use device: No such device

$ sudo blkid | grep cloop7
/dev/cloop7: UUID="2016-10-22-16-00-20-00" LABEL="KNOPPIX_ADDONS1" TYPE="iso9660"

fredvej
03-05-2017, 11:48 AM
The file system in the cloop file cannot be changed and must be attached as read-only

sudo losetup --verbose --read-only /dev/cloop7 /media/sdc2/sda1_2017-03-04.cloop

DirkS
03-07-2017, 11:27 AM
Just quick: Thank you very much! I'll try these later, some hours later if I can, otherwise tomorrow or next weekend.

The method I tried (twice) on Knoppix 7.0 was, after becoming root:

# mkdir /media/test-cloop
# mount /media/sdc2/sda1_2017-03-04.cloop /media/test-cloop -o loop=/dev/cloop3,ro
I didn't even need to specify the filesystem type.

Also thanks for the confirmation that something is off in 7.7.1. I want to find out where the ability to mount cloop-files on an already running Knoppix (instead of during booting) got lost and I'm on the hunt for older Knoppix versions between 7.0 and 7.7.1. Meanwhile I found some on Sourceforge. Preparations and tests will take some time... As soon as I discover something, I report here.

DirkS
03-12-2017, 10:18 PM
I'm at it.


The method I tried (twice) on Knoppix 7.0 was, after becoming root:

# mkdir /media/test-cloop
# mount /media/sdc2/sda1_2017-03-04.cloop /media/test-cloop -o loop=/dev/cloop3,ro
I didn't even need to specify the filesystem type.

This method also works in 7.3 but fails in 7.4.2, 7.7.0 and 7.7.1
For the following tests I used /media/sr0 as mountpoint instead of creating a directory named /media/test-cloop.
Using the commands that are contained in the cloop file at the beginning, slightly modified:

#modprobe cloop file=/media/sdd2/sda1_2017-03-01.cloop; echo $?
# mount -r -t auto /dev/cloop3 /media/sr0
This works in 7.4.2, even though it took me several tries to find the correct number after /dev/cloop. But this method does not work in 7.7.0 and 7.7.1:

root@Microknoppix:/media/sdd2# mount -r -t auto /dev/cloop3 /media/sr0
mount: /dev/cloop3: Superblock konnte nicht gelesen werden (Translation: Superblock could not get read) Also failed with all other cloop devices.

Your method:

root@Microknoppix:/media/sdd2# losetup --verbose --read-only /dev/cloop6 /media/sdd2/sda1_2017-03-04.cloop
root@Microknoppix:/media/sdd2# mount --verbose /dev/cloop6 /media/sr0
works in 7.7.0. Yay! :D I have to reboot to test it in 7.7.1 and/or older versions, but I wanted to write this post with the results so far first.

By the way, while still being root I was able to do

root@Microknoppix:/media/sde2# df | grep sr0; echo $?
/dev/cloop6 307196 233384 73812 76% /media/sr0
0
root@Microknoppix:/media/sdd2# umount /dev/sr0
root@Microknoppix:/media/sdd2# df | grep sr0; echo $?
1
so umounting as root works for me. But I cannot free/detach /dec/cloop6:

root@Microknoppix:/media/sdd2# losetup --verbose -d /dev/cloop6
losetup: /dev/cloop6: Benutzung des Gerätes ist fehlgeschlagen: Erfolg (Translation: Using the device failed: Success - sorry, that's what it says.)
So indeed, at this point a reboot is required. :-?

DirkS
03-12-2017, 11:09 PM
Wrapping up.


root@Microknoppix:/media/sdd2# losetup --verbose --read-only /dev/cloop6 /media/sdd2/sda1_2017-03-04.cloop
root@Microknoppix:/media/sdd2# mount --verbose /dev/cloop6 /media/sr0
also works in 7.7.1. Double Yay! :D :D So I have a solution for the newest Knoppix. Now I hope that it will still work in the upcoming Knoppix 8.

Is there a way to declare the thread as "solved"?

utu
03-13-2017, 01:45 AM
Is there a way to declare the thread as "solved"?
I suggest you PM Werner P. Schulz to see if this is possible.

DirkS
03-17-2017, 03:46 AM
Thanks, utu, I haven't done this yet, but I'm considering it.

Meanwhile I'm going through the mailing list and found something:

https://lists.debian.org/debian-knoppix/2016/06/msg00000.html - title: "losetup from 7.6.1 can't detach a cloop device" - sounds familiar, isn't it? Seems like this is caused by a change in losetup. Klaus Knopper posted an answer in which he mentioned that he filed a bug report and using the losetup of busybox should work. I can't test that right now, just leaving the info here so it will not get forgotten.