avfs or how to work with compressed usb, cd and hdd images
As I needed to copy a couple of files from the Ubuntu MATE raspberry pi image to my raspberry OS 64bit installation and the steps are a bit obscure I decided to make a quick post about it.
user@linux:~$ sudo apt-get install avfs
step 2 download the image file
user@linux:~$ wget https://releases.ubuntu-mate.org/groovy/arm64/ubuntu-mate-20.10-desktop-arm64+raspi.img.xz
step 3 configure avfs fuse
user@linux:~$ sudo -s root@linux:~# mkdir ~/.avfs root@linux:~# mountavfs Mounting AVFS on /root/.avfs...
step 4 use fdisk and avfs to look in the partion table of the image file without uncompressing it
Note: by adding a # after the filename we tell avfs that the file is an archive and we want to access its content.
avfs determens the compression type by the file extenzion so make sure that's correct (.gz,.7z,.xv, .zip, .rar)
root@linux:~# fdisk -l ~/.avfs/home/user/ubuntu-mate-20.10-desktop-arm64+raspi.img.xz# Disk /root/.avfs/home/user/ubuntu-mate-20.10-desktop-arm64+raspi.img.xz#: 5,6 GiB, 6000000000 bytes, 11718750 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xc0f11707 Device Boot Start End Sectors Size Id Type /root/.avfs/home/user/ubuntu-mate-20.10-desktop-arm64+raspi.img.xz#1 * 2048 524287 522240 255M c W95 FAT32 (LBA) /root/.avfs/home/user/ubuntu-mate-20.10-desktop-arm64+raspi.img.xz#2 524288 11718655 11194368 5,3G 83 Linux
step 5 mount the correct partition (the math is start * sector size)
root@linux mount -t ext4 -ro loop,offset=$((512 * 524288)) ~/.avfs/home/user/ubuntu-mate-20.10-desktop-arm64+raspi.img.xz# /mnt