So, I finally got un-lazy yesterday and rebuilt my home web/file server. I've had the pieces/parts for a while now, I just couldn't work up the motivation to actually do the work. Since I was planning on replacing the hard drives wholesale, I decided not to back up the system first, hoping that the current hard drives wouldn't crap out when powered down. Before I began, I took a quick uptime check: 309 days, 22:00 hours. *sniff*. Then I powered it down and opened the case to begin the work.
Wow, the amount of dust and dust bunnies that had built up was kind of epic. I grabbed the home vacuum cleaner and used the hose and soft brush attachment to remove the vast majority of of the dust from the system (had to take out the NIC in order to get behind it). Now the hardware part began. The first thing I did was replace the CMOS battery. In retrospect, I probably should have done that part with the power cord still attached, but I didn't. I'll remember this in the future. The next step was the removal of the two existing hard drives (primary: Seagate Barracuda 160GB, secondary: Western Digital Caviar Blue 500GB), which gave me better access to the RAM slots. After replacing the two 500MB DIMMs with four 1GB DIMMs, I installed the two brand new 1TB Western Digital Blue hard drives and closed the case. Ok, hardware upgrade complete, now for the software upgrade.
My server usually runs headless, but I connected a keyboard and LCD monitor up to it for the OS install. I had previously found some guides for creating a RAID1 array on Slackware (actually, this would work on pretty much any distro), so I popped the Slackware Linux 14.0 DVD (x86-64 side up, of course ;) ) in the drive and powered up the server. During the first part of the Slackware install, you login as root (no password), create your partitions and format them with your desired file system. Setting them up for a RAID1 array isn't much different. The main difference is you choose "FD" (Linux raid partition with autodetect using persistent superblock) for your main partitions, and of course "82" (Linux swap) for you swap partition. If your drives are identical, you only need to partition the first drive (call it /dev/sda). After you've finished with the partitioning, save it and quit. Oh, don't forget to mark your root ("/") partition as bootable! After this, I copied the partition information to my second drive (call it /dev/sdb), using this command:
sfdisk -d /dev/sda | sfdisk /dev/sdb
Once the drives had been properly partitioned, it was time to create the RAID1 arrays. I started with the root partition, then the swap partition, then the /home partition and finally the server partition:
root partition:
mdadm --create /dev/md0 --level 1 --raid-devices 2 /dev/sda2 /dev/sdb2 --metadata=0.90
swap partition:
mdadm --create /dev/md1 --level 1 --raid-devices 2 /dev/sda1 /dev/sdb1
/home partition:
mdadm --create /dev/md2 --level 1 --raid-devices 2 /dev/sda3 /dev/sdb3
/usr/local/pub partition (where the file shares and web server document root will be):
mdadm --create /dev/md3 --level 1 --raid-devices 2 /dev/sda4 /dev/sdb4
After the RAID arrays were created, I ran the "mkswap" command to make the swap partition usable:
mkswap /dev/md1
Now I began the Slackware setup. This followed the standard Slackware install, with the exception of using "/dev/mdx" for the partitions, instead of the usual "/dev/sdx" or "/dev/hdx". After the installation completed, before the first reboot into the system, I had to do a couple more things to ensure the RAID1 arrays would be picked up. The first was to update /etc/lilo.conf to use "/dev/md0" as the boot partition. to do that, you have to chroot into the new build:
chroot /mnt
Then edit /etc/lilo.conf and add this line:
raid-extra-boot = mbr-only
And edit the boot stanza to change it from
"/dev/sdax" to
"/dev/md0".
Exit from the editor and run the /sbin/lilo command to pick up the changes, then exit from chroot and save the RAID1 array data to the /etc/mdadm.conf file:
exit
mdadm -D --scan >> /mnt/etc/mdadm.conf
After this, I rebooted into my new RAID1 array, Slackware-powered file server. The rest was just configuration stuff, getting the web server set up correctly, getting the Subversion repositories set up and running correctly under Apache, copying the files and directories over from the old hard drives and then setting up NFS and Samba for file sharing. I'm still working on the last of it, but for the most part, my web/file server is up and running. Oh, I took an old 1TB Western Digital Caviar drive, put it in my external USB SATA enclosure and set the whole thing up on the top of the file server. I created one huge 1TB partition, formatted as EXT3, and plan to use that to back up the server.
Don't think this all went as smoothly as it shows above. This evolution was a major learning process for me. The first time I set it up and installed Slackware, I had forgotten to store the RAID array information to /etc/mdadm.conf, and on the first reboot, I only had my swap and root partition. I could have recovered from that, but I opted to do the entire thing over again, as a learning experience for me. I also ran into issues because of my faux pas with the CMOS battery. I use a stand-alone NIC on this box, because the internal NIC that is built into the motherboard doesn't work well under Linux (or at least it didn't before), and when I replaced the CMOS battery, that was re-enabled, so I had to fiddle around to disable the internal NIC in CMOS, then figure out how to tell Slackware that the stand-alone NIC was actually eth0.
Here are some of the documents I used to set up the RAID arrays:
Configuring RAID1 on Slackware 12.0
Slackware 14 (Software) RAID Installation on HDD with Advanced Format (4KB sectors)