Fetch a file from a Clonezilla image without restoring to disk

Dinosaurs are cute

I thought this was neat, but I got the info from a site that presented it in a way that was a bit difficult to decipher, so I wanted to pass it on in a presentation that is easier to understand.

If you’re not using CloneZilla, you’re definitely missing out. It’s a super easy way to clone hard drives, USB thumb drives, etc. into a format that’s easy to restore. It does disk-to-image, disk-to-disk, disk-to-network supporting ssh, nfs and cifs, and even has a p2p cloning framework for two networked computers using CloneZilla live USBs (!)

Needless to say, that’s definitely cool. But what if you want to grab a file out of an archive you’ve already created?

I had made a backup of a client’s computer I wanted to have in case something went south, but I needed to make sure I could get to the files in case I was asked to deliver files while the computer was in a state of (dis)repair.

Well, thankfully that’s pretty easy, since CloneZilla’s default image format is just some gzipped archives. You basically just unzip them into another file, which appears as the raw image file (e.g. .img), which at that point you can mount and traverse like any other mounted drive.

Or, you could (probably) just unzip all the files into a directory, and skip the whole partclone.restore pipe. It’s up to you!

The basic structure of an image is contained inside a directory created by CloneZilla. It looks like this:

$ ls -la
total 55474810
drwxr-xr-x 2 avery avery                  43 May  5 18:57 .
drwxrwxrwx 9 avery administrators         16 May  5 21:36 ..
-rw-r--r-- 1 avery avery                 874 May  5 17:28 blkdev.list
-rw-r--r-- 1 avery avery                 706 May  5 17:28 blkid.list
-rw-r--r-- 1 avery avery               10068 May  5 18:57 clonezilla-img
-rw-r--r-- 1 avery avery                 235 May  5 18:56 dev-fs.list
-rw-r--r-- 1 avery avery                   4 May  5 18:57 disk
-rw-r--r-- 1 avery avery                 482 May  5 18:57 efi-nvram.dat
-rw-r--r-- 1 avery avery                7354 May  5 18:57 Info-dmi.txt
-rw-r--r-- 1 avery avery                 236 May  5 18:57 Info-img-id.txt
-rw-r--r-- 1 avery avery               19252 May  5 18:57 Info-lshw.txt
-rw-r--r-- 1 avery avery                2401 May  5 18:57 Info-lspci.txt
-rw-r--r-- 1 avery avery                 313 May  5 18:57 Info-OS-prober.txt
-rw-r--r-- 1 avery avery                 211 May  5 18:57 Info-packages.txt
-rw-r--r-- 1 avery avery                 114 May  5 18:57 Info-saved-by-cmd.txt
-rw-r--r-- 1 avery avery               10192 May  5 18:57 Info-smart.txt
-rw-r--r-- 1 avery avery                  20 May  5 18:57 parts
-rw------- 1 avery avery            13784650 May  5 17:28 sda1.vfat-ptcl-img.gz.aa
-rw------- 1 avery avery             7477849 May  5 17:28 sda2.dd-ptcl-img.gz.aa
-rw------- 1 avery avery          4096000000 May  5 17:36 sda3.ntfs-ptcl-img.gz.aa
-rw------- 1 avery avery          4096000000 May  5 17:42 sda3.ntfs-ptcl-img.gz.ab
-rw------- 1 avery avery          4096000000 May  5 17:48 sda3.ntfs-ptcl-img.gz.ac
-rw------- 1 avery avery          4096000000 May  5 17:54 sda3.ntfs-ptcl-img.gz.ad
-rw------- 1 avery avery          4096000000 May  5 18:00 sda3.ntfs-ptcl-img.gz.ae
-rw------- 1 avery avery          4096000000 May  5 18:07 sda3.ntfs-ptcl-img.gz.af
-rw------- 1 avery avery          4096000000 May  5 18:13 sda3.ntfs-ptcl-img.gz.ag
-rw------- 1 avery avery          4096000000 May  5 18:19 sda3.ntfs-ptcl-img.gz.ah
-rw------- 1 avery avery          4096000000 May  5 18:25 sda3.ntfs-ptcl-img.gz.ai
-rw------- 1 avery avery          4096000000 May  5 18:32 sda3.ntfs-ptcl-img.gz.aj
-rw-r--r-- 1 avery avery               16384 May  5 17:28 sda-gpt-2nd
-rw-r--r-- 1 avery avery               17920 May  5 17:28 sda-gpt.gdisk
-rw-r--r-- 1 avery avery                 790 May  5 17:28 sda-gpt.sgdisk
-rw-r--r-- 1 avery avery                 512 May  5 17:28 sda-mbr
-rw-r--r-- 1 avery avery                 621 May  5 17:28 sda-pt.parted
-rw-r--r-- 1 avery avery                 551 May  5 17:28 sda-pt.parted.compact
-rw-r--r-- 1 avery avery                 849 May  5 17:28 sda-pt.sf

They’re logically named with tags for partitions, like sda1, sda2, etc. You can see the super huge files are .gz.* files – gzip archives (or zstd, depending on what option you chose) that have to be re-combined to decompress properly, but that’s no big deal.

If you want to save a partition to an image file, make sure you have a copy of partclone installed on your system (e.g. # apt install partclone -y if on a debian-based distro). That’ll automate the restructuring of the partition from the gzip archives.

Make sure you have enough room on whatever drive you’re doing it on for the entire partition (and then some) – might want to du and df first just to be safe.

Note: if you used zstd instead of gzip for the archives, you’ll have to look up the zstd command switches and adapt the one-liner to accommodate the differences in their APIs. I haven’t tried it, but I assume the result should be the same.

Here’s a quick run-down of how the process goes:

# These instructions assume you're in a dir containing the backup dir
$ ls -la
drwxrwxrwx  9 avery                       administrators           16 May  5 21:36  .
drwxr-xr-x  6 root                        root                      7 Mar 23 00:21  ..
-rw-------  1 root                        root               14196736 
drwxr-xr-x  2 avery                       avery                    43 May  5 18:57  laptop-drive-backup 

# create the file that will be your raw image - any name will do
$ touch laptopPartition.img

# pipe the archives to gzip and use partclone to construct the .img 
$ cat ./laptop-drive-backup/sda3.ntfs-ptcl-img.gz.* | gzip -d -c | partclone.restore -C -s - -O ./laptopPartition.img

# then you can mount your .img file as a loop
$ sudo mount -o loop -t ntfs ./laptopPartition.img /mnt/someEmptyDir

# and browse it like anywhere else
$ ls -la /mnt/someEmptyDir # which is now loop-mounted .img file

Another thing to note is that loop mounts are read-only, kind of like mounting an .iso file, or more recently, a snap container. So you can copy stuff off, but you can’t put stuff on. But this is just a copy of your original .gz.* backup anyway, so there’s really no chance in harming the original’s integrity anyway.

It’s always important to conduct yourself with the utmost (file) integrity!

Compiling and installing GitHub’s Hub Utility in msys2

Hub project source code root directory

So I’ve been liking msys2 so far. I’ve replaced the default git install with msys2’s utilities in C:\tools\msys64\usr\bin and they seem to work from Windows command prompt just fine, except for bash, which complains of cygwin1.dll mismatch, but that’s OK, I’ll just run the msys2_shell.cmd which is how it’s intended to be used anyway (inside Mintty – or, alternately ConEmu or defterm). So it’s slightly less flexible (git-bash’s bash.exe could be run from inside a standard cmd.exe terminal), but I’m OK with that since I now have man files in Windows (!) and I can update the utilities using pacman, instead of waiting for updates to come through git-bash updates (I have my doubts that it ever happens).

Why do all of this hacky 3rd-party linux sublayer stuff instead of just enabling Windows Subsystem for Linux (WSL)? Simple: I am fairly certain you cannot run WSL binaries from Windows (please correct me if I’m wrong!).

Continue reading “Compiling and installing GitHub’s Hub Utility in msys2”

man command in Windows possible (?)

Continuing along in my series about how to make Windows more palatable for Linux users, one thing that’s been more difficult to find a workaround for is the man command

For about an hour, I went on a wild goose chase for some sort of alternative in Windows, and found relatively little. I discovered a win32 implementation of mandoc here, which sounds interesting, but I decided not to explore it further than seeing if it’d run (spoiler: it does), since where would I download all the man files for the utilities that were included with git-bash? Sounded like too much of a chore.

Instead, I opted to go with an entirely new shell framework, called msys2. It’s slightly different than git-bash, in that, although both link to cygwin.dll for their tools, it starts logins an entirely new user folder in the C:\tools\msys64\home\user directory, and uses pacman as a package manager. You can supposedly compile tools that are totally win32 compatible with minGW (also included in the installation package) without having to link to cygwin.dll, but I’ve yet to see that in action.

Besides, all I really cared about at the time was getting my man back! Does that sound like you? Are you also a Windows user missing your man? Well, read further!

Continue reading “man command in Windows possible (?)”

More ways to help Linux users hate Windows less

Evil Computer Laptop - Openclipart

Ok, so obviously if you hate Windows, you probably just shouldn’t be using it. But what if you love the way Linux operates, but have a plethora of Windows-only applications you have to have at your fingertips at any moment’s notice?

Here are some ways the discerning Linux user who’s stuck by vendor lock-in can make Windows a little more palatable in the command line:

Continue reading “More ways to help Linux users hate Windows less”

The GRUB prompt: Demystified

Free Computer People Cliparts, Download Free Computer People Cliparts png  images, Free ClipArts on Clipart Library

OK, so practically everyone who uses Linux has come to this menacing prompt at least once or twice. Typically, unless you’re a seasoned sysadmin, it’s a harbinger of death, requiring more than you bargained for to be able to use the computer that day without dire intervention.

But if you know how to navigate the GRUB prompt, you can get back to work just like you were hoping.

These two skills are extremely useful to have in your arsenal of command-line fu, because if you can knowledgably tackle a GRUB prompt in a reasonable amount of time, it can save you hours of headaches and hassle.

So don’t be afraid, embrace the unknown and learn how to navigate GRUB!

Continue reading “The GRUB prompt: Demystified”

Easing pain of migration from Google Hangouts to Google Voice (as much as humanly possible)

Parting Hangouts is not sweet sorrow…

Some of us have been using Hangouts for ages. Essentially since Google recommended we switch from texting with Google Voice way back May of 2013.

Well, now they’ve dropped the hammer again, and said we have to switch back to Google Voice, since for whatever reason they’ve decided to terminate Hangouts altogether.

What gives? I’d been enjoying Hangouts quite a bit, as it fits my workflow perfectly, and had adapted to it in every minute detail through years of experience in daily life.

And now you want to make that all go away?

Continue reading “Easing pain of migration from Google Hangouts to Google Voice (as much as humanly possible)”

PSA: Menus not staying open in Supermicro IPMI? Here’s how to fix it:

I’ve noticed this a couple times in the last week – I had an iKVM window open on my Supermicro host, trying to control the ESXi DCUI, and the menu wouldn’t stay open. It’s very frustrating.

I don’t have a physical monitor hooked up to any of my hosts, so this is a pretty important thing to have working in the event I need to change a setting only available on the “physical” host’s menu.

So, in case you landed on this page because you’re trying to figure out how to fix the same issue, here’s what I discovered:

Continue reading “PSA: Menus not staying open in Supermicro IPMI? Here’s how to fix it:”

Automate kernel module installations for VMware Workstation on your Linux distro

VMWare Archives - The CloudStack Company
VMware Robot does a little dance

Update April 2021: I noticed VMware Workstation 16 in Ubuntu tends to install kernel modules fine through its GUI now, so a lot of this info about how to compile and install vmmon and vmnet is probably obsolete. But since it may be useful to someone using an older version of Workstation, I’ll leave it up for the time being.

In reference to this post I made earlier: https://develmonk.com/2020/10/20/solve-the-system-cannot-find-the-file-specified-error-in-vmware-workstation/

I found the most helpful script, just drop this in a text file called /etc/kernel/install.d/vmmodules.install

Continue reading “Automate kernel module installations for VMware Workstation on your Linux distro”

Solve “The system cannot find the file specified” error in VMware Workstation

If you’ve ever run into this, it’s a real bummer. I encountered it after using rsync to clone a vm.

At the outset, I want to say either using vm -> manage -> clone or file -> export to OVF are both easier options, but if you’ve already copied a vm by hand, you can try this out:

Continue reading “Solve “The system cannot find the file specified” error in VMware Workstation”

PowerBash eases some discomfort of adjusting to PowerShell for Linux users

Want to use grep or vim from your powershell env? Now you can!

OK, I just stumbled across the coolest thing.

Occasionally I use PowerShell because it’s the easiest way to get batch processes accomplished on a Windows computer, or sometimes the only way to implement a feature (e.g. making folders case-sensitive to avoid naming conflicts when syncing with nix computers).

But it’s always a bit of a pain because I have to look up ways to do basic things I can easily do in a POSIX-style environment without needing a reference (e.g. find, grep, sed, df, vim) and sometimes their implementation is awkward or clunky, or just not easily possible.

Enter Powerbash:

Continue reading “PowerBash eases some discomfort of adjusting to PowerShell for Linux users”