Archive for August, 2008

Software RAID On Linux

Sunday, August 3rd, 2008

A couple of months ago I scored a free computer from one of my brother’s friends because it was broken. It’s some kind of Pentium 4 with 500MB of RAM. With the addition of one of my spare video cards, it was perfect for a backup gaming computer (well, games like Warcraft and BF2).

I had been hosting a couple of websites off my windows Vista computer and decided to move all the server stuff over to that extra computer. So I installed the Linux distro Ubuntu Server on it and moved the computer into my wardrobe, where I administer it from an SSH shell.

I had been hosting a cool website called Ampache, a PHP + MySQL solution that indexes all your music and lets you listen to it anywhere, from a browser (with a login). So the server was serving up the music that was located on my Vista machine, and accessing the music through Windows File Sharing. This was not ideal if I wanted to turn off the Vista computer or play around with OSX86. The hard drive I had in the linux computer was a 40GB, so along with the linux stuff taking up about 5GB, there wasn’t enough space to copy all my music onto it.

So I stuck a spare 30GB hard drive in the server and read up on Software Raid for Linux.

I decided to use the RAID specification called ‘linear’, which basically works by appending partitions together. When the first partition is filled, the next one is used seamlessly, with it all appearing as one partition to the system. But I couldn’t use the 40GB partition which had the Linux operating system on it, otherwise I would lose all the data on that one.

I found a distribution of Linux on DistroWatch.com called ‘Parted Magic’. It’s about 50MB and just contains the tools required to partition your hard drives however you want. I resized the Linux partition to 8GB (non destructively) and used the remaining space for a secondary partition. Combined with the second hard drive and Software RAID, this would give me about 60GB – perfect storage on the server for my music.

Back in Linux now, the steps required for setting up Software RAID were surprisingly few.

  1. Identify the partitions / hdds you will be using for the RAID device, i.e. find out their device names (/dev/sdb1 etc).
  2. Backup your data
  3. Run ‘cat /proc/mdstat‘ to check whether your kernel has RAID support. if the file is non existent, then either your kernel does not support RAID and you need to change it, or you need to load the kernel module. If typing ‘modprobe md‘ is successful, you have loaded the RAID kernel module. You will need to make sure this module is loaded on bootup, so add the ‘md’ module to your kernel startup file. This may be at /etc/modules.autoload, /etc/modules.autoload.d/, /etc/modules.conf or somewhere similar.
  4. Install the mdadm tool by running ‘apt-get install mdadm‘ as root or superuser.
  5. Depending on which type of RAID device you want to setup, refer to the Software RAID Howto for the specific command. Disregard talk of /dev/raidtab and mkraid, just use the mdadm tool. The command I used for a Linear RAID of 2 disks was: ‘mdadm --create --auto yes --verbose /dev/md0 --level=linear --raid-devices=2 /dev/sdb1 /dev/sda3
  6. If that is successful, you will see something like ‘mdadm: chunk size defaults to 64K, mdadm: array /dev/md0 started.‘ This has created your RAID device at /dev/md0
  7. Create ext3 filesystem with ‘/sbin/mkfs -t ext3 /dev/md0
  8. Mount: ‘mkdir /mnt/raid && mount /dev/md0 /mnt/raid
  9. Add entry to /etc/fstab

Excellent, a 60GB combined partition out of 2 hard drives. I could add more in the future if I want. All that was left was to create a SAMBA share, and then setup Synctoy 2.0 to sync my music to the server every night.

Isn’t Wireless Great?

Saturday, August 2nd, 2008

I was stupid and didn’t keep track of my downloads this month, resulting in a ’shaped’ (slowed to 64kbps) internet connection. It would have been easier to keep my sanity if there wasn’t a certain someone in my household constantly using the voice chat feature of Live Messenger. That voice chat seems to take all the crippled bandwidth for itself and doesn’t let anyone basically do anything on the internet. Unless you count 5 minutes to load CNET News ‘using the internet’.

So, I went in search of alternative internet connections, in the form of wifi access points. It was the last day before the end of the month (when my download limit resets), so I wasn’t going to bother cracking someone’s wireless encryption. But luckily I found a new unencrypted wifi access point with my laptop. The only place I could get a connection was near the front window of the house, with the laptop raised above my head.

So I shut down my spare computer which was running linux hosting all this web goodness, put an XP hard drive and wifi pci card in it, put it on top of a chest of drawers in that room and connected it to the wired network.

I wish I had taken a photo of this; it looked ridiculous. The computer at the window with no screen, and a huge stack of books on top of it with an antenna sitting at the top.

I used VNC to remotely configure the XP machine and set up a proxy server on it so I could use my neighbour’s wireless from my computer out the back. Unfortuneately, after all this effort it turned out that my neighbour appeared to have gone over his/her download limit also and their internet was no faster than mine.

I could have taken the time sans internet to catch up on some HSC study, but I instead elected to do something I hadn’t done in a few months and watch commercial TV for more than 10 minutes.