All hardware is eventually decommissioned. It may be broken, stolen, or just too old and slow. However, the software on it might still be needed. Not all software is easily transferable to a new PC with the latest OS on it. This quick guide helps you convert the old machine to a virtual machine, so that you can run it in VirtualBox. The process is called physical to virtual (P2V).
This article assumes you are at home in a Linux shell.
Boot the old hardware from a Ubuntu live CD or USB stick (or any other live cd, for example the gparted cd).
Prepare copying each file system with the following steps:
Mount the filesystem
Remove the contents of /tmp and trashcans in the home directories.
Now copy each physical disk to the target host computer (you could also do this per partition). With nc (netcat) and dd this is easy. Netcat essentially opens a pipe between two computers. We then use dd to stream the entire disk to and from the pipe. One of the two netcat's are in listening mode, the other connects to that one. It doesn't matter which one does the listening, except I found that netcat in MacOSX does not properly support listening. To speed up the transfer, gzip is used. Because we cleared empty sections of the disk, gzip is a quite efficient addition. (Update 2013-04-15: Now I would recommend a compression program that compress/decompress faster at the cost of compression efficiency. For example lzop.)
Here are the two examples of copying the disk /dev/sda. The first puts netcat in listen mode on the target, the second on the source system (execute in the given order):