Donnerstag, 29. August 2013

Create Virtual Machine with Windows Guest using Qemu/KVM in Ubuntu Linux


I think Qemu/KVM represents a nice native alternative to Virtualbox or similar. Although all the GUI-tools (like aQemu or Qtemu) are broken in Ubuntu 13.04, it's really easy to setup a VM using the terminal. Precisely, you only need 3 commands to get a running VM:

  1. Create an image, where your VM is installed in. For Windows (>XP) take at least 18Gb:

    qemu-img create -f qcow2 ~/VMs/Windows\ 7/Windows\ 7.qcow2 18G

  2. Install your preferred OS in the created image:

    qemu-system-x86_64 -hda ~/VMs/Windows\ 7/Windows\ 7.qcow2 -cdrom ~/windows7_image_x64_.iso -boot d -m 4096 -cpu kvm64,+nx -enable-kvm

    Explanation for the parameters:
    This launches the typical Windows installation, whereas your new image represents your HDD to install to and -cdrom sets your installation media. The -boot parameter ensures that your VM boots the proper partition (you might can leave it out) and the option -m reserves 4096MB RAM for your VM (adapt it to your system). The -cpu parameter ensures that a 64-Bit CPU is emulated, because it's a KVM CPU you have to enable KVM in Qemu too.
    Note: Adapt the options to your system, especially in case your x86 user!
     
  3. After installation completed, launch your VM with:

    qemu-system-x86_64 ~/VMs/Windows\ 7/Windows\ 7.qcow2 -m 4096 -vga std -enable-kvm -cpu kvm64,+nx

    Of course you need to define the CPU again, enable KVM and set the memory. The option -vga std enables more and higher resolution within your VM, so use it if your are unsatisfied with low resolution.
     
That's it ! Of course you can also Linux VMs with it.

Two additional tips:
  • If your mouse pointer is caged within VM, free it with LEFT-[CTRL]+[ALT]
  • You can reach your Host from the Guest from the IP 10.0.2.2. This might be handy for web developers.

Dienstag, 27. August 2013

Enable Cover-Preview for Audio Files for KDE's Dolphin in Kubuntu 13.04


Unfortunately cover art preview is still not included in KDE (see Bug-report), you can enable that feature by yourself by building and installing the Preview Plugin of RazrFalcon from kde-look.org.

So, if you ever wanted a cover art preview for audio in Dolphin, e.g. like Nautilus has, here's my guide to make it work in Kubuntu (13.04):


  1. Install the necessary dependencies for building:

    sudo apt-get install cmake automake kde-workspace-dev libtag1-dev libqt4-dev libflac++6 libflac++-dev libtag-extras-dev

  2. Get the sources of the plugin:

    wget http://kde-look.org/CONTENT/content-files/145088-AudioThumbs-0.2.tar.gz

  3. and create a folder for it to unpack it:

    mkdir ~/audiothumbs;
    tar -zxvf 145088-AudioThumbs-0.2.tar.gz -C ~/audiothumbs


  4. Cd into the folder with sources and create a build dir and cd into it:

    cd ~/audiothumbs; mkdir build; cd build

  5. Now prepare building with cmake:

    cmake -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` ..

  6. Finally compile it with:

    make

  7. and install it with:

    sudo make install

  8. Update KDE's settings to find the new plugin:

    kbuildsycoca4

  9. End all open Dolphin windows and reopen it. Go to "Control -> Configure Dolphin... -> General -> Previews" and enable "Show previews for Audio files"

  10. Now move to your folder with music and enable preview for the folder and enjoy the cover art in dolphin

Dienstag, 20. August 2013

Completely encrypt your external HDD / USB-Key securely using Ubuntu Linux


If you ever wondered how to encrypt some external devices in Ubuntu or Linux in general, the following commands will guide you:

1. Create a crypted LUKS container for your device (replace /dev/xxx with your device):    

sudo cryptsetup --cipher aes-xts-plain64 --key-size 512 --hash sha512 --iter-time 5000 --use-random --verify-passphrase luksFormat /dev/xxx

You can also spare the additional parameters, cryptsetup will fall back on the default  parameters. Further explanation of what each parameter means can be found here.  

2. Open you encrypted container:    

sudo cryptsetup luksOpen /dev/xxx crypt_container    

3. Create a file system within the opened container (e.g. ext4):

sudo mkfs.ext4 /dev/mapper/crypt_container


4. Close the container and unmount it:    

sudo cryptsetup luksClose crypt_container     
sudo umount /dev/xxx    

That's it. Finally, if you disconnect and replug you device, Dolphin or Nautilus  will ask you for you password and mount it as every standard device.   If you need to check your new encrypted device or partition for errors, read this.

Donnerstag, 15. August 2013

Create *.po translation files from Vala Sources with context information in Ubuntu / Linux

I recently tried to create a *.po-File for translations strings from Vala sources which include locale context information.
As it was not so easy to figure out the right command, I thought I would share it with the internet folks:

xgettext -o result.po -L C -k_ --keyword=C_:1c,2 src/*.vala

So how does this work ?
  • xgettext extracts the translatable strings from the sources 
  • ...and puts it into the output file (-o result.po)
  • ...it also requires a defined programming language in this case C (-L C)
  • ...and needs to know what are translatable keywords (_ for strings and C_:1c,2 for contextual information, in this case)
  • ...finally set the input files (src/*.vala)
It's not that hard if you understand how it works :)