Friday, November 30, 2007

Ubuntu Version Where Are You?

Being a more recent Ubuntu user I can never remember which version I installed, it was much easier in the Debain days but adapt, improvise and overcome is the motto I try to live by. There are two options which I've included below, if someoone knows of more please pass them along.

Option 1:

user@machine~> cat /etc/issue
Ubuntu 7.04 \n \l

Option 2:
user@machine~> lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 7.04
Release: 7.04
Codename: feisty



Encrypted Offsite Backup - Part I

For a couple of years now I've been performing offsite backups using the following process.

1. If not already loaded, boot into my Windows XP partition on my laptop
2. Copy all important files to a directory inside of the My Documents folder
3. Zip everything up using 7zip
4. Encrypt the zip file created in step 3 using AxCrypt
5. Copy the file to my backup server in another state using scp

The process didn't usually bother me too much because I'd kick off the zipping and copying processes before heading to bed so they'd just run at night. The problem with that process is obvious, it requires me manually initiating the process. As I've become painfully aware of most of us IT guys neglect our backups until it is too late. In my situation I've got a mixed home network running Debian, Ubuntu, Windows XP, uNSLUng and another distro or two when the urge strikes me. Well it came time to pony up and get with the program so I figured out a solution that once set up would give me secure offsite backups but also eliminate the time of doing the copying and zipping manually.

The solution involves using encfs to encrypt the data before copying it to the offsite machines using a mount created with sshfs. Below is the bash function I created that does the action for me, I'll be updating to use a key later but for now it just runs through cron and prompts me for the password.


function offsiteBackup
{

## set variables
DIRBASE=$HOME/Backup
DIRENC=$DIRBASE/encrypt
DIRDEC=$DIRBASE/decrypt

## remove encryption/decryption directories to make sure everything is gone
echo "Cleaning up from previous backups"
rm -rf $DIRBASE
mkdir -p "$DIRENC"
mkdir -p "$DIRDEC"

## mount the encryption and decryption directories
echo "Directories mounted"
encfs $DIRENC $DIRDEC

## copy all files that will be backed up
## NOTE: since the remote machines were mounted using sshfs only
##        the cp command is necessary.
echo "Copying files backup files from remote locations"
cp /media/remote1/settings.xml $DIRDEC
cp /media/remote1/mystuff $DIRDEC

echo "Files copied to the backup unencrypted directory"

## umount the decrypted directory
fusermount -u $DIRDEC

## create the zipped archive backup file
tar -czvf backup.tar.gz $DIRENC

## remove encryption/decryption directories to make sure everything is gone
echo "Removing backup directories"
rm -rf $DIRBASE

}


In Part II I'll be investigating if this same process can be followed with the Windows boxes using cygwin or some other alternative but for now this should get the Linux junkies started.

Special thanks for Tom Lowry at the University of Arizona Computer Science department for this post that got me started.

Tuesday, November 27, 2007

$363 19" All-In-One PC

George Ou is a crazy man, his projects like this are what keeps me coming back to his blog. If you have 5 minutes read the blog post and check out the pictures.

The $363 19-inch dual-core all-in-one LCD PC by ZDNet's George Ou -- This is the new all-in-one Intel dual-core 2.0 GHz E2180 19″ LCD PC computer I built for the family. The shocker is that I did it for less than $363 in parts (not including keyboard and mouse). The 19″ LCD (1440×900 resolution) was on sale for $140 and the dual-core Intel CPU/Motherboard/graphics was on sale [...]

Monday, November 26, 2007

Mount Disk by UUID

Have you ever been in a situation where you are wanting to mount your disk drives (USB, ATA, SATA, Firewire, etc.) by some unique identifier due to the occasional weirdness where you get the joy of what used to be your USB thumb drive -> /mnt/disk is now /mnt/disk2? If not then move on and pretend like you never stumbled across this post, if you have been scratching your head or read a convoluted solution that was driving your crazy this is your post.

The most consistent way I've found is to mount a device by the device's UUID, also known as its Universally Unique Identifier. What this alpha numeric looks like can depend on the device but I've yet to discover two devices that have the same UUID.

In the example below we'll assume we want to mount /dev/sda1 as /media/windows

Step 1 - Get the UUID of your drive by executing the following:
user@machine ~> sudo vol_id -u /dev/sda1
208861208860Z1A6


Step 2 - Add the proper line to your /etc/fstab file to property mount the partition in the future, snippet below:
# /dev/sda1
UUID=208861208860Z1A6 /media/windows ntfs defaults,umask=007,gid=46 0 1


Another example which mounts a FAT32 partition:
# dev/sda#
UUID=A123-B456 /media/fat32 vfat gid=46,umask=000 0 1

If you wish to 'reload' the fstab file instead of rebooting:
user@machine ~> mount -a

Retrieve System Information

As usual with Linux (and Windows in some cases) there are multiple ways to accomplish the same task but here is one for getting information on disks, usb devices, etc. attached to your computer.

user@machine:~$ sudo lshw

The listing can be quite long so don't forget to run it with the less, more or grep if you just want to see if a particular device is installed. For example if I wanted to check if one of my PQI mini-flash memory sticks was installed.

user@machine:~$ sudo lshw | grep pqi
vendor: pqi


If you're allergic to the command line use the GUI by installing lshw-gtk.