06 September 2010

Remap mouse buttons in Ubuntu 10.04, to have middle button as 'back' in browser

Ok, so i tried a bunch of programs, like btnx and imwheel, but nothing worked. Btnx worked, but had some weird side effects, such as holding down the alt key every time i pressed the mouse button, so i had to physically press the alt button on the keyboard to stop the 'alt signal'.

The solution was simple:

First, get the name for your mouse


$ xinput list

⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ PS/2 Generic Mouse id=11 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=12 [slave pointer (2)]
⎜ ↳ Macintosh mouse button emulation id=13 [slave pointer (2)]
⎜ ↳ Logitech Trackball id=16 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Sleep Button id=8 [slave keyboard (3)]
↳ HP Webcam [2 MP Macro] id=9 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=10 [slave keyboard (3)]



Find the mouse. My mouse has the name "Logitech Trackball".

A fancier mouse with more buttons will have a button for 'back' in the browser, so i wanted to set my middle mouse button to that signal.

First, just for fun, look at your current mouse map

$ xinput get-button-map "Logitech Trackball"
1 2 3 4 5 6 7


This is the standard map. The order of the numbers are 1 = left mb, 2 = middle mb, 3 = right mb, 4 = mwheel up, 5 = mwheel down

So what is 6 and 7? I have no idea :) But i know for a fact that 8 = Back on my mouse :)

I just tried mapping different numbers to my middle mouse button until it worked.

Like this:

$ xinput set-button-map "Logitech Trackball" 1 7 3 4 5 6 7

Tried it, and it did not work. So i increased it once more:

$ xinput set-button-map "Logitech Trackball" 1 8 3 4 5 6 7

And it worked! I did not even had to restart X or anything, it updated instantly.

To make the change permanent, you have to add this to some startup script. I added it to the startup applications thingy in Preferences >> Startup Applications. Simply write xinput set-button-map "Logitech Trackball" 1 8 3 4 5 6 7 in the command field.

27 August 2010

Creating a multi-partition usb drive with dual booting persistent Linux Mint and Puppy Linux

Wow, that title is really a mouth full :)

First off, i used other guides while doing this, and i would not have made it without them.
* http://tazbuntu.blogspot.com/2009/05/multibootin-with-unetbootin.html For getting the multibooting to work

So, i wanted a bootable usb-stick. I wanted Linux Mint, for obvious reasons, and also Puppy Linux, if i ever were to come across a old and crappy computer. To be extra picky, i also wanted the OS to be on a separate partition, since it looks messy with loads of weird linux-files in the root. I also wanted to be able to use the data-part of the stick in both windows and linux.

So, to put in in a list form:

* Boot Mint and Puppy
* Separate OS and data partitions
* Work in both Windows and Linux

Ok, so the first thing i discovered was that Windows for some weird reason will only read the first partition on a usb-stick..

1. Start Linux. I used Linux Mint 9. Whether you have it installed by default or use a live-cd doesnt matter.

2. Install programs needed. Gparted for partitioning, unetbootin for the puppy part.
sudo apt-get install gparted unetbootin

3. Partition your usb-stick.

- Start gparted.

- Remove all partitions on your usb-stick (this WILL delete everything you the usb-stick, so take care while doing it, and make sure it is your usb-stick you are deleting)

- Create the data partition that will work in both linux and windows. I used 12gb for this on my 16gb stick. Make the file system NTFS so that windows can read it. It is IMPORTANT to create this first in the beginning of the usb-stick, since windows only reads the first partition.

- Create the OS partition that will host your linux installs. Make this FAT32. (maybe ext will work?)

- Perform the changes with gparted if you have not already done so.

4. Download the latest Linux Mint and Puppy Linux isos. (just google it)

5. Use unetbootin to install Puppy Linux on the OS partition you just created.

6. Copy the entire OS partition to a folder called /puppy on the data-partition. This is just for storing it until later.

7. Format the OS partition to clear away puppy linux. Make sure it is still FAT32.

8. Use the "Startup Disc Creator" that is included in all later Ubuntu editions. It is for sure included in Linux Mint 9. Use it to install the linux mint iso you downloaded in step 4 onto the newly formated OS partition. Select a nice size for the "reserved extra space". I used 1 gb for this. This is where the persistence comes in. All changes you make will be saved in this space, so dont be cheap ;)

Ok, so now there is a data partition that works in windows, a persistent linux mint on it, and soon there will be puppy as well!

9. Copy the files from the /puppy folder from the data partition and place it in /puppy on the OS partition.

10. Edit /syslinux/syslinux.cfg on the OS partition. This is the grub menu that is displayed during boot. Puppy linux has to be inserted here to be able to choose it.

My file looked like this:

default vesamenu.c32
timeout 100

menu background splash.jpg
menu title Welcome to Linux Mint 9 Isadora
menu color border 0 #00eeeeee #00000000
menu color sel 7 #ffffffff #33eeeeee
menu color title 0 #ffeeeeee #00000000
menu color tabmsg 0 #ffeeeeee #00000000
menu color unsel 0 #ffeeeeee #00000000
menu color hotsel 0 #ff000000 #ffffffff
menu color hotkey 7 #ffffffff #ff000000
menu color timeout_msg 0 #ffffffff #00000000
menu color timeout 0 #ffffffff #00000000
menu color cmdline 0 #ffffffff #00000000
menu hidden
menu hiddenrow 6
label live
menu label Start Linux Mint
kernel /casper/vmlinuz
append noprompt cdrom-detect/try-usb=true persistent file=/cdrom/preseed/mint.seed boot=casper initrd=/casper/initrd.lz quiet splash --
menu default
label xforcevesa
menu label Start Linux Mint (compatibility mode)
kernel /casper/vmlinuz
append noprompt cdrom-detect/try-usb=true persistent file=/cdrom/preseed/mint.seed boot=casper xforcevesa initrd=/casper/initrd.lz ramdisk_size=1048576 root=/dev/ram rw noapic noapci nosplash irqpoll --
label memtest
menu label Memory Test
kernel memtest
label local
menu label Boot from local drive
localboot 0x80


Almost unreadable, so lets add some blank lines


default vesamenu.c32
timeout 100

menu background splash.jpg
menu title Welcome to Linux Mint 9 Isadora
menu color border 0 #00eeeeee #00000000
menu color sel 7 #ffffffff #33eeeeee
menu color title 0 #ffeeeeee #00000000
menu color tabmsg 0 #ffeeeeee #00000000
menu color unsel 0 #ffeeeeee #00000000
menu color hotsel 0 #ff000000 #ffffffff
menu color hotkey 7 #ffffffff #ff000000
menu color timeout_msg 0 #ffffffff #00000000
menu color timeout 0 #ffffffff #00000000
menu color cmdline 0 #ffffffff #00000000
menu hidden
menu hiddenrow 6

label live
menu label Start Linux Mint
kernel /casper/vmlinuz
append noprompt cdrom-detect/try-usb=true persistent file=/cdrom/preseed/mint.seed boot=casper initrd=/casper/initrd.lz quiet splash --
menu default

label xforcevesa
menu label Start Linux Mint (compatibility mode)
kernel /casper/vmlinuz
append noprompt cdrom-detect/try-usb=true persistent file=/cdrom/preseed/mint.seed boot=casper xforcevesa initrd=/casper/initrd.lz ramdisk_size=1048576 root=/dev/ram rw noapic noapci nosplash irqpoll --

label memtest
menu label Memory Test
kernel memtest
label local

menu label Boot from local drive
localboot 0x80


Ahh, much better!

Ok, so we have to add Puppy to the list

label puppy
menu label Puppy Linux 5.1.0
kernel /puppy/vmlinuz
append initrd=/puppy/initrd.gz pmedia=cd

should do the trick. And the final result should look like this:


default vesamenu.c32
timeout 100

menu background splash.jpg
menu title Welcome to Linux Mint 9 Isadora
menu color border 0 #00eeeeee #00000000
menu color sel 7 #ffffffff #33eeeeee
menu color title 0 #ffeeeeee #00000000
menu color tabmsg 0 #ffeeeeee #00000000
menu color unsel 0 #ffeeeeee #00000000
menu color hotsel 0 #ff000000 #ffffffff
menu color hotkey 7 #ffffffff #ff000000
menu color timeout_msg 0 #ffffffff #00000000
menu color timeout 0 #ffffffff #00000000
menu color cmdline 0 #ffffffff #00000000
menu hidden
menu hiddenrow 6

label live
menu label Start Linux Mint
kernel /casper/vmlinuz
append noprompt cdrom-detect/try-usb=true persistent file=/cdrom/preseed/mint.seed boot=casper initrd=/casper/initrd.lz quiet splash --
menu default

label xforcevesa
menu label Start Linux Mint (compatibility mode)
kernel /casper/vmlinuz
append noprompt cdrom-detect/try-usb=true persistent file=/cdrom/preseed/mint.seed boot=casper xforcevesa initrd=/casper/initrd.lz ramdisk_size=1048576 root=/dev/ram rw noapic noapci nosplash irqpoll --

label puppy
menu label Puppy Linux 5.1.0
kernel /puppy/vmlinuz
append initrd=/puppy/initrd.gz pmedia=cd

label memtest
menu label Memory Test
kernel memtest
label local

menu label Boot from local drive
localboot 0x80


Ok, now everything should be working. Reboot your computer and start from the usb-stick, and you should be greeted by grub!

A recommendation is to install PortableApps on the data partition from windows. After that, you will have a very functional usb-stick that has all the programs you need (PortableApps) and can even boot it's own OS if needed (Mint or Puppy).

01 June 2010

Recover a TrueCrypt volume after quick format

Background: I have an encrypted RAID0 array for storing data, and a SSD to install windows on. I had some problems with windows, so i decided to reinstall it. I did this without disconnecting the RAID-drives. (I mean, why should i have to?)

So, during a windows installation my encrypted data-drive got quick formated. Since an encrypted drive looks like random data when it is not mounted, I guess windows saw it fit to initialize my apparently unformatted RAW-drive without asking me..

The encrypted drive looked like a normal newly formated drive in windows, and i could mount it with truecrypt using the same password as before, but i was not able to read the drive that was mounted. It was unformatted according to windows.

Solution:

I used my rescue disc and restored the file header. I have no idea if this in necessary, but it did not take long and did not hurt, so i might as well write it here. I then used the data recovery program R-Tools to scan the mounted drive for files. Just like a normal drive. I have used Zero Assumption Recovery before, but i think R-Tools was much faster with equal results. Just took 4-5 hours to scan my 1.2TB drive.

After the scan it was just a matter of restoring the data on the damaged drive to another drive, and then copy it back again.