Friday, December 14, 2007

Installed Packages

I've been searching for an easy way to itemize all installed packages on a Debian / Ubuntu system, but just found it today. To list all installed packages,

dpkg --get-selections > installed-software

Now, you can use this list to re-install an existing system or duplicate its configuration on a new system:

dpkg --set-selections < installed-software

Finally, run deselect to make the selection changes take effect!

dselect

Thank you to Ubuntu Forums for the answer: http://ubuntuforums.org/showthread.php?t=261366

Monday, December 03, 2007

Finishing my previous thought

After expanding the virtual disk and the partition, simply run resize2fs on the device of interest and the filesystem (EXT2 or EXT3) will be expanded to occupy the full extent of the partition :)

Virtual Disks

Expanding a virtual disk in VMWare is very simple:

vmware-vdiskmanager -x 10GB myDisk.vmdk

Just remember that you still have to expand the partition and the filesystem living on that partition as well. Thanks to http://4sysops.com/archives/expanding-a-virtual-vmware-disk/ for the information!

Monday, October 29, 2007

a simple reminder

Two things today...first, a simple way to determine how much work you are causing your laptop harddrive:

 sudo smartctl -a /dev/sda | grep Load_Cycle_Count

Apparently anything above 600000 means your drive is about to kick the bucket :(

I've always wanted an easy way to pop up a reminder message at some point in the future from the command line on a Linux system. I wonder why it took me so long to find the answer?

 echo "DISPLAY=$DISPLAY zenity --info --text='go home'" | at "5pm"

Thursday, October 25, 2007

another vim trick

Just found this amazing tip which allows VIM to automatically open a GPG encrypted text file, edit it, and save it back to disk in encrypted form without writing the unencrypted data to a buffer. Thank you Wouter Hanegraaff!

Friday, September 14, 2007

The Internet from Afar

I recently attempted to fire up an instance of Firefox on a remote system that I was connected to through SSH (with X forwarding enabled). I remember doing this back in the day with no problems. However, Firefox apparently has a "feature" now that checks the DISPLAY settings and starts the process locally if you attempt to run it over the remote connection. This behavior seems to be counter-intuitive and unwanted. Someone somewhere decided to start treating users as idiots. Now for the fix:

 firefox -no-remote

Of course this option is not mentioned in the help menu...

Tuesday, August 28, 2007

Thursday, July 12, 2007

A Challenge

I often wonder if the number of hopeful days balance out the number of hopeless days. Has anybody ever tried writing down how they feel each day and doing an analysis on it? The patterns one finds could prove very interesting. And why does hopeful only have one L?

Tuesday, April 24, 2007

Random Thought

It is interesting and disturbing how few quiet places there are in my world. The loss of power always seems to leave a ringing in my ear...

Monday, April 16, 2007

Partition Fun

I recently made the mistake of installing Linux on a single disk partition. As a result, my home directory and all of my settings were stored on this partition and I was long past due for an OS upgrade. Luckily, a utility called RESIZE2FS for resizing EXT2/3 filesystems exists. With this tool, I was able to shrink the root filesystem from its original 60GB size down to approximately 20GB:

resize2fs -p /dev/sda1 20G

At this point, I could manipulate the partition table, resizing the first partition to 20GB and creating a new partition which would serve as my /home folder in the unused space. As long as the first partition is large enough to encompass the root filesystem, this should not cause any problems.

Finally, I could create a new filesystem in the new partition and copy my home directory there:

mke2fs -J /dev/sda2

At this point, I can install a fresh OS, formatting the root filesystem and still preserve my user settings :)

Sunday, March 25, 2007

Sometimes print is bad

I wrote a simple Ruby script that, given a connection request on a particular port, opens a connection to a remote host on a particular port and forwards all packets from one to the other, a very simple packet forwarder. For debugging purposes, I was printing some text to standard out for each packet received / forwarded. I set up a simple performance test running the forwarder on my local system and generating packets using /dev/zero...something like this:

ruby forwarder.rb 20000 10000 localhost
nc -l -p 10000 -c "cat /dev/zero"
nc localhost 20000 > moo

After running this test for 15 seconds, the output file "moo" reached a size of 48MB on my laptop, indicating a throughput of over 3 MBps. Although this was sufficient for my purposes, it was much lower than I expected given that transfer should only be limited by the speed of my laptop harddrive in writing the output file.

By simply removing all "puts" calls for output, the performance increased dramatically. With the same 15 second run, the output file "moo" reached a size of 350MB on my laptop, indicating a throughput of over 23 MBps!

I suppose that when writing an application that handles a large amount of data, all debugging should obviously be turned off. However, it wasnt obvious to me that it could have such a large impact on performance. Hopefully this will help me not make the same mistake in the future.

Thursday, March 15, 2007

Ruby Trix

I've been having a number of problems in Ruby of late with error handling in Threads. In particular, any time I encounter a problem in a thread, I was given no indication that something went wrong.  It turns out that by default, an unhandled exception simply kills the current thread and you don't even hear about it unless you issue a "join" on the thread that raised the exception.  I suppose proper coding practice would be to handle my exceptions appropriately, but for debugging, it is nice to know when something has gone wrong.  The simple snippet of code:

Thread.abort_on_exception = true

takes care of this problem.  With this modification, any unhandled exception kills all running threads and yields readable error information.