Skip navigation

Tag Archives: Ubuntu

I was really fascinated by the stuff I have read about Truecrypt. I wanted to try that but I had two reasons to not do that. First, I had nothing really to hide; Second, I thought my poor hp mini won’t be able to handle encrypting a partition, if not the whole disk. And also I was lazy. My close friends, bro and sis know my password anyway. Sis won’t find anything I don’t want her to and I have no problem others finding those. So the only reason I’d try encrypting is curiosity.

One day I was struck by a fireball of curiosity. And I was looking for ways to make portable, encrypted disk I can even put in Dropbox [referral link]. I found few good howtos with lot of details but what I’m going to put together will be an easier howto for a better virtual disk that is encrypted on-the-fly.

I am using Ubuntu 10.04 Lucid Lynx so there maybe a leetle Ubuntu specific things that I’m not sure of. The process has commands that can destroy your data if not used with care. I have tried this and it works perfect for me. If you manage to screw things up in the process that should be purely because you are stupid or careless or even both. And that was my disclaimer.

Alright let’s go make it.

We need dmsetup and cryptsetup installed for this.
$sudo aptitude install dmsetup cryptsetup

Once the installation process is finished we can start making our encrypted vitual disk.

First we create a file with random data in it. You can chose a size that matches your needs. In this example I’m making a 20MB virtual disk so I will create a 20MB file in this step.

$ dd if=/dev/urandom of=~/sekret bs=1M count=20

Here, the dd command creates 20 1MB blocks and fill it with random data. ~/sekret means that we create the filee named sekret in your home directory. You can chose a file name you like and also a path you like.

Next we need to create a block device from the file. For that find a free loop device with
$ sudo losetup -f

And use that loop device and create the block device. Let’s assume /dev/loop0 is free.
$ sudo losetup /dev/loop0 ~/sekret

Now we need to luks format the device. FYI: LUKS stands for Linux Unified Key System.
$ sudo cryptsetup luksFormat -c aes-cbc-essiv:sha256 /dev/loop0

This will warn you that the data in /dev/loop0 are gonna be overwritten. Hope you are confident enough to say yes. Then you are required to enter a pass-phrase for this encrypted this. Chose a powerful pass-phrase here. And then confirm the pass-phrase. The process will report success if we are lucky.


Map the crypto partition using

$ sudo cryptsetup luksOpen /dev/loop0 mycrypt

To be sure about the success run
$ sudo dmsetup ls

This will output something like mycrypt (252, 0).

Now we create file system on the device we created.
$ sudo mkfs.ext3 /dev/mapper/mycrypt

This will create EXT3 file system on the device. You can format it with your choice of file system. At the successful finishing of formatting, we have our own encrypted disk ready to use.

We can mount it with..
$ sudo mount /dev/mapper/mycrypt /media/sekret

Once you are done adding juicy stuff on your device you should unmount it AND REMOVE THE DEVICE FILE.
$ sudo umount /mnt/sekret
$ sudo cryptsetup luksClose mycrypt
$ sudo losetup -d /dev/loop0

Once you have created an encrypted disk, to use next time you only have to follow the steps 2), 4) and 6). Once you are done using the device, unmount with step 7).

I have put an encrypted virtual disk in my Dropbox and it works pretty well. Maybe you’d like to try that too. To use it in Dropbox, copy the encrypted virtual disk file (~/sekret in our case) in to your Dropbox directory.

I have put together a bash script to automate the process and I named it crysp :). You have to run the script as root so use sudo when running it. I might be an evil bastard trying to destroy your data so take a look at the script before you run. With the script you can easily mount and unmount the encrypted devices similar to the usage of mount/umount commands. I have added a dirty hack to allow read/write access to the device from Nautilus. To use this, change chanux to your login name in line 08 in the script.

Find the source in it’s Google Code repository. There’s a version that prevents the existence of thumbnails related to the encrypted disk. check crysp-no-thumb branch for that.

Update: 27-01-2013 Updated the script and put it on a github gist.

I was using gnome-do as my application launcher through out last year with my ubuntu 9.04 installation. I installed it right after installing 10.04 recently too. But I kinda needed a change. I realized I wasn’t using the launcher THAT MUCH so it better be lightweight. So I found dmenu. A nifty tool coming with ‘dwm’ window manager. I also found yeganesh, a wrapper around dmenu which lists most used app first. Yeganesh is written in haskell. Not that I don’t like haskell but let’s go with python yeganesh clone called pydmenu since ubuntu has python installed by default.

First install dmenu which is in dwm-tools on Ubuntu repositories.

$sudo aptitude install dwm-tools

Then download pydmenu, extract it and copy it in to /usr/local/bin

$ wget
$ tar xjfv pydmenu.tar.bz2
$ sudo cp /usr/local/bin/

create a file named inside /usr/bin/local and put following code in it.

exe=`` && eval "exec $exe"'

Or just run following command and it’ll automatically do it for you.

$ echo -e '#!/bin/bash\nexe=`` && eval "exec $exe"' | sudo tee /usr/local/bin/

You should change persmission of the file too

$ sudo chmod 755 /usr/local/bin/

OK enough playing in goofy command line. Let’s go on the surface and set up a shortcut key combination for our new launcher.

Go to System > Preferences > keyboard Shortcuts and press Add button to add a new shortcut. A dialog box called Custom Shortcut will show up. type in dmenu as the name and as the command and press Apply. Now you’ll see your new shortcut entry under Custom Shortcuts. We need to set the key combination now. For that click on Disabled (in ‘shortcut’ column) in the new entry. It’ll change to New Shortcut… Now press the key combination you prefer. (ex: press ctrl + space) Make sure the combination will not clash with others. I chose Super key (Some people call it windows key.)  and Space (Super Key + Space) which is the default for Gnome-Do. Close the keyboard shortcut window.

Now you can press the key combination you chose and see how it goes typing in few characters of your fave app’s name. Use arrow keys to move between suggested applications and Enter to run. You can dismiss dmenu with Esc.

PS: You can change the looks and orientation of dmenu editing dmenu command in file (/usr/local/bin/ with help of man dmenu.

And it obviosly is not sexy :D

dmenu in action. Click to enlarge.

Usual Chanux crap

I always used SCIM input method with sayura sinhala input scheme. But it had weird bug that screws up almost all the text input areas (My friend @gaveen pointed out it’s SCIM related). So the people who new about iBus told me to try it but as always I didn’t have time to try it on my previous ubuntu 9.04 installation. iBus came default on ubuntu since Karmic Koala (9.10) and since I switched to Lucid Lynx (10.04) it was the right time to check iBus-sayura out.

As lazy as I’ve become I chose seemingly easier way of installing ibus-sayura. I used the ibus-sayura unstable PPA on launchpad to install. And it worked, සෙටිපිකට් ඇත්ත. So you too can take the easier route.

The actual How-to

Step 1 – install
First, to add the PPA repository your system run the following command in a terminal (Applications > Accessories > Terminal)

<p>$sudo add-apt-repository ppa:skhome/ibus-sayura-debianised-alfa</p>

Then update package list with

<p>$sudo aptitude update</p>

Then comes the installing step.

<p>$sudo aptitude install ibus-sayura</p>

(Yeah, you are right. You can use apt-get instead of aptitude)
Step 2 – Launch and use

Now you are ready to use sayura. Go to System > Preferences > Ibus Preferences*.  Select the input method tab. Find Sinhala,Sinhalese in “Select an input method” drop down list and select sayura there. And now press add button. Close the preferences window if you want to :P.

You’ll see a little keyboard icon on upper panel. Click on it and select sayura and enjoy typing sinhala.

*If this is your first I bus run it will ask whether to start ibus daemon. You should say yes. Then it might present another scary message with following  commands.

<br />
export GTK_IM_MODULE=ibus<br />
export XMODIFIERS=@im=ibus<br />
export QT_IM_MODULE=ibus<br />

If IBus doesn’t work, you’ll have to run these commands in a terminal like we did in the beginning and log out and log in again. Don’t forget to keep your fingers crossed, literally. Now you may want to try the step 2 again.

My tweet you just read says the long story short. In case you didn’t come across, Google made DNS a buzzing topic again with Google Public DNS. So I felt like trying a dns cache again. The logic is “If a better DNS server makes things better, DNS cache makes it even better.”

This is more of a note to self than a HOWTO. If your use case atches with mine, feel free to use this.

My use case: I use an HSDPA, mobile broadband connection on Ubuntu 9.04 Jaunty Jackalope.

Install pdnsd with,

$sudo apt-get install pdnsd

Now launch the text editor you hate and add following to /etc/pdnsd.conf

(By default all the parts are commented so just adding this was fine enough for me)

server {
ip= ,;

global {
 min_ttl=15m;       // Retain cached entries at least 15 minutes.
 max_ttl=1w;        // One week.
 timeout=10;        // Global timeout option (10 seconds).

I copied this piece from here and edited ;). Added the global field because defaults were not cool enough for me. And in ip field I’ve put respectively OpenDNS and Google DNS addresses. You can just add one address there. ‘man pdnsd.conf’ will teach you more about the content in the file.

Once you are done editing the configuration file restart pdnsd with

$sudo /etc/init.d/pdnsd restart

Now you should tell the network manager to look for pdnsd for it’s DNS needs.

Right click network manager icon and then follow Edit Connections > Mobile Broadband and choose to edit your preferred network connection.

In Editing <Your Network Connection> dialog box,
[1] Choose IPv4 Settings tab
[2] Choose Automatic Addresses (ppp) Only in Methods Dropdown box.
[3] Set DNS Servers field to (which refers to pdnsd in our case)

And obviously, Apply Changes :P .

If everything went fine, you are now ready to enjoy DNS cache goodness with pdnsd.

You can check how good is it with dig command.


run this command twice and compare Query time field.

Note: If you followed all the steps but still it doesn’t work, try restarting pdnsd. If you get following error refer this page

/etc/resolv.conf must be a symlink

Update: Added the global settings for config file.

The other day I was at one of my friends place. To install Micro$oft Window$ XP. Period. The machine had SATA drive which XP didn’t have drivers for. That’s why I had to go into the trouble of installing that cursed OS again after Jurassic age, she didn’t know how to put the floppy disk in to the drive at right time.

However once I installed suXPee then she wanted me to install “ubiquitous” Ubuntu GNU/Linux too. Well..Since Ubuntu is known to pass the Girlfriend test I decided to install. The installation process started & since the installer presented an NTFS partition resize option I chose it. And half the way I got an ERROR. It was the evening & I think it was almighty gods ceyesta time. Then I kept pulling my hair for sometime, called my friends Such & geekaholic in search of stress reduction.

Few nights went away keeping me busy & angry with Ubuntu Hardy Heron for not showing me enough of an error report, I mean for being too much user friendly (rest of the world call it so). Finally I came back to recover the partition & downloaded some well known NTFS recovery software & like any other poor guy I went in search of …. You know.

F*ck I didn’t find any. Looked for any FOSS solutions. I found two. Testdisk, I didn’t try coz Such said it didn’t work very well for him(older version problem) & Scrounge which I didn’t have enough confidence of using. And then my friend gave me a link which pointed me to some shareware kind of recovery tools. There I found this great tool which didn’t cost me a buck — Piriform Recuva. It is a great tool indeed. I recovered enough of files with it. I have no money to donate to the project but lot of love to spread. It’s a great tool even though I’m not gonna use neither window$ nor NTFS resize option of Ubuntu installer anymore.

So if you ever find the depth of “lost NTFS partition” hell, Recuva is worth trying.