May 17, 2019 - Back up a VirtualBox image

Back up a VirtualBox image

What are we trying to achive: A backup of a VirtualBox image with a size as small as possible.

‘Zero’ out the harddisk

As you keep using your virtual machine and writing and deleting things to the virtual harddisk, you’re filling it up with 0’s and 1’s. As you probably know, deleting a file doesn’t delete its binary data, just the file system reference to the data on the disk. Furthermore data chunks with random 0’s and 1’s can’t be compressed very well. So in order to achive a good compression rate, we need to fill up the ‘free’ space with uniform data, e. g. 0’s:

Boot into the virtual machine and run as root:

dd if=/dev/zero of=/tmp/zeros bs=10M
rm /tmp/zeros

This command will write zeros into the file /tmp/zeros until there is not disk space left. Then we delete this file again.

Shutdown the virtual machine.

Compress the virtual harddisk

On the host machine:

Find out where the virtual harddisk (usually [VM_NAME].vdi) file is stored.

Run:

# On Linux:
vboxmanage modifymedium disk /path/to/disk.vdi --compact

# on Windows:
VBoxManage.exe modifymedium disk "C:\path\to\disk.vdi" --compact

Export the virtual machine

Finally in the VirtualBox GUI: ‘Export Appliance’

May 16, 2019 - Search for apt packages

Search for apt packages

Quite often you want to compile or run something and all you get is something like “Error: libXYZ1.2.3.so not found”.

In these cases I usually used

apt-cache search XYZ

in order to find out which package might be missing on my Debian system.

If the package name really contains XYZ then I’d find it. But if libXYZ is actually in package ABC I would not.

A much better tool for this is ‘apt-file’. You’ll probably have to install it. The package like the command is simply called ‘apt-file’.

Then a

apt-file search libXYZ1.2.3.so

will most certainly find the package you have to install in order to get the libXYZ1.2.3.so !

Often apt-file returns a lot of not so useful stuff. If you’re looking for a specific command, try searching for ‘/usr/bin/command’, e.g.

apt-file search /usr/bin/nmap

if you want to know which package contains the nmap tool.

Caveat: apt-file uses your local apt cache. Make sure it’s up-to-date with

apt-get update

May 14, 2019 - Install R and RStudio on Debian 9

Install R and RStudio on Debian 9

This can be real pain… however after a lot of googling I finally figures out how to do it.

Install lastest R version

In your /etc/apt/sources.list add:

deb http://cran.uni-muenster.de/bin/linux/debian stretch-cran35/

(or any other CRAN mirror)

Then import the GPG key of the mirror (in above case it’s gonna be FCAE2A0E115C3D8A):

# most likely have to install 'dirmngr' first:
apt-get install dirmngr

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys FCAE2A0E115C3D8A

Refresh and install latest R version:

apt-get update
apt-get install r-base r-recommended

Install latest nightly build of RStudio

Why do you need the nightly build? Because they’ve still not managed
to get rid off the very annoying libssl.so.1.0.0 dependency in their release builds!

Get the latest build for Debian9+ from: https://dailies.rstudio.com/

Then install it with:

dpkg -i rstudio-*.deb