Thursday, October 28, 2021
Mounting a Clonezilla image to a running OS
I have a Clonezilla image of Ubuntu OS and wanted to extract just a directory of important files from it. I'm trying to avoid restoring the whole image into a physical or virtual machine. What I can do is to extract the raw image file from the Clonezilla image itself and mount it onto a running OS. Below are the steps.
Extract the compressed raw image file(s) from the Clonezilla image. The easiest way to do this is by using 7-zip, open and extract under Windows (open and drag). Example below shows that I have 2 partitions stored in my Clonezilla image, "sdb1" & "sdb2". Copy out the compressed raw image partition file that you are interested in. For my case is "sdb2". Note that if you partition is too big, Clonezilla might split it and store more than than 1 file. They are differentiate by the same base name but different extension such as "*.aa", "*.ab" & "*.ac".
Next is to decompress the file by issuing command below. [ ref = link ].
# cat sdb2.ext4-ptcl-img.gz.aa | gzip -d > sdb2.ext4-ptcl-img
If you have more than 1 file, please issue command below. [ref = link ].
# cat sdb2.ext4-ptcl-img.gz.* | gzip -c -d > sdb2.ext4-ptcl-img
Next is to restore the decompressed file back into raw image format. Use "partclone.restore" tool to do this.
# partclone.restore -s sdb2.ext4-ptcl-img -o sdb2.ext4-ptcl-img_restore Partclone v0.2.86 http://partclone.org Starting to restore image (-) to device (file.img) device (file.img) is mounted at error exit
If you encounter error above, it is probably because of the "partclone.restore" version mismatch. On the current OS we have "partclone.restore" v0.2.86. But when the ISO was created with Clonezilla, it was using different version of "partclone" and having incompatibility issue. You can try this trick by find the exact version of the "partclone.restore" copy from the Clonezilla image itself. It turns out for my case the "partclone.restore" version is newer which is v0.3.11.
Copy the "partclone.restore" into the current OS and "chmod +x" it to make it executable. Run the extracted "partclone.restore". Use option -C to disable size checking, -O to override output file if it is already exists and -W to create special raw file for loop device.
#./partclone.restore -C -s sdb2.ext4-ptcl-img -O sdb2.ext4-ptcl-img_restore Partclone v0.3.11 http://partclone.org Starting to restore image (sdb2.ext4-ptcl-img) to device (sdb2.ext4-ptcl-img_restore) Calculating bitmap... Please wait... done! File system: EXTFS Device size: 10.5 GB = 2560000 Blocks Space in use: 6.9 GB = 1695256 Blocks Free Space: 3.5 GB = 864744 Blocks Block size: 4096 Byte Elapsed: 00:00:20, Remaining: 00:00:00, Completed: 100.00%, Rate: 20.83GB/min, current block: 2558079, total block: 2560000, Complete: 100.00% Total Time: 00:00:20, Ave. Rate: 20.8GB/min, 100.00% completed! Syncing... OK! Partclone successfully restored the image (sdb2.ext4-ptcl-img) to the device (sdb2.ext4-ptcl-img_restore) Cloned successfully.
Now try to mount it with "-o loop" and "-t ext4" options.
# mount -o loop -t ext4 sdb2.ext4-ptcl-img_restore temp
If you encounter below error, look for a clue from "/var/log/syslog".
mount: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error In some cases useful info is found in syslog - try dmesg | tail or so.
# tail /var/log/syslog Oct 20 05:10:18 xxx kernel: [34532.566686] EXT4-fs (loop0): bad geometry: block count 2560000 exceeds size of device (2558079 blocks)
I've no exact answer for this but you can refer to this link for more answer on this [ link ]. I believe because of the "sdb2.ext4-ptcl-img_restore" raw image file is not reaching the actual block count of 2560000. Thus from the URL, issue was solved by truncating it to 2560000 with -o option to treat SIZE as number of IO blocks instead of bytes.
# truncate -o -s 2560000 sdb2.ext4-ptcl-img_restore
Now, try to mount again.
# mount -o loop -t ext4 sdb2.ext4-ptcl-img_restore temp
Finnally, the image is now mounted.
# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT loop0 7:0 0 9.8G 0 loop /mnt/disk/temp
Wednesday, October 27, 2021
Ubuntu .desktop file shortcut or launchers not working
I encounter this issue while installing Intel Thermal Analysis Tool (TAT) under Ubuntu 20.04. The desktop launchers seems didn't installed correctly.