cybernoid / archivemount

A fuse filesystem for mounting archives in formats supported by libarchive.
Other
181 stars 19 forks source link

archivemount can't read .img.gz #25

Open mr-who2012 opened 1 year ago

mr-who2012 commented 1 year ago
# archivemount ./sda2_Linux.img.gz /media/archive -o readonly

Unrecognized archive format

This happens with all gzipped-images on my backup-hdd. p7zip can open these files without problems. The image was created like this:

dd if=/dev/sda2 bs=1M conv=noerror,sync | pv -s50G -cN "sda2" | gzip -c -9 > /media/backup/sda2_Linux.img.gz

Versions:

Linux-Version: Ubuntu Bionic (18.04) archivemount-version 0.9.1 libfuse-version: 2.9.7 libfuse-dev-version: 2.9.7

mxmlnkn commented 1 year ago

Archivemount does not support pure gzip files. It supports gzip-compressed TARs and other archives but not disk images. You can try ratarmount, which can mount even single gzip files and show the contents. But in your case, it will only show the .img file not the actual files on the file system. For that, you would have to mount the .img file again like so:

python3 -m pip install --user ratarmount
ratarmount /media/backup/sda2_Linux.img.gz mounted-gzip-file
mount -o loop mounted-gzip-file/sda2_Linux.img /mnt/disk.img.partition

See also this StackOverflow question.

nabijaczleweli commented 4 weeks ago

abjectly false and an ad; archivemount does this with -o formatraw:

$ gzip -9 < archivemount.c > archivemount.c.gz
$ ./archivemount -o formatraw archivemount.c.gz mnt
$ l mnt/
total 67K
-r--r--r-- 1 nabijaczleweli users 67K 06-16 02:48 data
$ head mnt/data
/*

   Copyright (c) 2005-2018 Andre Landwehr <andrel@cybernoia.de>

   This program can be distributed under the terms of the GNU LGPL.
   See the file COPYING.

   Based on: fusexmp.c and sshfs.c by Miklos Szeredi <miklos@szeredi.hu>

   Contributions by: Niels de Vos <niels@nixpanic.net>
mxmlnkn commented 4 weeks ago

I didn't know that such an option existed. However, when trying out a minimal example, I get this error:

git clone https://github.com/cybernoid/archivemount.git
cd archivemount
autoreconf -i && ./configure && make
./archivemount --version
# archivemount version 0.9.1
# FUSE library version: 2.9.9
# fusermount3 version: 3.10.5
# using FUSE kernel interface version 7.19
echo foo > bar
gzip -k bar
mkdir mnt
./archivemount -o formatraw bar.gz mnt
# ls -lA mounted/
# ls: cannot access 'mounted/bar': Operation not permitted
# total 4
# -????????? ? ?       ?          ?            ? bar
cat mounted/bar
# cat: mounted/bar: Operation not permitted

Interestingly, it only works when compressing the file using your command line gzip -9 < bar > bar2.gz:

./archivemount -o formatraw bar2.gz mnt
ls -lA mnt
# total 1
# -r-x------ 1 user user 4 Jun 16 10:02 data
cat mnt/data
# foo

There also is the difference that the mounted bar.gz shows a file bar, while the over shows a file data. By analyzing the gzip files with rapidgzip --analyze bar.gz, it can be shown that bar.gz contains a file name in the gzip header bar, while bar2.gz does not. It seems that archivemount cannot handle file names in gzip headers.

And yes, I may have been a bit overly eager to share my pet project. I'm sorry about that. Note that there are many other alternatives, such as fuse-archive, fsspec, dissect that similarly improved things over archivemount.

nabijaczleweli commented 4 weeks ago

Yes, and you may recognise this as #18. I've fixed this in archivemount-ng (this specifically is 3409787). As well as all other known bugs. And a plethora of ones no-one else has found. I already got the cnanakos@ co-sign, so expect it in Debian in the coming weeks.