Skip to content
May 12 12

Installing Ubuntu (or Mint) from usb-stick when booting from usb doesn’t work

by admin

My semi-old computer doesn’t boot from a USB-stick/pendrive even when configured in the BIOS to do so. I really don’t want to burn a cd or dvd every time I (re)install Linux on a new drive.
Here’s how I worked around the issue, allowing me to boot from usb. No previous Linux-installation is required.

From Windows install Easy BCD and enable its “Grub bootloader” (autoNeoGrub1).
This gives you an old grub version for MS-DOS or so. We’ll use that to load the Linux installer.

Ubuntu (and Mint and others) has this new hybrid boot solution, where you can very easily install Linux from a USB-stick.
Start by writing the install-image, for example Ubuntu, to the USB-stick.

First locate the boot-partition on the usb-stick.
Try ls (hd1,0)/ to list the contents of the first partition on the second disk
(assuming that hd1 is the usb-stick). You should see a list of files from the install-image, i.e. not your regular files.

Then enter these grub commands to load the installer from the USB-stick:

module linux
set root=(hdX,0)
kernel /casper/vmlinuz boot=casper noprompt noeject
initrd /casper/initrd.lz
boot

May 12 12

Importing database from hosted Scrumworks Pro to a local instance

by admin

Just a quick note on how I solved this problem.
Scrumworks support said it couldn’t be done, but it was possible and not too difficult.

My team had been using the free trial of hosted Scrumworks Pro and entered a lot of backlog items. To avoid entering them again, I wanted to export the database and load it on my locally hosted Scrumworks Pro instance.

The trick was to first install Scrumworks Pro 5.0 locally, then import data, then upgrade it to SWP 5.1. Apparently they don’t run the latest version on their site.
Detailed steps:

  1. Login as admin to the hosted instance, choose “export” from the menu and you get an excel file.
  2. Install SWP 5.0 locally, and activate it with a free (or paid) license
  3. Import the excel file, check that the backlog appears, and quit SWP
  4. Install SWP 5.1 as an overlay, and choose to upgrade from 5.0
  5. Load SWP 5.1, you’re done!
Feb 26 12

Dualbooting Windows and Linux when grub2 fails to boot Windows

by perchrh

Of course I’d like grub2 boot all my operating systems, showing me a nice menu at boot time, but in my case that doesn’t work.
When grub2 tries to boot Windows, my machine reboots.
The documentation, forums, bug reports, etc. didn’t help me, so now I use the Windows bootloader to load grub and boot Linux.
This is tested on Windows 7 and Vista.
Here’s how:

First, from Linux, install the grub2 bootloader to the partition you installed Linux to (root partition).
In my case Linux is installed to /dev/sda5, so I go

sudo grub-install /dev/sda5 --force

If you can’t boot Windows at the moment, reinstall the Windows boot loader.
Insert your Windows install CD and run the bootsect.exe tool:

bootsect.exe /nt60 /all /mbr

Reboot into Windows.

Now, install Easy BCD, add your Linux partition (/dev/sda5 in my case) and select type grub2.

Remember to install the grub2 bootloader to /dev/sda5 (or your equivalent) when re-installing Linux or updating grub, as opposed to /dev/sda where the Windows bootloader resides.

Recent versions of Easy BCD also comes with a “bios extender” that allows you to boot from usb even when your computer doesn’t support it. I haven’t tried that feature.

Jan 14 11

Unix tools on Windows for fun and profit

by perchrh

So, your workplace or customers requires you to use Windows on your desktop. You’re a Linux-guy. How do you get by? Or maybe you are not familiar with Unix and Linux and want to try out some new tools on Windows, to make your life easier?
I used Linux exclusively (home, work, school) for eight years until I had to change to the Windows Vista environment at work.

Read on for some tips based on my experiences:

Improving I/O performance

File operations are slow on Vista, and this can be annoying, for example when you are creating and deleting many files regularly as part of your work, for example when you are building a large software product. This is fixed in Windows 7 and Windows 2008.R2. Upgrading my machine to Windows Server 2008.R2, and using it as a workstation helped make Windows quicker and more responsive, and was a good improvement in general.

I also recommend disabling indexing of all drives. Indexing is used for quicker file searches and to maintain the index degrades performance. If you are like me, you don’t use the built-in search function of Windows at all, anyway.

Install Cygwin 1.7 or later

Previous versions of Cygwin didn’t work well with Vista and later Windows-versions, but with Cygwin 1.7, it works nicely.

Get the Cygwin installer from http://cygwin.org. Install it, and make sure to include the ‘mintty’ package when installing.
After Cygwin has installed, create a link to C:\cygwin\bin\mintty.exe -e /usr/bin/bash --login to get a nice Xterm-like terminal that supports resizing and other nifty features.

Cygwin console on Windows screenshot

To get correct the file permissions on files created using Cygwin, you’ll need to fetch group and user information from the local machine and from Active Directory (if using Active Directory, of course).
Cygwin’s ‘mkpasswd’ and ‘mkgroup’ does this job for you.

First add the local groups and users:

mkpasswd -l > /etc/passwd
mkgroup -l > /etc/groups

Then add the network groups and users (this may take long time, depending on how many users and groups there are):

mkpasswd -d >> /etc/passwd
mkgroup -d >> /etc/groups

Command line power to the people

The Unix command line is awesome and can help you save time on a number of tasks. Here are some common use-cases:

Replaces text in files using regular expressions:

> find . -name "*.xml" -exec sed 's/testDataSource/prodDataSource/' {} \;

To detect encoding and content type of text files:

> file Person.java
Person.java: UTF-8 Unicode Java program text

Using ‘find’ to find files and directories:

> find /some/path -name "*I.java"

To find the errors in that xml file, or verify that it is well-formed:

> xmlwf myfile.xml

To change the end of line encoding in text files from Windows to UNIX:

> fromdos MyFileWithWindowsLineEndings.java

and correspondingly, use todos for converting files the other way.

Printing code out on paper:

> a2ps FileOne.java FileTwo.java -o printMe.ps

You can include line numbers, highlight keywords for multiple programming languages, use multiple pages per sheet etc. Send the .ps file to your printer.

Using ‘find’ to find files and directories, combined with ‘grep’ to look inside the files:

> find /some/path -name "*.java" -exec grep -il demo {} \;

Change the encoding of a text file:

> iconv -f ISO-8859-1 -t UTF-8 someFile.xml > newFile.xml

For-loops are your friend! Now changing the encoding of multiple files:

for file in $(find . -name "*.xml");
do
iconv -f ISO-8859-1 -t UTF-8 ${file} ${file}.new;
mv ${file}.new ${file};
done

Install KDE

Yes, KDE is available on Windows!
Get the installer from http://windows.kde.org, make sure to run it “as administrator”, and choose to install the latest stable version.

I like to install these packages:

  • kdeapps-base
  • kdebase-workspace
  • kdenetwork
  • kdesdk
  • kdeutils

This gives me (among other things):

  • Kate, a super editor with highlight-support for many languages
  • Okular, the quick and light PDF reader
  • kompare, a powerful tool for showing differences between text files
  • Umbrello, the UML diagram tool

KDE on Windows screenshot

KDE on Windows screenshot

Replace MS Office Communicator

I don’t particularly like the user-interface of MS Communicator. Also, it crashed pretty often for me.
You can replace it with Pidgin, the multi IM-client. Make sure to install the SIPE plugin, to support the protocol MS Communicator (and MS Live Communicator) uses.

Starting programs without clicking the menus

A simple way of supporting the behavior of “alt-f2″ or “alt-space” on Linux (KDE, gnome, others) to run a program, is to add the programs to Windows’ PATH and press ‘win-key r ‘ to run an application, like for example ‘kate’.

Install python

Python is great for text-processing and -generation and also as a calculator.
Get it from http://python.org.
I’ve had good use for python to build test-sets in XML based on data from a SQL database.

Jul 13 10

Quicker builds on Windows by using a RAM-drive

by perchrh

There’s been a number of blog posts lately celebrating the use of SSD-disks for reducing build/compile times and to make your IDE snappier.
This post is about an even quicker and often cheaper alternative – mount a portion of your RAM as a drive and execute builds there! I also show you how to accelerate Maven and IntelliJ using this strategy.

I have 16GB RAM on my Windows 2008 workstation (my customer demands that I use Windows) of which I normally use about 3GB. What I’ve done is to set 8GB aside for a RAM-drive. Files put on my e:\ drive are stored directly in system memory, no need to do the round-trip to a harddrive, waiting for the data to be copied into memory. I’m developing software in Java and use the RAM-drive for my Maven builds and installs. Also, I keep IntelliJ temporary files, indexes, etc. in memory.

On Linux/Unix and MS-DOS/older Windows versions RAM-drives are easily created using tmpfs or ramdisk.sys, but on new versions of Windows, Vista and later, built-in support for RAM-drives is lacking. Enter Dataram RAMdisk. This free software does the job nicely. Typically, you’ll need a 64-bit Windows version to access more than 4GB of RAM at the same time.

Create the RAM-drive

  1. Install RAMDisk
  2. Configure and create the RAM-drive.
    Configuration, part 2
    Select persistence settings of the RAM-drive. Remember to save your settings.
    Configuration, part 1
    Select the size of the RAM-drive and start it up.
  3. Using Server Manager, format the new drive as NTFS. After a wait of a couple of seconds, the new drive will show under “My Computer”.
    format the new drive
  4. [Optional] Disable indexing of files on the new drive. It is not worth it to have Windows build and maintain a search index for your build tree. Go to the new drive in explorer, for example e:\ and choose properties. On the bottom of the first page, uncheck “..index files..”
  5. Check out your code tree to the new drive
  6. Execute mvn clean package. Observe the difference in speed from building on your ordinary harddrive. In my case I get more than a 20% speedup, saving myself over five minutes on certain builds.

Put your Maven artifacts on the RAM-drive

Putting your Maven artifacts on the RAM-drive will speed up builds and installs.

The simplest solution is to just put your entire local maven repository on the RAM-drive by setting the local repository path in Maven’s settings.xml. For example, you change the location of the repository from c:\Users\someuser\.m2\reposistory to e:\repository.

A more flexible solution, and the one I use, is to only put -my- artifacts on the RAM-drive.
I do this to save space, as my repository is a bit on the heavy side.
To get there, I used the built-inmklink command.
mklink allows you to create a directory that links to another directory.
That way I make the directory (c:\someuser\.m2\reposistory\my\artifact-root) point to e:\repository-ramdisk.

The syntax is
MKLINK /J Link Target

Example:

C:\Users\someuser\test>mklink /J mydir e:\mydir
Junction created for mydir <<===>> e:\mydir

C:\Users\someuser\test>dir
 Volume in drive C is System
 Volume Serial Number is 1401-307B

 Directory of C:\Users\someuser\test

06.07.2010  11:17              .
06.07.2010  11:17              ..
06.07.2010  11:17         mydir [e:\mydir]
               0 File(s)              0 bytes
               3 Dir(s)  55 119 831 040 bytes free

C:\Users\someuser\test>mkdir e:\mydir

C:\Users\someuser\test>cd mydir

C:\Users\someuser\test\mydir>dir
 Volume in drive C is System
 Volume Serial Number is 1401-307B

 Directory of C:\Users\someuser\test\mydir

06.07.2010  11:15              .
06.07.2010  11:15              ..
               0 File(s)              0 bytes
               2 Dir(s)   2 102 341 632 bytes free

Make IntelliJ use the RAM-drive

Putting IntelliJ’s temporary files and indexes on the RAM-drive will make it snappier, especially for large, multi-module projects.

First, make sure you have the default setting of “use maven output directories” enabled, that will make IntelliJ create class-files on the RAM-drive.

Secondly, import or load the project from the RAM-drive, for example import e:\src\mymodule\pom.xml as a new project.

Finally, exit IntelliJ and copy IntelliJ’s system (c:\Users\someuser\.IntelliJIdea90) folder to the RAM-drive (or selected parts of that folder if you’re short on free space).
Then rename the system folder and create a link with the same name, pointing to the folder on the RAM-drive (using mklink as in the previous section).

Make files on the RAM-drive persistent across reboots

There is of course the option of just checking out the source code and downloading the maven artifacts anew after a reboot. You can even script this task to do it automatically at startup.

If you want some file safety in case the computer crashes, there is a loss of power or so, you can have Dataram RAMdisk write the RAM-drive to disk automatically and regularly.
Also, it can persist and load the RAM-drive at shutdown and startup, by selecting the ‘auto save’ option as shown in the first screenshots. making the RAM-drive appear completely like a normal drive. Tweak the settings to your liking, and remember to save them :)

May 1 10

Quick and easy upgrade/reinstall of Ubuntu

by perchrh

This post explains how to reinstall Linux without using a cd/dvd, usb disk/pen drive, network boot or install partition. It requires internet-access from the machine you’re reinstalling and it requires the Grub boot loader to be installed, which most new Linux-systems installs (Ubuntu, Debian and Suse uses Grub) . If you have a dedicated partition to /home, you’ll likely not need to take backup first.

I don’t particularly like burning CDs, DVDd or writing special installer images to usb pen drives to install/reinstall Ubuntu. The pen drive boot option can be quick and easy, but you have to get a pen drive first, or find the one(s) you have laying about somewhere.

Backing up your files if necessary

If you don’t have all your user files at a dedicated /home partition, you’ll have to backup the files you want to keep to another drive or to some network location.
If this is a server, you’ll likely want to take a backup of /etc and /var, to keep logs and configuration files, for example your ssh host keys in /etc.

If you have important files on your system I advise you to make regular backups in any case, reinstalling or not :)

A neat trick I use, to save time reinstalling packages after reinstall, is to save the list of the currently installed packages and just automatically install all those packages after the OS-installation is complete.

To save the package list:
dpkg -l|awk 'NR > 5 {print $2}' > $HOME/mypackages.list

To restore packages from the list:
sudo aptitude install $(cat foo.list)

I often like to manually prune the list, just open mypackages.list in your favorite editor, and delete package names you don’t want.
If you want to install package-collections like ‘kubuntu-desktop’ or so after install, it’s best to do that before restoring your package list.

Preparing for reinstall

Get the initrd.gz file and the linux file from the netboot directory of the Ubuntu installer location. In my case I got the one for amd64 (x86-64) for Ubuntu Lucid Lynx because I want a 64-bit system:
http://archive.ubuntu.com/ubuntu/dists/lucid/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64/

Copy the files to your grub boot directory. Assuming you downloaded the files to $HOME/tmp, this is done as follows:
sudo mkdir /boot/reinstall
sudo cp $HOME/tmp/linux /boot/reinstall/
sudo cp $HOME/tmp/initrd.gz /boot/reinstall/

Also make a note of your partition layout, so that you’ll know which partitions to choose during installation. To do so, just execute mount on the command line of your current Linux system to see which partitions are used for what. Of special interest are the partitions for /home and /. Example: /home is at /dev/sda8 and / is at /dev/sda5.

Actual reinstall

There is an excellent guide on how to boot the installer using Grub (easy) at
http://help.ubuntu.com/community/Installation/NetbootInstallFromInternet
which I won’t repeat.

This will launch the text-based installer. Choose manual partitioning, and to format your old / partition and preserve your /home partition. If you don’t have a /home partition, this is your chance to create one. In that case you split the / partition into two, using most of the space for /home and 15-20 GB for /, and reformat both of them.

Apr 30 10

Twitter and Facebook support in bitlbee

by perchrh

With version 1.2.6 of bitlbeee both Twitter and Facebook accounts are supported!
Read on for how to add them to your account list!

Twitter

Previously, I’ve connected to my twitter account using jabber and ping.fm , which has worked okay, but required me registering an account with ping.fm. Also, it only pushes my status updates, I don’t get other people’s updates.

account add twitter <handle> <password>
account on

There are some settings you can tune, as well, checkout account set <id>, where id is the number of your twitter-account. The ‘mode’ setting should be of special interest. It let’s you decide whether all messages from twitter comes from the nick twitter_yourHandle (mode=one), or if there is one nick per twitter-user (mode=many) and if all twitter action happens in its own channel (mode=chat). I prefer the latter one, to separate between Twitter-messages and ‘the rest’.

account set twitter/mode chat

Note that you have to disconnect the account first, when changing the mode.

Twitter on bitlbee/IRC

Twitter on bitlbee/IRC

Facebook Chat

First set a Facebook username.
Then add your account:
account add jabber @chat.facebook.com <password>
account set facebook/nick_source first_name
Or
account set facebook/nick_source full_name
Then
account on

Note that non-ascii characters are stripped away, meaning letters other than A-Z are removed.

Nov 21 09

Implicit supervised learning for kids through computers

by perchrh

In early middle school I found a new friend. His family had a computer. This was pretty much my first meeting with computers – what they do, how they look and what kind of noises they make.  While all of these attributes have changed since then, some properties remain. We learned maths and language by playing games on the computer. What’s interesting is that we learned from experimenting and pattern generalization, not by being actively taught vocabulary or how to do math problems.

In artificial neural network theory, that is modern artificial intelligence for you, there is the concept of supervised learning. You give the network a set of input values and let it know what the appropriate, corresponding output values are [a training set]. The network will, if you’ve managed to do it correctly, and the stars are right, learn the pattern between input and output and be able to predict the correct output for input values it has not been trained for. Humans do this all the time, it’s called understanding things. Only when you understand something will you be able to generalize the knowledge and use it in new situations.  At my friends’ place, the computer was supervising us implicitly, by letting us know when we’ve done right, and to some extent, when we’ve done wrong.

We didn’t have access to that many games back then, but we were fascinated by the machine, so we played whatever game we could get hold of. We really liked adventure games like King’s Quest and Space Quest. We would play them whole days at a time, exploring the game worlds and solving puzzles. Looking back, I realize these games were highly educational to us. As the games were in English, our secondary language, we had to work to understand the game text and phrase the instructions to the game correctly. I will forever remember the difference between “three” and “tree”. Space Quest III did not at all accept my instruction to “Kick three” in order to break an old tree in two and use it to get across a gorge, and it got us stuck for days trying to come up with something else to do to move the game along. Each area [screen] in the game would typically come with a description. We soon learned to type ‘look around’ on every new screen to learn what parts of the world we might be able to manipulate. This implied mapping new words to known images. I don’t remember ever using a dictionary while playing, we learned by trial and error and educated guesses on what’s what in each screen. All in all, these games did wonders for our vocabulary, resulting in me getting the top grade at end exams in English at upper secondary school. This is a kind of supervised learning. When we tried multiple solutions, we got feedback if they were right or wrong.

Now for something stranger. We found a math game. It had symbols like ‘a’ and ‘b’ and ‘x’ in it, which was totally alien to us at the time. Professor Weissman’s Algebra Tutorials it was called. We didn’t realize then that this was a program to test students’ skills in basic algebra. It had a number of mathematical problems you were to solve. If you failed, it would show you a stepwise solution. It would not explain anything, just show you each line of the calculation. For some reason, this intrigued us and we determined to beat all the challenges in this game. My friend and I would sit together and reason about what the correct solution might be, knowing nothing about the underlying mathematics. That’s how we learned basic algebraic manipulation of equations! I ended up studying engineering at university level and did my share of advanced calculus (maths).
I believe being two and knowing some English and maths already helped our learning significantly.

Thinking along the lines of the tendency to follow the path of least resistance (people are lazy), I believe if we had had other, equally fun, less challenging games, we would have played those instead. Is that the situation today, I wonder? With a plethora of highly entertaining games, how does a game that forces you to stop up and reason compare?