Various nuggets of useful technical information.

Thursday, June 19, 2008

Adding Raid and Swap Partitions on RedHat 9.0

This applies to Redhat 9.0, I cannot confirm that it applies to Redhat 9.0- but it may. All the same it is a good starting point for RAID configuration troubleshooting on Redhat archs.

Note on Disk Drive Support:
If adding a new physical hard disk, ensure that you either use a standard type of drive, like IDE or a drive that is of the same type as a drive that already exists in the installation.

RH does not recognize SATA or certain types of EIDE.
RH may need additional drivers for special types of SCSI drives.

Adding additional drivers to the boot loader and kernel is non-trivial, try to avoid at all costs. Simply have a look at the machine and either add a drive of the same type or add a standard IDE drive.

If adding SCSI drives ensure the pins on the SCSI chip are such that:
The drive is detected as the last drive in a SCSI chain (if an additional drive)
The drive is detected in the same place/order as the SCSI drive it is replacing (if a replacement drive)

Adding a RAID partition:
Once the drive is in place, see if it is detected at boot time. If not, perhaps it is either:
not plugged in properly - check pin jumper settings for both SCSI and IDE drives
not supported - try a different (type of) drive.

Once the drive is detected, see where it shows up in /dev
SCSI drives are normally /dev/sdX where X is the letter of the drive in the order it shows up on the SCSI chain. /dev/sda is the first one
IDE drives are normally /dev/hdX where X is a-f depending on the IDE controller and whether it is Master or Slave. Normally Masters are hd[ace]. Slaves are hd[bdf].

Let's assume that we added a supported SCSI disk and it was detected as /dev/sda.

Partition the drive using fdisk:
#cd /dev
#fdisk sde

Create a new partition on it:
Command (m for help): p

Disk sda: 36.7 GB, 36748945408 bytes
255 heads, 63 sectors/track, 4467 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
sda1 1 128 1028128+ 83 Linux

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (129-4467, default 129):
Using default value 129
Last cylinder or +size or +sizeM or +sizeK (129-4467, default 4467):
Using default value 4467

Change the partition type if necessary:
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): L

0 Empty 1c Hidden Win95 FA 70 DiskSecure Mult bb Boot Wizard hid
1 FAT12 1e Hidden Win95 FA 75 PC/IX be Solaris boot
2 XENIX root 24 NEC DOS 80 Old Minix c1 DRDOS/sec (FAT-
3 XENIX usr 39 Plan 9 81 Minix / old Lin c4 DRDOS/sec (FAT-
4 FAT16 <32m>
5 Extended 40 Venix 80286 83 Linux c7 Syrinx
6 FAT16 41 PPC PReP Boot 84 OS/2 hidden C: da Non-FS data
7 HPFS/NTFS 42 SFS 85 Linux extended db CP/M / CTOS / .
8 AIX 4d QNX4.x 86 NTFS volume set de Dell Utility
9 AIX bootable 4e QNX4.x 2nd part 87 NTFS volume set df BootIt
a OS/2 Boot Manag 4f QNX4.x 3rd part 8e Linux LVM e1 DOS access
b Win95 FAT32 50 OnTrack DM 93 Amoeba e3 DOS R/O
c Win95 FAT32 (LB 51 OnTrack DM6 Aux 94 Amoeba BBT e4 SpeedStor
e Win95 FAT16 (LB 52 CP/M 9f BSD/OS eb BeOS fs
f Win95 Ext'd (LB 53 OnTrack DM6 Aux a0 IBM Thinkpad hi ee EFI GPT
10 OPUS 54 OnTrackDM6 a5 FreeBSD ef EFI (FAT-12/16/
11 Hidden FAT12 55 EZ-Drive a6 OpenBSD f0 Linux/PA-RISC b
12 Compaq diagnost 56 Golden Bow a7 NeXTSTEP f1 SpeedStor
14 Hidden FAT16 <3>
16 Hidden FAT16 61 SpeedStor a9 NetBSD f2 DOS secondary
17 Hidden HPFS/NTF 63 GNU HURD or Sys ab Darwin boot fd Linux raid auto
18 AST SmartSleep 64 Novell Netware b7 BSDI fs fe LANstep
1b Hidden Win95 FA 65 Novell Netware b8 BSDI swap ff BBT
Hex code (type L to list codes): fd

Command (m for help): p

Disk sda: 36.7 GB, 36748945408 bytes
255 heads, 63 sectors/track, 4467 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
sda1 1 128 1028128+ 83 Linux
sda2 129 4467 34853017+ fd Linux

Save the partition:
Command (m for help): w
Writing table to disk..

Create a new RAID parition:
#mdadm --create /dev/mdX --level= --raid-devices= --spare-devices= /dev/[hs]dX /dev/[hs]dY

Look at manpage for mdadm for more details.

Verify the new RAID device:
# cat /proc/mdstat
Personalities : [raid1] [raid5]
read_ahead 1024 sectors
md2 : active raid1 sde1[1] sda1[0]
1028032 blocks [2/2] [UU]

md0 : active raid5 sdd1[2] sdc1[1] sdb1[0]
143636864 blocks level 5, 64k chunk, algorithm 0 [3/3] [UUU]

unused devices:

Format the new partition:
mkfs -t -c /dev/mdX

Save the data located on the mount_point:
If the mount point is located on device(s) that make up the new RAID device, then copy over the contents of the entire mount_point elsewhere*
If the mount point is located on device(s) that do not make up the new RAID device, nothing needs to be done.
If you are about to mount a new mount_point then nothing needs to be done.

Unmount the mount point if necessary:
umount /mount_point

Remount the mount point:
mount /dev/mdX /mount_point
If the mount point was located on device(s) that now make up the new RAID device, then copy over the contents of the entire mount_point that were copied over elsewhere*

Verify the mount:
# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/md0 141382888 24337024 109864024 19% /
/dev/md2 1011864 21748 938716 3% /boot
none 1804184 0 1804184 0% /dev/shm
10.243.102.3:/var/www/html/ca
141267544 60599344 73492000 46% /var/www/html/ca

Modify /etc/fstab:
Change the entry for this mount_point in /etc/fstab or add a new entry for it
/dev/md2 /boot ext2 defaults 1 2

Add the new RAID device into /etc/raidtab:
This is very important as in RH, creating a raid device does not add it to /etc/raidtab. /etc/raidtab is where RH installations look for and register raid devices from.

Edit /etc/raidtab and add the following lines at the end depending on the type of raid device you created:

raiddev /dev/md2
raid-level 1
nr-raid-disks 2
chunk-size 64k
persistent-superblock 1
nr-spare-disks 0
device /dev/sda1
raid-disk 0
device /dev/sde1
raid-disk 1

Save the file.

Verify that /etc/fstab has the mount_point mounted on the new RAID device, check that the mount_point has the necessary data in it and reboot.

--------------

Adding a SWAP device:

Add the disk drive.

Use fdisk to create the swap partitions:
fdisk

Format them as swap partitions:
mkswap

Start them:
Either add them to fstab and reboot.

or start them from the command line:
swapon

or add them to fstab and start them all at once:
swapon -a