How to extract/decompress cloop images (python version)

I’m working on a little project to multiboot anything and everything unix in the universe on a single media. This is one of the several utilities that I have written to help with that. It’s a python version of the original decompressor for compressed loopback device (cloop). To extract/decompress the cloop image, you can do:

python cloop-decompress ~/tmp/KNOPPIX ~/tmp/KNOPPIX.raw

Now you can loop mount the raw image as you normally would:

mount -o loop ~/tmp/KNOPPIX.raw /mnt
posted by
Mansour
on

Talk with guest OS in VirtualBox through serial port

Setup the serial configuration. Boot the VM. Then run the following to turn the unix socket into a terminal:

socat UNIX-CONNECT:/tmp/com1 PTY,link=/tmp/com1-pty

The above should block for the entire time of the conversation. If it doesn’t, there’s an issue. Fix it!

Then run a terminal program to talk with it:

screen /tmp/com1-pty

As an alternative to using screen, you can use the following in place of socat and screen above:

socat UNIX-CONNECT:/tmp/com1 STDIO,raw,echo=0

VirtualBox Serial Ports configuration page

Serial Port Configuration

Allowing root access to FUSE mounts

There are some places even root can’t get to. One such place is a FUSE mounted volume. I found this out when trying to access an sshfs mounted directory as root and got permission denied.

To get around this, do the following (which I learnt by asking about it on serverfault):

  1. Add user_allow_other to /etc/fuse.conf
  2. Run sshfs (or any other FUSE mounting command) with -o allow_root option.
posted by
Mansour
on

Find own public IP address

Here are a few tricks to programatically find your public IP address:

curl -s http://jsonip.com | sed 's/.*"ip":"\([^"]\+\)".*/\1\n/'
curl -s http://ipinfo.io
posted by
Mansour
on

Merge PDF files

A little ghostscript trick to merge multiple PDF files into one:

gs -q -sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=pdfwrite \
   -sOutputFile=out.pdf in1.pdf in2.pdf in3.pdf ...
posted by
Mansour
on