Archive

Archive for the ‘Linux’ Category

Upgrading a RAID-1 array…in only a week

June 8th, 2008

750GB hard disks have been at the $/GB sweet spot for a while now, and now that they’ve hit $100, I decided to upgrade my home directory RAID-1 from 250GB to 750GB. I really dread these upgrades, as there’s always a chance you can really screw things up. So, for when I upgrade to 2TB or whatever in two years, I wrote up some notes.

In my configuration, sdb1 and sdc1 are the partitions currently part of my RAID-1 md0. sdd is one of the 750GB disks. I’m adding one 750GB disk at a time, because 1) I want at least two copies of my data to be available at all times and 2) I only have one free drive bay and don’t want disks dangling next to the machine for hours.

  1. Change the number of active devices in the array from two to three. This will cause any newly added drive to become active (i.e. actually write the array’s data onto the new drive)

    mdadm -G /dev/md0 -n 3

  2. A little burn-in testing for the new disk

    badblocks -svw -t random -p 2 /dev/sdd

  3. Partition, not forgetting to set the partition type to 0xfd, Linux raid autodetect
  4. Add the new drive as a spare to the existing array

    mdadm /dev/md0 --add /dev/sdd1

  5. Once recovery is done (check `mdadm -D /dev/md0`), fail and remove one of the old disks from the array

    mdadm /dev/md0 -f /dev/sdc1 -r /dev/sdc1

  6. Shred the removed drive

    shred -v -n 2 -z /dev/sdc

  7. (Physically) swap out the removed drive and replace it with the second new one
  8. Repeat steps 2-5 above for the second new disk. Hold off on the shredding, as this is going to be our backup
  9. Reset the number of active devices in the array to two

    mdadm -G /dev/md0 -n 2

  10. Grow the array

    sudo mdadm -G /dev/md0 --size=max

  11. Let it resync, then unmount and resize the filesystem

    umount /home
    resize_reiserfs /dev/md0
    mount /home

  12. Finally, if everything seems okay, shred that second old disk

    shred -v -n 2 -z /dev/sdb

…and we’re done! The one annoying thing is that with testing and a couple of resyncs, you end up with loads of down time between really short and simple tasks. So it’s possible (and I speak from experience) to stretch this weekend project out over a whole week.

Computers, General, Linux , ,

duplicity with Amazon S3

January 25th, 2007

Goal: I want cheap backups

Reality: Online storage generally isn’t cheap

That is, until Amazon’s S3 came onto the scene last year. I’d heard of duplicity and knew it had backend support for S3, so I figured that it couldn’t be too hard to setup. Unfortunately, I couldn’t find a place online that ties everything together, so I’ll try to do that here.

Background: Amazon’s S3 (Simple Storage Service) is cheap, available storage. How cheap? $0.15 each GB-month, and $0.20/GB transfer. duplicity gives you “encrypted, bandwidth-efficient backup using the rsync algorithm.” Well, good enough for me. Let’s start.

On my Ubuntu Linux 6.10 (Edgy Eft) machine, I first had to get librsync-dev:

sudo apt-get install librsync-dev

Then, I got duplicity-cvs and installed it:

cvs -z3 -d:pserver:anonymous@cvs.sv.gnu.org:/sources/duplicity \
co duplicity

cd duplicity
dist/makedist 0.4.3
tar xzf duplicity-0.4.3.tar.gz
cd duplicity-0.4.3
python setup.py install ??prefix=/home/tkho

If you install into your home folder, make sure to set the PYTHONPATH:

export PYTHONPATH=/home/tkho/lib/python2.4/site-packages

For duplicity to use the S3 backend, you need the BitBucket library. Once downloaded, install it:

tar xzf BitBucket-0.4a.tar.gz
cd BitBucket-0.4a
python setup.py install ??prefix=/home/tkho

Now, everything is installed so we can start a sync. On a side note, it took about half an hour for my S3 account to start working.

export PASSPHRASE=password
export S3KEY=your_s3key
export S3SECRET=your_s3secret
duplicity /home/tkho/sync s3+http://duplicity_sync

That’s it! Add that to a daily or weekly cron and you have cheap, off-site backups. And, since you’re using duplicity, you get snapshots for free!

Lastly, don’t forget to grab Jets3t Cockpit–it’s a GUI file browser for your S3 data.

Computers, General, Linux, The Pursuit of Happiness ,

Stacked GIT

June 18th, 2006

I spent part of Friday moving into the 21st century and learning my way around GIT. Not long after, I found out about Stacked GIT, which makes it an order of magnitude faster and easier to use and maintain code over CVS. It keeps a series of interdependent changesets organized a stack–you push and pop to switch the active changeset you’re working on, and pushing clues you in to any necessary conflict resolution. How cool is that?!

Computers, General, Linux, Software Development

offlineimap

May 28th, 2006

Since I abandoned Fastmail for Gmail’s intuitive keyboard shortcuts and conversation views a couple of months ago, I’ve been putting off the task of backing up the old account. I ran across offlineimap today, which has simple configuration and seems to be doing a good job of syncing about 500mb of email.

Update 12/9/2006: I found an even better way to get IMAP backups with the aptly named imapbackup.py script.

Computers, General, Linux

ptrace(2)

May 24th, 2006

I was trying out the sample ptrace‘ing code from this article [Playing with ptrace, Part II] today and ended up wasting a bunch of time trying to figure out why the int80, int3 code injection example would fail with strace showing an EIO error. Then it hit me that I was trying to write over the sleep library function…great…

Computers, General, Linux, Software Development

FTP with TLS/SSL client on Linux

April 28th, 2006

I’ve run into this before–my school’s web space is only accessible via FTP with TLS/SSL, and the problem is that I don’t know of (and I can’t find) a Linux client that lets me do that. I wasted about 5 minutes trying to find something I could apt-get, but ended up downloading FileZilla and running it in Wine (I also tried three versions of CuteFTP, all of which failed to run properly).

Update 12/11/2006: See if this works.

General, Linux

QEMU and the network bridge

February 18th, 2006

QEMU’s user networking won’t do UDP out of the box, so I poked around online for a solution. What’s out on the web is a hodge-podge of tutorials, all of them different, and most of them for a non-current (read: not QEMU 0.8.0) release. This is a (equally poor) guide to get bridged networking working. FYI, my distro du jour is Ubuntu 5.10, and I hope to revise these instructions should the need arise to re-configure my setup.

First, check out How to install QEmu on Ubuntu Linux (Breezy) for some aptly named instructions.

From the tun/tap on ubuntu thread on Ubuntu Forums (probably not necessary?):

# apt-get install uml-utilities
# tunctl

From qemu ‘networking howto’:

# ifconfig eth0 down
# brctl addbr br0
# ifconfig eth0 0.0.0.0 promisc up
# ifconfig tun0 0.0.0.0 promisc up
# ifconfig br0 192.168.1.2 netmask 255.255.255.0 broadcast 192.168.1.255 up
# brctl stp br0 off
# brctl setfd br0 1
# brctl sethello br0 1
# brctl addif br0 eth0
# brctl addif br0 tun0
# route add default gw 192.168.1.1

From djw’s qemu network bridge page, modify your /etc/qemu-ifup to something like:

#!/bin/sh echo "Executing /etc/qemu-ifup"
echo "Bringing up $1 for bridged mode..."
sudo /sbin/ifconfig $1 0.0.0.0 promisc up
echo "Adding $1 to br0..."
sudo /usr/sbin/brctl addif br0 $1
sleep 2

Finally, what they never tell you is how to start up QEMU. Little did I know that when you connect TAP to a VLAN, it doesn’t create the NIC for you. I wasted about a hour until I realized you need to append another `-net nic`. Here’s how I start QEMU:

qemu debian.img -kernel bzImage-2.6.14 -append "root=/dev/hda1" -net tap -net nic

Voila, mon ami. C’est tout!

Update: You’ll want to chmod 666 /dev/net/tun, and make sure you have the bridge-utils package.

Update 2: I have kernel config files for Linux 2.4.20, 2.6.11 (found these first two online), and 2.6.14. These build decently small kernels without modules that boot up in QEMU.

Computers, General, Linux ,

SCALE 4X

February 12th, 2006

After a couple years of putting it off, I can finally say I’ve gone to the Southern California Linux Expo (SCALE). I spent this weekened listening to a handful of really interesting speakers. Here were my highlights:

  • Zend’s Andi Gutmans talked about PHP 5 and the future of PHP. I haven’t done significant PHP work since 4 was released, so I found a lot of the new stuff pretty amazing. I was espeically impressed by a 2-line example of accessing the Google API via SOAP. TWO LINES.
  • David Schachter from Sleepycat (the makers of Berkeley DB) talked about how pervasive Berekley DB is in Linux systems. One thing I definitely walked away with was that a lot of people (myself previously included) myopically think relational databases are the only kind of databases around. Obviously, they’re not. I wish this was ingrained in me a couple years back.
  • Adam Leventhal, a Solaris kernel guy, talked about using DTrace to find hotspots in Linux apps. DTrace is purely a Solaris thing, but by running your Linux app in Solaris’ Linux sandbox, you get most of the interesting metrics.

And of course, Dan Kegel and Chris Dibona had interesting things to say.

Computers, General, Linux

RSI

February 12th, 2006

When I used OS X full time, I found a nifty little tool named AntiRSI. True to its name, it prevents you from working too long on the computer by eclipsing your screen and forcing you to take a break.

Fast forward about a year, and today I found out about Workrave. It reminds you to take breaks just like AntiRSI, but improves on the idea by giving suggestions of stretches. Even better, all it took was an `apt-get install workrave`:)

Postscript: Also saw this short article: Alleviate RSI the Hacker Way

Computers, General, Linux

Nokia 770, VPNs, etc

January 25th, 2006

After drooling over the Nokia 770 (Wifi/Bluetooth Internet Tablet) for about a week, I drove down to CompUSA near the Fox Hills Mall to buy one. The thing is 0.5 lbs, has a 4″ 800×480 screen and actually looks nice.

Today, I got root on the machine, installed xterm and Gaim and setup vpnc to connect to UCLA’s IPSEC VPN. I was ever-so-kindly pointed to Cisco VPN Group Password Decoder which takes the encrypted password in a VPN profile and gives you the plaintext password.

Now I don’t have to make the trips to the SEASnet lab to check my email :)

Computers, General, Linux