Saturday, July 28, 2007

Installing Slackware 12 on Linux Software RAID and LVM2

This article describes how I installed Slackware 12 onto Linux Software RAID partitions and LVM logical volumes. It is the first time I played with Software RAID and LVM.

In my case, the root filesystem is installed on a RAID-1 partition (non-LVM), and other filesystems (like /home, /tmp, and swap) are on LVM logical volumes on top of RAID-1 or RAID-0 arrays. I read from somewhere (and I concur) that it is not necessary and not good to put root partition into LVM, because if anything screws up, it is easier to get into root partition and do recovery if you don't have to deal with LVM. If you run into space problems with root filesystem later, you can always move some directories to another filesystem and change the mount points easily. I still want the root filesystem to be on RAID because I want the redundancy and speed gain on reads.

Hardware InstallationI have a PC with:- Pentium D 930 CPU- Gigabyte GA-8i945GMH-RH motherboard- Seagate 80GB IDE harddisk.The motherboard supports up to 2 IDE and 4 SATA devices. I bought 2 more Seagate 7200.10 320GB SATA2 harddisks (at S$126 each, from Best Bargin, Sim Lim Square).What to take note here is that you need SATA cable and SATA power cable to connect the harddisks to your PC. If they don't come with the harddisk or motherboard, you have to buy separately. I paid S$2 for one SATA cable, and S$3 for one SATA power cable.

Installing the harddisks is straightforward if you follow your motherboard manual, or you have basic PC assembling knowledge.

After that, make appropriate setting changes in the BIOS. I don't plan to use the on-board RAID chipset, because it cannot create RAID arrays out of partitions. So I did not enable the RAID mode in BIOS. Instead I just enabled the SATA controller so that the SATA disks can be detected by the BIOS.

Note: Originally I plan to install Windows on some logical partition, but I encountered some problems. Seems like Windows cannot be installed onto logical partitions, but I am not sure.

Installing SlackwareGet ready the following things:-Slackware 12 Installation CDs (I only burned CD1)- Slackware 12 installation files (I downloaded selected directories from a mirror site using wget) in one of your harddisk partition (I put them into my USB harddisk), because I plan to use the option to copy files from a harddisk partition.- Grub 0.97 package from extra directory (I plan to use Grub instead of Lilo).

Boot up using Installation CD1, using the default image (huge.s) to have mdadm and LVM available.

Use fdisk/cfdisk to partition the two harddisks. In my PC they are under /dev/sda and /dev/sdb respectively. I want identical partitions in the two, so I can use the following command to duplicate sda's partitions to sdb.

Set up swap filesystem (do this manually because Slackware Setup program cannot detect swap filesystems on LVM):mkswap /dev/raid0_vg0/swapswapon /dev/raid0_vg0/swap

Run Setup:setup

Skip the ADDSWAP step because I want the swap filesystem on LV but it will not look inside the LVs.

At TARGET step, I choose /dev/md2 for root (/) (ext3), /dev/raid1_vg0/slackware_home as /home (reiserfs), /dev/raid0_vg0/slackware_tmp as /tmp (reiserfs). Here what filesystem you want to use is up to individual test. Do take note that since Slackware 12, the default filesystem is changed from reiserfs to ext3, probably because of the uncertain future of reiserfs...I also specify /dev/sda1 to be mounted as /mnt/windows-xp, and /dev/sdb1 as /mnt/windows-data.

At SOURCE step, I choose Install from a hard drive partition, then specify the partition (dev/sdc5) and path of the installation files in my USB harddisk.

After that, select the packages and install them to the selected partitions. (I choose all since I don't want to spend too much time picking through the packages)I then go through the CONFIGURE step as per normal, but skip LILO installation. I did not create a USB boot stick because I don't have a spare one.

After that, exit the Setup program, but do not reboot first. Still need to do a couple of things:

- Install grub. By now the root filesystem of the installed system is mounted to /mnt, so:chroot /mntinstallpkg /grub-0.97-i486-3.tgzmkdir /boot/grub; cp /usr/lib/grub/i386-pc/* /boot/grub

Exit chroot.

- Create menu.lst under /boot/grub (better prepare it in advance in case you forgot the syntax). My grub entry for Slackware:

- Run vgscan to create /etc/lvm/backup, which is checked by the init scripts in order to enable LVM (for details see /etc/rc.d/rc.S).chroot /mntvgscan -v

Exit chroot.

Now reboot. After rebooting, you should see the login prompt. Go in and check if everything is started and mounted correctly.

Points to Note- The Generic Slackware kernels cannot boot from root partitions on RAID, so the Huge kernel should be used. (It probably can with some initrd, but I didn't try that.)- Be careful when you change your harddisk partitions. Because there is RAID arrays and PV/VG/LVs created on top of the partitions, deleting existing partitions may screw up those. Always make sure there is no existing RAID arrays or PVs using them first. See if you really need to change the partitions - after all with LVM it may not be necessary to change partitions directly. Try changing the LVs instead.

To remove the PV/LVs, use lvremove, vgreduce, and pvremove commands. To remove a partition or harddisk from a RAID array, use mdadm --zero-superblock to erase the RAID superblock from the device. The superblock is a 4K block of data written near the end of the device. It contains information for the array and the member devices. It allows the kernel to automatically start arrays when the system boots.

- If you did not manage to complete the installation process after you have created the RAID arrays and LVM stuff, you can do the following:mdadm --assemble /dev/md0 /dev/sd[ab]5 # manually specify the RAID array and it member devicesOR mdadm --assemble --scan /dev/md[0-2] # just specify the RAID arrayOR mdadm --assemble --scan --config= # assemble all MD devices using mdadm.confvgscan # detect all VGs

8 comments:

Anonymous
said...

thanks for this howto. however im having difficulty configuring grub. my root filesystem (/) is installed on top of a logical volume. what should be my root= ??? i tried the root=UUID=number and i've also tried root=/dev/VG/slackwarefs. any suggestions? i get the following error: