Cloning raid1 boot disks: Difference between revisions

From DaqWiki
Jump to navigation Jump to search
mNo edit summary
m (5 revisions imported)
 
(No difference)

Latest revision as of 16:02, 16 September 2015

Cloning raid1 boot disks

  • starting point:
    • fdisk -l
[root@deap02 ~]# fdisk -l

Disk /dev/sda: 16.0 GB, 16013852672 bytes
224 heads, 56 sectors/track, 2493 cylinders
Units = cylinders of 12544 * 512 = 6422528 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0007e9b2

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        2493    15636068   fd  Linux raid autodetect

Disk /dev/md0: 16.0 GB, 16011259904 bytes
2 heads, 4 sectors/track, 3908999 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/md0 doesn't contain a valid partition table

Disk /dev/sdb: 16.0 GB, 16013852672 bytes
224 heads, 56 sectors/track, 2493 cylinders
Units = cylinders of 12544 * 512 = 6422528 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xeccedcd8

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1        2493    15636068   fd  Linux raid autodetect
    • cat /proc/mdstat
[root@deap02 ~]# cat /proc/mdstat
Personalities : [raid1] 
md0 : active raid1 sdb1[2] sda1[1]
      15635996 blocks super 1.0 [2/2] [UU]
      bitmap: 1/1 pages [4KB], 65536KB chunk

unused devices: <none>
  • disconnect one of the 2 boot disks
  • connect a new blank disk
  • fdisk -l ### to see which /dev/sdX device it will be
  • fdisk -H224 -S56 /dev/sdX
    • for 8/16GB USB disk: create one partition spanning the whole device, type 0xfd, set "active/bootable" flag
    • for SSD or high capacity disk: omit the -H and -S flags, create partitions 1 and 2 to match the boot and swap partitions on the active boot disk
  • result should look like this:
Disk /dev/sdb: 16.0 GB, 16013852672 bytes
224 heads, 56 sectors/track, 2493 cylinders
Units = cylinders of 12544 * 512 = 6422528 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xeccedcd8

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1        2493    15636068   fd  Linux raid autodetect
  • mdadm --add /dev/md0 /dev/sdX1
  • cat /proc/mdstat ### should look like this:
[root@deap02 ~]# cat /proc/mdstat
Personalities : [raid1] 
md0 : active raid1 sdb1[2] sda1[1]
      15635996 blocks super 1.0 [2/1] [_U]
      [>....................]  recovery =  0.5% (92288/15635996) finish=14.0min speed=18457K/sec
      bitmap: 1/1 pages [4KB], 65536KB chunk

unused devices: <none>
  • wait until raid1 resync completes: watch -d -n1 "cat /proc/mdstat" or watch the grass grow
  • cat /proc/mdstat ### should look like this:
[root@deap02 ~]# cat /proc/mdstat
Personalities : [raid1] 
md0 : active raid1 sdb1[2] sda1[1]
      15635996 blocks super 1.0 [2/2] [UU]
      bitmap: 1/1 pages [4KB], 65536KB chunk

unused devices: <none>
  • install GRUB on new disks: (remember to substitute /dev/sdX !!!) (do NOT change (hd0) to (hd1), etc !!!)
    • echo -e "device (hd0) /dev/sdX\nroot (hd0,0)\nsetup (hd0)\n" | grub --batch --no-floppy
  • sync; sync; sync
  • done