#Follow the below steps to configure and add the new disk to array.
#We can use this command to create the partitions from the other disk(sda) to (sdb):
(testvm:root)$sfdisk -d /dev/sda | sfdisk /dev/sdb
Checking that no-one is using this disk right now ...
OK
Disk /dev/sdb: 8924 cylinders, 255 heads, 63 sectors/track
sfdisk: ERROR: sector 0 does not have an msdos signature
/dev/sdb: unrecognized partition table type
Old situation:
No partitions found
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 62990864 62782020 fd Linux raid autodetect
/dev/sdb3 0 - 0 0 Empty
/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).)
(testvm:root)$
#We have to run the below command to check if both hard drives have the same partitions.
(testvm:root)$ /sbin/fdisk -l
Disk /dev/sda: 36.4 GB, 36401479680 bytes
255 heads, 63 sectors/track, 4425 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 3921 31391010 fd Linux raid autodetect
Disk /dev/sdb: 73.4 GB, 73407488000 bytes
255 heads, 63 sectors/track, 8924 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 3921 31391010 fd Linux raid autodetect
Disk /dev/md1: 32.1 GB, 32144293888 bytes
2 heads, 4 sectors/track, 7847728 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Disk /dev/md1 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
(testvm:root)$
#Next we should add /dev/sdb1 to /dev/md0 and /dev/sdb2 to /dev/md1 using below commands.
(testvm:root)$ mdadm --manage /dev/md0 --add /dev/sdb1
mdadm: added /dev/sdb1
(testvm:root)$ mdadm --manage /dev/md1 --add /dev/sdb2
mdadm: added /dev/sdb2
(testvm:root)$
#Now both arrays (/dev/md0 and /dev/md1) will start synchronizing.
#It will take longer time depending on amount of data to synchronize.
#output should be as below when its finished.
(testvm:root)$ cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb1[1] sda1[0]
104320 blocks [2/2] [UU]
md1 : active raid1 sdb2[1] sda2[0]
31390912 blocks [2/2] [UU]
unused devices: <none>
(testvm:root)$
#Start the grub shell to add the grub bootblock to the replaced disk
#You can use the grub geometry command to view disk information:
(testvm:root)$ 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> geometry (hd0)
geometry (hd0)
drive 0x80: C/H/S = 4425/255/63, The number of sectors = 71096640, /dev/sda
Partition num: 0, Filesystem type is ext2fs, partition type 0xfd
Partition num: 1, Filesystem type unknown, partition type 0xfd
grub> geometry (hd1)
geometry (hd1)
drive 0x81: C/H/S = 8924/255/63, The number of sectors = 143374000, /dev/sdb
Partition num: 0, Filesystem type is ext2fs, partition type 0xfd
Partition num: 1, Filesystem type unknown, partition type 0xfd
#Add the bootblock to /dev/sdb:
grub> device (hd1) /dev/sdb
device (hd1) /dev/sdb
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"... succeeded
Done.
grub> quit
quit
(testvm:root)$
#That's it, you have successfully replaced /dev/sdb!
#We can use this command to create the partitions from the other disk(sda) to (sdb):
(testvm:root)$sfdisk -d /dev/sda | sfdisk /dev/sdb
Checking that no-one is using this disk right now ...
OK
Disk /dev/sdb: 8924 cylinders, 255 heads, 63 sectors/track
sfdisk: ERROR: sector 0 does not have an msdos signature
/dev/sdb: unrecognized partition table type
Old situation:
No partitions found
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 62990864 62782020 fd Linux raid autodetect
/dev/sdb3 0 - 0 0 Empty
/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).)
(testvm:root)$
#We have to run the below command to check if both hard drives have the same partitions.
(testvm:root)$ /sbin/fdisk -l
Disk /dev/sda: 36.4 GB, 36401479680 bytes
255 heads, 63 sectors/track, 4425 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 3921 31391010 fd Linux raid autodetect
Disk /dev/sdb: 73.4 GB, 73407488000 bytes
255 heads, 63 sectors/track, 8924 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 3921 31391010 fd Linux raid autodetect
Disk /dev/md1: 32.1 GB, 32144293888 bytes
2 heads, 4 sectors/track, 7847728 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Disk /dev/md1 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
(testvm:root)$
#Next we should add /dev/sdb1 to /dev/md0 and /dev/sdb2 to /dev/md1 using below commands.
(testvm:root)$ mdadm --manage /dev/md0 --add /dev/sdb1
mdadm: added /dev/sdb1
(testvm:root)$ mdadm --manage /dev/md1 --add /dev/sdb2
mdadm: added /dev/sdb2
(testvm:root)$
#Now both arrays (/dev/md0 and /dev/md1) will start synchronizing.
#It will take longer time depending on amount of data to synchronize.
#output should be as below when its finished.
(testvm:root)$ cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb1[1] sda1[0]
104320 blocks [2/2] [UU]
md1 : active raid1 sdb2[1] sda2[0]
31390912 blocks [2/2] [UU]
unused devices: <none>
(testvm:root)$
#Start the grub shell to add the grub bootblock to the replaced disk
#You can use the grub geometry command to view disk information:
(testvm:root)$ 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> geometry (hd0)
geometry (hd0)
drive 0x80: C/H/S = 4425/255/63, The number of sectors = 71096640, /dev/sda
Partition num: 0, Filesystem type is ext2fs, partition type 0xfd
Partition num: 1, Filesystem type unknown, partition type 0xfd
grub> geometry (hd1)
geometry (hd1)
drive 0x81: C/H/S = 8924/255/63, The number of sectors = 143374000, /dev/sdb
Partition num: 0, Filesystem type is ext2fs, partition type 0xfd
Partition num: 1, Filesystem type unknown, partition type 0xfd
#Add the bootblock to /dev/sdb:
grub> device (hd1) /dev/sdb
device (hd1) /dev/sdb
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"... succeeded
Done.
grub> quit
quit
(testvm:root)$
#That's it, you have successfully replaced /dev/sdb!
No comments:
Post a Comment