Wednesday, October 9, 2013

Re-sizing SCSI disks for RAID membership

Yet another reason why SATA sucks. In SCSI we can define how many blocks are exposed. So say we have a raid set like so:

root@pops:~# cat /proc/mdstat

Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]

md0 : active raid10 sdb1[1] sdc1[3] sdd1[2]

      286875904 blocks super 1.2 32K chunks 2 near-copies [4/3] [_UUU]

      bitmap: 2/3 pages [8KB], 65536KB chunk

sde is our new member and it's twice the size of the original members.

root@pops:~# lsscsi

[0:0:0:0]    cd/dvd  ATAPI    iHAS124   C      LL0B  /dev/sr0

[1:0:0:0]    disk    ATA      WDC WD1002FAEX-0 05.0  /dev/sda

[6:0:0:0]    disk    HITACHI  HUC151414CSS600  A330  /dev/sdb

[6:0:1:0]    disk    HITACHI  HUC151414CSS600  A330  /dev/sdc

[7:0:0:0]    disk    HITACHI  HUC151414CSS600  A330  /dev/sdd

[7:0:1:0]    disk    HITACHI  HUS156030VLS600  A5D0  /dev/sde



root@pops:~# sg_readcap /dev/sde

Read Capacity results:

   Last logical block address=586072367 (0x22eec12f), Number of blocks=586072368

   Logical block length=512 bytes

Hence:

   Device size: 300069052416 bytes, 286168.1 MiB, 300.07 GB

root@pops:~# sg_readcap /dev/sdd

Read Capacity results:

   Last logical block address=287140276 (0x111d69b4), Number of blocks=287140277

   Logical block length=512 bytes

Hence:

   Device size: 147015821824 bytes, 140205.2 MiB, 147.02 GB

I always use partitions for RAID sets just to advertise "hey, someone is probably using this", it also gives you some head room in case you start developing badblocks. For the sake of simplicity, I want to slim down the replacement disk. I don't want those blocks available for anyone else to add another partition and make the raid member thrash due to competing IOs, so let's resize it.
root@pops:~# sg_format --resize --count=287140277 /dev/sde

    HITACHI   HUS156030VLS600   A5D0   peripheral_type: disk [0x0]

      << supports protection information>>

Mode Sense (block descriptor) data, prior to changes:

  Number of blocks=586072368 [0x22eec130]

  Block size=512 [0x200]

Resize operation seems to have been successful

and to check.
root@pops:~# sg_readcap /dev/sde
Read Capacity results:
   Last logical block address=287140276 (0x111d69b4), Number of blocks=287140277
   Logical block length=512 bytes
Hence:
   Device size: 147015821824 bytes, 140205.2 MiB, 147.02 GB

Sweet! Now to reuse the existing partition map from it's siblings and push it into service.
sfdisk -d /dev/sdd > part.txt

sfdisk /dev/sde < part.txt

...

and we're back in service
root@pops:~# mdadm /dev/md0 --add /dev/sde1

mdadm: added /dev/sde1



root@pops:~# cat /proc/mdstat

Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]

md0 : active raid10 sde1[4] sdb1[1] sdc1[3] sdd1[2]

      286875904 blocks super 1.2 32K chunks 2 near-copies [4/3] [_UUU]

      [>....................]  recovery =  0.2% (423040/143437952) finish=28.1min speed=84608K/sec

      bitmap: 2/3 pages [8KB], 65536KB chunk



unused devices: 

Done.

No comments:

Post a Comment