Monday, January 24, 2011

Update Ubuntu Release from the command line

sudo apt-get install update-manager-core # may/may not be necessary
sudo do-release-upgrade


If there's no new release found and you think there should be, check /etc/update-manager/release-upgrades and change Prompt=lts to Prompt=normal if necessary

Wednesday, January 12, 2011

Reset Moinmoin password

I always forget this

moin account resetpw --name=username password

Tuesday, January 11, 2011

Postgres Recovery

Postgres killed itself during a disk failure and while later trying to start it up I got messages along the lines of:

database system was interrupted; last known up at ...
database system was not properly shut down; automatic recovery in progress
redo starts at 309/3BA1EB48
record with zero length at 309/3C9F8ED8
redo done at 309/3C9F8EA8
last completed transaction was at log time ....
could not fdatasync log file 777, segment 60: Input/output error
startup process (PID 23142) was terminated by signal 6: Aborted
aborting startup due to startup process failure

On further investigation it sound like the transaction log was corrupted. This can be fixed with pg_resetxlog. This will clear the write ahead log and may result in some data loss or loss of integrity but when nothing else works it's a lifesaver. The documentation describes some follow up steps to ensure the integrity of data after postgres is starting properly.

You can do a dry run:
sudo -u postgres /usr/lib/postgresql/8.4/bin/pg_resetxlog -n /var/lib/postgresql/8.4/main
and if that indicates a new segment and there's no other option then you might as well reset with:
sudo -u postgres /usr/lib/postgresql/8.4/bin/pg_resetxlog /var/lib/postgresql/8.4/main
or
sudo -u postgres /usr/lib/postgresql/8.4/bin/pg_resetxlog -f /var/lib/postgresql/8.4/main

Friday, January 7, 2011

Pretty Print XML in Python

From the command line:

python -c "import xml.dom.minidom; xml = xml.dom.minidom.parse('myxmldoc.xml'); print xml.toprettyxml()"

Saturday, October 2, 2010

Mounting an encrypted LUKS LVM volume from a live CD

Get Luks and dm-crypt running on the live disk:
sudo apt-get install lvm2 cryptsetup
sudo modprobe dm-crypt
sudo cryptsetup luksOpen /dev/sda4 crypt1

If you LVM setup then you need to continue with:
sudo vgscan --mknodes
sudo vgchange -ay
Take note of the volume group name. 'vg0' in my case.

Mount the disk:
sudo mkdir /mnt/disk
sudo mount /dev/vg0/root /mnt/disk

Friday, July 30, 2010

Move Lucid min, max, close buttons to the right

gconftool-2 --set /apps/metacity/general/button_layout --type string menu:minimize,maximize,close

Tuesday, June 1, 2010

Inotify

Inotify is awesome, I've used the python bindings before to good effect but just today I needed to monitor a directory for whenever a file was created.

Pretty easy:
sudo aptitude install inotify-tools
inotifywait -m -r --format '%f' -e CREATE data/