Debian
2.6.19 Mirror (RAID1) notes
After several years of using a RedHat 2.4 kernel, we upgraded to a
Debian 2.6 Kernel by way of a Knoppix live CD.
These notes come from a RedHat RAID1command
mindset and many years of using Linux (some steps may have been
ommited, because Linux familiarity is assumed.) If you
are starting from scratch with mirroring concepts or Linux, do not
waste your
time here. There is no need to learn Linux commands that are
obsolete. However, we cannot stop you from reading further : )
Most of the RAID
commands (raidhotadd, mkraid, etc) fom RedHat
do not exist on Debian, the /etc/raidtab no longer is used and is
ignored if present.
The main command for RAID on Debian is mdadm
The Knoppix CD, and subsequent hard disk, loads everything
it can find. We had spare mirror drives from the Redhat mirror to use
for the Debian installation, and even though the file type for the
partition was changed from Linux raid autodetect to Linux, the
partitions were automatically started as part of a RAID configuration
(/dev/md0, /dev/md1). The drive partition /dev/hdc2 was unable to be
mounted. I believe the Superblock was detected, which is not visible to
the user.
So, the first time using mdadm command was to stop the mirror: #mdadm
–S /dev/md0
Prior to creation of the RAID1 array, the mirror drive needs to be
partitioned and file systems created (mkswap, mkfs.ext3, mkfs.reiserfs,
etc). You could wait to create the file system till after the RAID1 is
created (mkfs.ext3 /dev/md1), if both drives are empty. The Knoppix CD
created a Reiser File system as a default, which works great and is
fast, but the creator of the file system (Hans Reiser) is in jail for
killing his wife, which turned off many in using the system.
Creation of a mirror drive was not able to be accomplished for the
active partition. Several attempts were made to write a superblock
manually, but the partition was busy or the device /dev/md1 could not
be found (Knoppix live CD). The primary mirror drive (the one with all
the data) needs to be made a mirror by another drive running Debian and
not a mirror drive – no superblock, as follows:
#mdadm –create –verbose /dev/md1 –level=1
–-raid-devices=2 missing /dev/hdd2
(/dev/hdd2 is the drive to be made a mirror drive, the boot drive was /dev/hda2 non-RAID)
After substituting the newly created mirror drive /dev/hdd2 as
/dev/hda2, then rebooting (check entries in /etc/grub/menu.lst and
/etc/fstab ex.
Substitute /dev/hda2 with /dev/md1) [possibly need Linux rescue disk
and vi editor], when the other mirror drive is
available, the command would be:
#mdadm –a /dev/md1 /dev/hdd2 (essentially the raidhotadd
command; drive /dev/hda2 is already part of the RAID array /dev/md1, created above --^)
A fast way to make a mirror drive from a blank disk:
Copy the MBR and partitions from the RAID1 drive #dd
if=/dev/hda of=/dev/hdc for 30 seconds, then ctrl+C. Make the
respective file systems # mkwap /dev/hdc1 # mkfs.reiserfs
/dev/hdc2 Reboot, then: #mdadm –a /dev/md1
/dev/hdc2 #mdadm –a /dev/md0 /dev/hdc1
When trying to get mirroring working, /dev/md1 would not start because
/dev/hda2 was pre-mounted (/etc/initramfs-tools/scripts/local-premount)
for the boot from /boot/grub/menu.lst. So, /dev/md1 needed to be
specified in menu.lst instead of /dev/hda2. In the
process of trying various methods of making a superblock, the
partition with the Reiser FS needed to be repaired:
#fsck.reiserfs –a –rebuild-sb /dev/md1
If one of the RAID1 partitions is swap space (/dev/md0), /etc/fstab
should have the entry:
/dev/md0 none swap sw 0 0
Initially there was a problem with the swap partition not being recognized.
Another method to get the swap space mounted was to put a line in a
startup script:
In /etc/rc.local :
/sbin/swapon /dev/md0
The command free displays the usage of memory, in particular to note was the swap space being availabe.
#free
total used
free
shared buffers
cached
Mem:
482760 428460
54300
0
50408
83096
-/+ buffers/cache:
294956 187804
Swap:
1024076
64 1024012
/etc/mdadm/mdadm.conf
DEVICE /dev/hda1 /dev/hdc1 /dev/hda2 /dev/hdc2
ARRAY /dev/md0 level=raid1 devices=/dev/hda1,/dev/hdc1
ARRAY /dev/md1 level=raid1 devices=/dev/hda2,/dev/hdc2
#mdadm --examine /dev/hda2
dev/hda2:
Magic : a92b4efc
Version : 00.90.00
UUID : c397a21e:47354420:e759641f:3b75dba8
Creation Time : Fri Dec 12 09:15:06 2008
Raid Level : raid1
Used Dev Size : 18526976 (17.67 GiB 18.97 GB)
Array Size : 18526976 (17.67 GiB 18.97 GB)
Raid Devices : 2
Total Devices : 2
Preferred Minor : 1
Update Time : Tue Dec 23 17:32:36 2008
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Checksum : 6a760d21 - correct
Events : 1482
Number Major Minor RaidDevice State
this 0
3 2
0 active sync /dev/hda2
0
0 3 2
0 active sync
/dev/hda2
1
1 22 2
1 active sync
/dev/hdc2
#mdadm --examine /dev/hda1
/dev/hda1:
Magic : a92b4efc
Version : 1.0
Feature Map : 0x0
Array UUID : 86347328:98224399:d51be4df:d918f459
Name : 0
Creation Time : Thu Dec 11 15:58:42 2008
Raid Level : raid1
Raid Devices : 2
Avail Dev Size : 2048168 (1000.25 MiB 1048.66 MB)
Array Size : 2048168 (1000.25 MiB 1048.66 MB)
Super Offset : 2048176 sectors
State : clean
Device UUID : abbbb8f4:c08bdec4:cc4ed625:128f831f
Update Time : Tue Dec 23 16:00:57 2008
Checksum : 369d92dd - correct
Events : 6
Array Slot : 1 (failed, 1, 0)
Array State : uU 1 failed
#mdadm --detail /dev/md0
/dev/md0:
Version : 01.00
Creation Time : Thu Dec 11 15:58:42 2008
Raid Level : raid1
Array Size : 1024084 (1000.25 MiB 1048.66 MB)
Used Dev Size : 1024084 (1000.25 MiB 1048.66 MB)
Raid Devices : 2
Total Devices : 2
Preferred Minor : 0
Persistence : Superblock is persistent
Update Time : Tue Dec 23 16:00:57 2008
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Name : 0
UUID : 86347328:98224399:d51be4df:d918f459
Events : 6
Number Major Minor RaidDevice State
2 22 1
0 active sync
/dev/hdc1
1 3 1
1 active sync
/dev/hda1
#mdadm --detail /dev/md1
/dev/md1:
Version : 00.90
Creation Time : Fri Dec 12 09:15:06 2008
Raid Level : raid1
Array Size : 18526976 (17.67 GiB 18.97 GB)
Used Dev Size : 18526976 (17.67 GiB 18.97 GB)
Raid Devices : 2
Total Devices : 2
Preferred Minor : 1
Persistence : Superblock is persistent
Update Time : Tue Dec 23 17:41:37 2008
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
UUID : c397a21e:47354420:e759641f:3b75dba8
Events : 0.1482
Number Major Minor RaidDevice State
0 3 2
0 active sync
/dev/hda2
1 22 2
1 active sync
/dev/hdc2
Brought
to you by - Droit
Technologies, Inc. www.droittech.com
PO Box 322
Carlstadt, NJ 07072