Saturday, January 11, 2014

mirror root disk

=============================================================
==========================================
RHEL5.5 x86_64 tested documentation version:1.0
=============================================================
==========================================
Requiremnt:
1) two disk with same size:like 20GB hear
2) mdadm package is required if not then install it
#rpm -qa mdadm
3)
#####
If VM then you have to be a sufficient space for the disk becz when it sysc first time it will
take space from the physical disk
###
when disk fail & then we add new disk at that time it required more space becz at that
time also sync happen between the disk
######========================================================
=====================================
testing have to be done at 20GB at list becz that will justify the production
environment
=============================================================
==========================================
########------------------------------------------------------------------
#############################
=============================================================
============================
Checking the disk structure & partition assign at which mount point
=============================================================
===========================
[root@pant ~]# fdisk -l
^[[A
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1925 15358140 83 Linux
/dev/sda3 1926 2056 1052257+ 82 Linux swap / Solaris
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
[root@pant ~]#
[root@pant ~]#
=============================================================
=========================
same partition structure assign to another disk which is also the same in size like sda
sda structure print over sdb
=============================================================
=========================
[root@pant ~]# sfdisk -d -f /dev/sda > mirror
[root@pant ~]# sfdisk /dev/sdb < mirror
Checking that no-one is using this disk right now ...
OK
Disk /dev/sdb: 2610 cylinders, 255 heads, 63 sectors/track
Old situation:
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0
Device Boot Start End #cyls #blocks Id System
/dev/sdb1 0 - 0 0 0 Empty
/dev/sdb2 0 - 0 0 0 Empty
/dev/sdb3 0 - 0 0 0 Empty
/dev/sdb4 0 - 0 0 0 Empty
New situation:
Units = sectors of 512 bytes, counting from 0
Device Boot Start End #sectors Id System
/dev/sdb1 * 63 208844 208782 83 Linux
/dev/sdb2 208845 30925124 30716280 83 Linux
/dev/sdb3 30925125 33029639 2104515 82 Linux swap / Solaris
/dev/sdb4 0 - 0 0 Empty
Successfully wrote the new partition table
Re-reading the partition table ...
If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)
[root@pant ~]# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1925 15358140 83 Linux
/dev/sda3 1926 2056 1052257+ 82 Linux swap / Solaris
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 13 104391 83 Linux
/dev/sdb2 14 1925 15358140 83 Linux
/dev/sdb3 1926 2056 1052257+ 82 Linux swap / Solaris
=============================================================
==========================================
partition assign as raid identification number "FD"
=============================================================
==========================================
[root@pant ~]# fdisk /dev/sdb
The number of cylinders for this disk is set to 2610.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): fd
Changed system type of partition 1 to fd (Linux raid autodetect)
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): fd
Changed system type of partition 2 to fd (Linux raid autodetect)
Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): fd
Changed system type of partition 3 to fd (Linux raid autodetect)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@pant ~]# partprobe /dev/sdb
=============================================================
=========================
creating raid with missing in a order as per the system partition
=============================================================
=========================
[root@pant ~]# mdadm --create /dev/md0 --level=1 --raid-disks=2 missing /dev/sdb1
v/sdb1
mdadm: array /dev/md0 started.
[root@pant ~]# mdadm --create /dev/md1 --level=1 --raid-disks=2 missing /dev/sdb2
v/sdb2
mdadm: array /dev/md1 started.
[root@pant ~]# mdadm --create /dev/md2 --level=1 --raid-disks=2 missing /dev/sdb3
v/sdb3
mdadm: array /dev/md2 started.
[root@pant ~]# cat /proc/mdstat
Personalities : [raid1]
md2 : active raid1 sdb3[1]
1052160 blocks [2/1] [_U]
md1 : active raid1 sdb2[1]
15358016 blocks [2/1] [_U]
md0 : active raid1 sdb1[1]
104320 blocks [2/1] [_U]
unused devices: <none>
[root@pant ~]# mkfs.ext3 /dev/md0
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
26104 inodes, 104320 blocks
5216 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
13 block groups
8192 blocks per group, 8192 fragments per group
2008 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 35 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@pant ~]# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1925 15358140 83 Linux
/dev/sda3 1926 2056 1052257+ 82 Linux swap / Solaris
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 13 104391 fd Linux raid aut
/dev/sdb2 14 1925 15358140 fd Linux raid aut
/dev/sdb3 1926 2056 1052257+ fd Linux raid aut
Disk /dev/md0: 106 MB, 106823680 bytes
2 heads, 4 sectors/track, 26080 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Disk /dev/md0 doesn't contain a valid partition table
Disk /dev/md1: 15.7 GB, 15726608384 bytes
2 heads, 4 sectors/track, 3839504 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Disk /dev/md1 doesn't contain a valid partition table
Disk /dev/md2: 1077 MB, 1077411840 bytes
2 heads, 4 sectors/track, 263040 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Disk /dev/md2 doesn't contain a valid partition table
[root@pant ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 15G 2.2G 12G 17% /
/dev/sda1 99M 12M 83M 13% /boot
tmpfs 501M 0 501M 0% /dev/shm
/dev/hdc 3.5G 3.5G 0 100% /media/RHEL_5.5 x86_64 DVD
=============================================================
=============================
root partition of raid formatted
=============================================================
=============================
[root@pant ~]# mkfs.ext3 /dev/md1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1921984 inodes, 3839504 blocks
191975 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=3934257152
118 block groups
32768 blocks per group, 32768 fragments per group
16288 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632,
2654208
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 38 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
=============================================================
=======================
boot partition in raid formatted
=============================================================
=======================
[root@pant ~]# mkfs.ext3 /dev/md0
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
26104 inodes, 104320 blocks
5216 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
13 block groups
8192 blocks per group, 8192 fragments per group
2008 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 35 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
=============================================================
================================
swap raid partition assign to md2
=============================================================
================================
[root@pant ~]# mkswap /dev/md2
Setting up swapspace version 1, size = 1077407 kB
=============================================================
=====================
UUID of raid register mdadm file for booting
=============================================================
=====================
[root@pant ~]# mdadm --examine --scan > /etc/mdadm.conf
[root@pant ~]# cat /etc/mdadm.conf
ARRAY /dev/md0 level=raid1 num-devices=2 UUID=2bd2f52c:0a0fd464:8fd6fb
ARRAY /dev/md1 level=raid1 num-devices=2 UUID=3c983aa9:4ff137c0:699a7e
ARRAY /dev/md2 level=raid1 num-devices=2 UUID=d7464ff4:568cef5a:d82924
=============================================================
====================
create & mounting the directory & filesystem to take backup of /,/boot,swap
=============================================================
=====================
[root@pant ~]# mkdir /mnt/mdo
[root@pant ~]# mkdir /mnt/md1
[root@pant mnt]# mount /dev/md0 /mnt/md0
[root@pant mnt]# mount /dev/md1 /mnt/md1
=============================================================
=====================
Mount point check & ideal to change as per raid disk installed
=============================================================
======================
[root@pant mnt]# mount
/dev/sda2 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/hdc on /media/RHEL_5.5 x86_64 DVD type iso9660 (ro,noexec,nosuid,
nodev,uid=0)
/dev/md0 on /mnt/md0 type ext3 (rw)
/dev/md1 on /mnt/md1 type ext3 (rw)
=============================================================
====================
Now we will change the partition name which is mounted in /,boot,swap
=============================================================
====================
[root@pant mnt]# vi /etc/fstab
[root@pant ~]# cat /etc/fstab
/dev/md1 / ext3 defaults 1 1
/dev/md0 /boot ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/md2 swap swap defaults 0 0
[root@pant ~]#
=============================================================
same has to be done in mtab
============================================================
[root@pant ~]# vi /etc/mtab
/dev/md1 / ext3 rw 0 0
proc /proc proc rw 0 0
sysfs /sys sysfs rw 0 0
devpts /dev/pts devpts rw,gid=5,mode=620 0 0
/dev/md0 /boot ext3 rw 0 0
tmpfs /dev/shm tmpfs rw 0 0
none /proc/sys/fs/binfmt_misc binfmt_misc rw 0 0
sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw 0 0
~~
=============================================================
=====================================
enter the line grub/menu.1st fallback=1 entry
first kernel is 0 (default=0) & second (fallback=1)is 1 when it fail from o disk go to 1
=============================================================
=======================================
[root@pant mnt]# vi /boot/grub/menu.lst
=============================================================
=======================================
default=0
fallback=1
timeout=5
=============================================================
========================================
=============================================================
========================================
now change the disk booting disk & root disk inforation root=LABEL=/ with
root=/dev/md2 and root (hd0,0)
with root (hd1,0):
hd1,0=/dev/sdb
hd0,0=/dev/sda
Mean now "sda" fail then it will boot from "sdb"
=============================================================
========================================
title Red Hat Enterprise Linux Server (2.6.18-194.el5)
root (hd1,0)
kernel /vmlinuz-2.6.18-194.el5 ro root=/dev/md1 rhgb quiet
initrd /initrd-2.6.18-194.el5.img
title Red Hat Enterprise Linux Server (2.6.18-194.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-194.el5 ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.18-194.el5.img
=============================================================
===================
initrd back & reconstruct
=============================================================
====================
[root@pant mnt]# mv /boot/initrd-`uname -r`.img /boot/initrd-`uname -r`.img_orig
[root@pant mnt]# mkinitrd /boot/initrd-`uname -r`.img `uname -r`
=============================================================
========================
now / & boot disk copy to the respective raid disk
=============================================================
========================
[root@pant mnt]# cp -dpRx / /mnt/md1
cp: preserving permissions for `/mnt/md1/var/run/cups/certs/0': Operation not
supported
cp: preserving ACL for `/mnt/md1/var/run/cups/certs/0': Operation not supported
[root@pant mnt]# cd /boot/
[root@pant boot]# ls
config-2.6.18-194.el5 initrd-2.6.18-194.el5.img_orig System.map-2.6.18-194.el5
grub lost+found vmlinuz-2.6.18-194.el5
initrd-2.6.18-194.el5.img symvers-2.6.18-194.el5.gz
[root@pant boot]# cp -dpRx . /mnt/
md0/ md1/ q
[root@pant boot]# cp -dpRx . /mnt/md0
=============================================================
==================================
=============================================================
===================================
Now grub load install in "sdb" second disk which is used as raid mirror disk
=============================================================
======================================
=============================================================
======================================
[root@pant boot]# grub
\Probing devices to guess BIOS drives. This may take a long time.
GNU GRUB version 0.97 (640K lower / 3072K upper memory)
[ Minimal BASH-like line editing is supported. For the first word, TAB
lists possible command completions. Anywhere else TAB lists the possible
completions of a device/filename.]
grub> root (hd0,0)
\root (hd0,0)
Error 27: Unrecognized command
=============================================================
=================================
grub> root (hd0,0)
root (hd0,0)
Filesystem type is ext2fs, partition type 0x83
grub> setup (hd0)
setup (hd0)
Checking if "/boot/grub/stage1" exists... no
Checking if "/grub/stage1" exists... yes
Checking if "/grub/stage2" exists... yes
Checking if "/grub/e2fs_stage1_5" exists... yes
Running "embed /grub/e2fs_stage1_5 (hd0)"... 15 sectors are embedded.
succeeded
Running "install /grub/stage1 (hd0) (hd0)1+15 p (hd0,0)/grub/stage2
/grub/grub.conf"... succeed ed
Done.
=============================================================
===================================
grub> root (hd1,0)
root (hd1,0)
Filesystem type is ext2fs, partition type 0xfd
grub> setup (hd1)
setup (hd1)
Checking if "/boot/grub/stage1" exists... no
Checking if "/grub/stage1" exists... yes
Checking if "/grub/stage2" exists... yes
Checking if "/grub/e2fs_stage1_5" exists... yes
Running "embed /grub/e2fs_stage1_5 (hd1)"... 15 sectors are embedded.
succeeded
Running "install /grub/stage1 (hd1) (hd1)1+15 p (hd1,0)/grub/stage2
/grub/grub.conf"... succeed ed
Done.
=============================================================
==================================
grub> quit
quit
=============================================================
========================================
check the system whether is come up after reboot
=============================================================
=========================================
[root@pant boot]# reboot
Broadcast message from root (pts/3) (Sat Jun 9 00:12:38 2012):
The system is going down for reboot NOW!
=============================================================
=========================================
system is up now check the status of the raid disk
=============================================================
========================================
[root@pant ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/md1 15G 2.2G 12G 16% /
/dev/md0 99M 15M 80M 16% /boot
tmpfs 501M 0 501M 0% /dev/shm
[root@pant ~]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb1[1]
104320 blocks [2/1] [_U]
md2 : active raid1 sdb3[1]
1052160 blocks [2/1] [_U]
md1 : active raid1 sdb2[1]
15358016 blocks [2/1] [_U]
unused devices: <none>
=============================================================
========================================
so Now we can change the main disk of OS "sda" into raid convention for Raid
autodetect
=============================================================
========================================
[root@pant ~]# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1925 15358140 83 Linux
/dev/sda3 1926 2056 1052257+ 82 Linux swap / Solaris
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 13 104391 fd Linux raid autodetect
/dev/sdb2 14 1925 15358140 fd Linux raid autodetect
/dev/sdb3 1926 2056 1052257+ fd Linux raid autodetect
Disk /dev/md1: 15.7 GB, 15726608384 bytes
2 heads, 4 sectors/track, 3839504 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Disk /dev/md1 doesn't contain a valid partition table
Disk /dev/md2: 1077 MB, 1077411840 bytes
2 heads, 4 sectors/track, 263040 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Disk /dev/md2 doesn't contain a valid partition table
Disk /dev/md0: 106 MB, 106823680 bytes
2 heads, 4 sectors/track, 26080 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Disk /dev/md0 doesn't contain a valid partition table
[root@pant ~]# fdisk /dev/sda
The number of cylinders for this disk is set to 2610.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): fd
Changed system type of partition 1 to fd (Linux raid autodetect)
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): fd
Changed system type of partition 2 to fd (Linux raid autodetect)
Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): fd
Changed system type of partition 3 to fd (Linux raid autodetect)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
=============================================================
=========================================
Now we have to add disk in mirror raid in a same respective order
=============================================================
========================================
[root@pant ~]# mdadm --add /dev/md0 /dev/sda1
mdadm: added /dev/sda1
[root@pant ~]# mdadm --add /dev/md1 /dev/sda2
[root@pant ~]# mdadm --add /dev/md1 /dev/sda2
mdadm: added /dev/sda2
[root@pant ~]# mdadm --add /dev/md2 /dev/sda3
mdadm: added /dev/sda3
=============================================================
=========================================
now check the online status of the disk sync
=============================================================
=========================================
[root@pant ~]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sda1[0] sdb1[1]
104320 blocks [2/2] [UU]
md2 : active raid1 sda3[2] sdb3[1]
1052160 blocks [2/1] [_U]
resync=DELAYED
md1 : active raid1 sda2[2] sdb2[1]
15358016 blocks [2/1] [_U]
[>....................] recovery = 2.0% (313984/15358016) finish=19.1min
speed=13082K/sec
=============================================================
=========================================
=============================================================
=========================================
Now a after add disk now the uuid also have some change so we have to change it as
current status
=============================================================
=======================================
[root@pant ~]# mdadm --examine --scan > /etc/mdadm.conf
[root@pant ~]# cat /etc/mdadm.conf
ARRAY /dev/md0 level=raid1 num-devices=2
UUID=2bd2f52c:0a0fd464:8fd6fba9:1a717394
ARRAY /dev/md1 level=raid1 num-devices=2
UUID=3c983aa9:4ff137c0:699a7e3d:917ceacb
ARRAY /dev/md2 level=raid1 num-devices=2
UUID=d7464ff4:568cef5a:d8292475:d04e25bb
=============================================================
=======================================
Now we have to change the boot order when sdb fail then sda should boot or viseversa,
delted the previous
entry
=============================================================
========================================
title Red Hat Enterprise Linux Server (2.6.18-194.el5)
root (hd1,0)
kernel /vmlinuz-2.6.18-194.el5 ro root=/dev/md1 rhgb quiet
initrd /initrd-2.6.18-194.el5.img
title Red Hat Enterprise Linux Server (2.6.18-194.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-194.el5 ro root=/dev/md1 rhgb quiet
initrd /initrd-2.6.18-194.el5.img
=============================================================
===========================================
deleted the given below entry
=============================================================
==========================================
title Red Hat Enterprise Linux Server (2.6.18-194.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-194.el5 ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.18-194.el5.img
=============================================================
===========================================
after that initrd also change so get the backup of initrd & restucture it
=============================================================
=========================================
[root@pant ~]# mv /boot/initrd-`uname -r`.img /boot/initrd-`uname -r`.img_orig2
[root@pant ~]# mkinitrd /boot/initrd-`uname -r`.img `uname -r`
=============================================================
==========================================
Now reboot the server & check whether it come up or fail
=============================================================
==========================================
[root@pant ~]# reboot
Broadcast message from root (pts/1) (Sat Jun 9 00:59:24 2012):
The system is going down for reboot NOW!
=============================================================
==========================================
[root@pant ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/md1 15G 2.2G 12G 16% /
/dev/md0 99M 17M 77M 19% /boot
tmpfs 501M 0 501M 0% /dev/shm
[root@pant ~]# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 fd Linux raid autodetect
/dev/sda2 14 1925 15358140 fd Linux raid autodetect
/dev/sda3 1926 2056 1052257+ fd Linux raid autodetect
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 13 104391 fd Linux raid autodetect
/dev/sdb2 14 1925 15358140 fd Linux raid autodetect
/dev/sdb3 1926 2056 1052257+ fd Linux raid autodetect
Disk /dev/md1: 15.7 GB, 15726608384 bytes
2 heads, 4 sectors/track, 3839504 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Disk /dev/md1 doesn't contain a valid partition table
Disk /dev/md2: 1077 MB, 1077411840 bytes
2 heads, 4 sectors/track, 263040 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Disk /dev/md2 doesn't contain a valid partition table
Disk /dev/md0: 106 MB, 106823680 bytes
2 heads, 4 sectors/track, 26080 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Disk /dev/md0 doesn't contain a valid partition table
[root@pant ~]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb1[1] sda1[0]
104320 blocks [2/2] [UU]
md2 : active raid1 sdb3[1] sda3[0]
1052160 blocks [2/2] [UU]
md1 : active raid1 sdb2[1] sda2[0]
15358016 blocks [2/2] [UU]
unused devices: <none>
[root@pant ~]#
=============================================================
=========================================
TESTING THE RAID IF SOME DISK FAILS THEN
RAID WILL WORK OR NOT
=============================================================
=========================================
NOW testing if we remove disk from the raid what happen the system wakeup
of or not
=============================================================
===========================================
check the state of the disk & partition
=============================================================
===========================================
[root@pant ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/md1 15G 2.3G 12G 17% /
/dev/md0 99M 17M 77M 19% /boot
tmpfs 501M 0 501M 0% /dev/shm
[root@pant ~]# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 fd Linux raid autodetect
/dev/sda2 14 1925 15358140 fd Linux raid autodetect
/dev/sda3 1926 2056 1052257+ fd Linux raid autodetect
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 13 104391 fd Linux raid autodetect
/dev/sdb2 14 1925 15358140 fd Linux raid autodetect
/dev/sdb3 1926 2056 1052257+ fd Linux raid autodetect
Disk /dev/md1: 15.7 GB, 15726608384 bytes
2 heads, 4 sectors/track, 3839504 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Disk /dev/md1 doesn't contain a valid partition table
Disk /dev/md2: 1077 MB, 1077411840 bytes
2 heads, 4 sectors/track, 263040 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Disk /dev/md2 doesn't contain a valid partition table
Disk /dev/md0: 106 MB, 106823680 bytes
2 heads, 4 sectors/track, 26080 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Disk /dev/md0 doesn't contain a valid partition table
[root@pant ~]#
[root@pant ~]# mdadm --manage /dev/md0 --fail /dev/sdb1
mdadm: set /dev/sdb1 faulty in /dev/md0
[root@pant ~]# mdadm --manage /dev/md1 --fail /dev/sdb2
mdadm: set /dev/sdb2 faulty in /dev/md1
[root@pant ~]# mdadm --manage /dev/md2 --fail /dev/sdb3
mdadm: set /dev/sdb3 faulty in /dev/md2
[root@pant ~]# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 fd Linux raid autodetect
/dev/sda2 14 1925 15358140 fd Linux raid autodetect
/dev/sda3 1926 2056 1052257+ fd Linux raid autodetect
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 13 104391 fd Linux raid autodetect
/dev/sdb2 14 1925 15358140 fd Linux raid autodetect
/dev/sdb3 1926 2056 1052257+ fd Linux raid autodetect
Disk /dev/md1: 15.7 GB, 15726608384 bytes
2 heads, 4 sectors/track, 3839504 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Disk /dev/md1 doesn't contain a valid partition table
Disk /dev/md2: 1077 MB, 1077411840 bytes
2 heads, 4 sectors/track, 263040 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Disk /dev/md2 doesn't contain a valid partition table
Disk /dev/md0: 106 MB, 106823680 bytes
2 heads, 4 sectors/track, 26080 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Disk /dev/md0 doesn't contain a valid partition table
[root@pant ~]# [root@pant ~]# df -h
-bash: [root@pant: command not found
/dev/md1 15G 2.2G 12G 16% /
/dev/md0 99M 17M 77M 19% /boot
tmpfs 501M 0 501M 0% /dev/shm
[root@pant ~]# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 fd Linux raid autodetect
/dev/sda2 14 1925 15358140 fd Linux raid autodetect
[root@pant ~]# Filesystem Size Used Avail Use% Mounted on
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
-bash: Filesystem: command not found
[root@pant ~]# /dev/md1 15G 2.2G 12G 16% /
-bash: /dev/md1: Permission denied
/dev/sdb1 * 1 13 104391 fd Linux raid autodetect
/dev/sdb2 14 1925 15358140 fd Linux raid autodetect
/dev/sdb3 1926 2056 1052257+ fd Linux raid autodetect
Disk /dev/md1: 15.7 GB, 15726608384 bytes
2 heads, 4 sectors/track, 3839504 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Disk /dev/md1 doesn't contain a valid partition table
Disk /dev/md2: 1077 MB, 1077411840 bytes
2 heads, 4 sectors/track, 263040 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Disk /dev/md2 doesn't contain a valid partition table
Disk /dev/md0: 106 MB, 106823680 bytes
2 heads, 4 sectors/track, 26080 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Disk /dev/md0 doesn't contain a valid partition table
=============================================================
=========================================
DISK "SDB" is removing from the raid
=============================================================
=========================================
[root@pant ~]# mdadm --manage /dev/md0 --remove /dev/sdb1
mdadm: hot removed /dev/sdb1
[root@pant ~]# mdadm --manage /dev/md1 --remove /dev/sdb2
mdadm: hot removed /dev/sdb2
[root@pant ~]# mdadm --manage /dev/md2 --remove /dev/sdb3
mdadm: hot removed /dev/sdb3
=============================================================
=========================================
Now system have to reboot to check whether is will come back or not
=============================================================
=========================================
[root@pant ~]# reboot
=============================================================
=========================================
##ESC###
when system reboot it will show the fist booting promt where u select the hdd from
which you
want to boot or leave it
#####################################################################
##################################
=============================================================
==========================================
system is up & running now check the status of disk & the raid at which it will boot
now
it running from the sda disk which is add in raid.
=============================================================
==========================================
[root@pant ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/md1 15G 2.2G 12G 16% /
/dev/md0 99M 17M 77M 19% /boot
tmpfs 501M 0 501M 0% /dev/shm
[root@pant ~]# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 fd Linux raid autodetect
/dev/sda2 14 1925 15358140 fd Linux raid autodetect
/dev/sda3 1926 2056 1052257+ fd Linux raid autodetect
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 13 104391 fd Linux raid autodetect
/dev/sdb2 14 1925 15358140 fd Linux raid autodetect
/dev/sdb3 1926 2056 1052257+ fd Linux raid autodetect
Disk /dev/md1: 15.7 GB, 15726608384 bytes
2 heads, 4 sectors/track, 3839504 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Disk /dev/md1 doesn't contain a valid partition table
Disk /dev/md2: 1077 MB, 1077411840 bytes
2 heads, 4 sectors/track, 263040 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Disk /dev/md2 doesn't contain a valid partition table
Disk /dev/md0: 106 MB, 106823680 bytes
2 heads, 4 sectors/track, 26080 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Disk /dev/md0 doesn't contain a valid partition table
=============================================================
==========================================
SDA disk which run the OS of the system After removing or can say fault of sdb disk
the system is good
=============================================================
==========================================
[root@pant ~]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sda1[0]
104320 blocks [2/1] [U_]
md2 : active raid1 sda3[0]
1052160 blocks [2/1] [U_]
md1 : active raid1 sda2[0]
15358016 blocks [2/1] [U_]
unused devices: <none>
=============================================================
==========================================
RECOVERY OF DISK & ADD TO RAID TO BEHAVE AS
MIRROR
=============================================================
==========================================
=============================================================
===========================================
copy the partition table of /dev/sda to /dev/sdb so that both disks have same layout
=============================================================
==========================================
[root@pant ~]# sfdisk -d /dev/sda |sfdisk -f /dev/sdb
Checking that no-one is using this disk right now ...
OK
Disk /dev/sdb: 2610 cylinders, 255 heads, 63 sectors/track
Old situation:
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0
Device Boot Start End #cyls #blocks Id System
/dev/sdb1 * 0+ 12 13- 104391 fd Linux raid autodetect
/dev/sdb2 13 1924 1912 15358140 fd Linux raid autodetect
/dev/sdb3 1925 2055 131 1052257+ fd Linux raid autodetect
/dev/sdb4 0 - 0 0 0 Empty
New situation:
Units = sectors of 512 bytes, counting from 0
Device Boot Start End #sectors Id System
/dev/sdb1 * 63 208844 208782 fd Linux raid autodetect
/dev/sdb2 208845 30925124 30716280 fd Linux raid autodetect
/dev/sdb3 30925125 33029639 2104515 fd Linux raid autodetect
/dev/sdb4 0 - 0 0 Empty
Successfully wrote the new partition table
Re-reading the partition table ...
If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)
=============================================================
==========================================
First remove the previous superblock, means the stucture of disk is reassign
=============================================================
==========================================
[root@pant ~]# mdadm --zero-superblock /dev/sdb1
[root@pant ~]# mdadm --zero-superblock /dev/sdb2
[root@pant ~]# mdadm --zero-superblock /dev/sdb
=============================================================
==========================================
Now disk is add in a order
=============================================================
==========================================
[root@pant ~]# mdadm -a /dev/md0 /dev/sdb1
mdadm: added /dev/sdb1
[root@pant ~]# mdadm -a /dev/md1 /dev/sdb2
mdadm: added /dev/sdb2
[root@pant ~]# mdadm -a /dev/md2 /dev/sdb3
mdadm: added /dev/sdb3
=============================================================
==========================================
NOW the recovery is under process it will take a time
=============================================================
==========================================
[root@pant ~]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb1[1] sda1[0]
104320 blocks [2/2] [UU]
md2 : active raid1 sdb3[2] sda3[0]
1052160 blocks [2/1] [U_]
resync=DELAYED
md1 : active raid1 sdb2[2] sda2[0]
15358016 blocks [2/1] [U_]
[>....................] recovery = 1.1% (170816/15358016) finish=22.2min
speed=11387K /sec
unused devices: <none>
[root@pant ~]# watch cat /proc/mdstat
[root@pant ~]# watch cat /proc/mdstat
[root@pant ~]#
=============================================================
==========================================
=============================================================
==========================================
NOW Recreating the GRUB because we all ready removed the partition & also zero
the superblock
=============================================================
==========================================
[root@pant ~]# grub
Probing devices to guess BIOS drives. This may take a long time.
GNU GRUB version 0.97 (640K lower / 3072K upper memory)
[ Minimal BASH-like line editing is supported. For the first word, TAB
lists possible command completions. Anywhere else TAB lists the possible
completions of a device/filename.]
grub> root (hd0,0)
root (hd0,0)
Filesystem type is ext2fs, partition type 0xfd
grub> setup (hd0)
setup (hd0)
Checking if "/boot/grub/stage1" exists... no
Checking if "/grub/stage1" exists... yes
Checking if "/grub/stage2" exists... yes
Checking if "/grub/e2fs_stage1_5" exists... yes
Running "embed /grub/e2fs_stage1_5 (hd0)"... 15 sectors are embedded.
succeeded
Running "install /grub/stage1 (hd0) (hd0)1+15 p (hd0,0)/grub/stage2
/grub/grub.conf"... succ eeded
Done.
grub> root (hd1,0)
root (hd1,0)
Filesystem type is ext2fs, partition type 0xfd
grub> setup (hd1)
setup (hd1)
Checking if "/boot/grub/stage1" exists... no
Checking if "/grub/stage1" exists... yes
Checking if "/grub/stage2" exists... yes
Checking if "/grub/e2fs_stage1_5" exists... yes
Running "embed /grub/e2fs_stage1_5 (hd1)"... 15 sectors are embedded.
succeeded
Running "install /grub/stage1 (hd1) (hd1)1+15 p (hd1,0)/grub/stage2
/grub/grub.conf"... succ eeded
Done.
grub> quit
quit
[root@pant ~]#
=============================================================
==========================================
NOW reboot & check erverything work fine
=============================================================
==========================================
[root@pant ~]# reboot
Broadcast message from root (pts/1) (Sat Jun 9 14:57:43 2012):
The system is going down for reboot NOW!
[root@pant ~]#
=============================================================
=========================================
[root@pant ~]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb1[1] sda1[0]
104320 blocks [2/2] [UU]
md2 : active raid1 sdb3[1] sda3[0]
1052160 blocks [2/2] [UU]
md1 : active raid1 sdb2[1] sda2[0]
15358016 blocks [2/2] [UU]
unused devices: <none>
[root@pant ~]#
=============================================================
=========================================
[root@pant ~]# df -hHT
Filesystem Type Size Used Avail Use% Mounted on
/dev/md1 ext3 16G 2.4G 13G 16% /
/dev/md0 ext3 104M 18M 81M 19% /boot
tmpfs tmpfs 526M 0 526M 0% /dev/shm
=============================================================
=========================================
[root@pant ~]# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 fd Linux raid autodetect
/dev/sda2 14 1925 15358140 fd Linux raid autodetect
/dev/sda3 1926 2056 1052257+ fd Linux raid autodetect
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 13 104391 fd Linux raid autodetect
/dev/sdb2 14 1925 15358140 fd Linux raid autodetect
/dev/sdb3 1926 2056 1052257+ fd Linux raid autodetect
Disk /dev/md1: 15.7 GB, 15726608384 bytes
2 heads, 4 sectors/track, 3839504 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Disk /dev/md1 doesn't contain a valid partition table
Disk /dev/md2: 1077 MB, 1077411840 bytes
2 heads, 4 sectors/track, 263040 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Disk /dev/md2 doesn't contain a valid partition table
Disk /dev/md0: 106 MB, 106823680 bytes
2 heads, 4 sectors/track, 26080 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Disk /dev/md0 doesn't contain a valid partition table
[root@pant ~]#
=============================================================
===========================================
Now testing is complete everything work fine
Regards
Deepak Pant
=============================================================
===========================================
=============================================================
===========================================

No comments:

Post a Comment

Thanks for the comment