ascii image


0010101000011111101001101010000010011000
1110101110110101011011111010010010001011
0001011100011101111001010011010010111110
0000010111101001100000110011101100001000
0011000000111010001111111000100110000001
1010110110000000000001011001000110001010
0101100010101100000100000010100100010101
0001011001011101100011000101110111101110
0110010100110100111101110100110011111101
0010111100110011010010110010101111011011
0100000000001001001011000010110100101001
1101000111100000110111011100110111000010
1111110001111111101101001010000111101100
0010110000100000111011000000101100010110
0101111000011100111010000000011111101111
0010010011110010011101001000110101000101
0000000001000100001111111100111010001111

Wednesday, 9 March 2011

Linux root disk resize with raid, ext4 and grub2

There are lots of decent how-to pages on the 'net;

And here are my notes;
  • Make sure you add a small <5MB partition for the boot loader as these are the boot disks

    # gdisk -l /dev/sdc
    GPT fdisk (gdisk) version 0.5.1

    Partition table scan:
      MBR: protective
      BSD: not present
      APM: not present
      GPT: present

    Found valid GPT with protective MBR; using GPT.
    Disk /dev/sdc: 1953525168 sectors, 931.5 GiB
    Disk identifier (GUID): 1213CECB-D072-12C2-4846-60804FA91405
    Partition table holds up to 128 entries
    First usable sector is 34, last usable sector is 1953525134
    Total free space is 0 sectors (0 bytes)

    Number  Start (sector)    End (sector)  Size       Code  Name
       1              34            6144   3.0 MiB     EF02  BIOS boot partition
       2            6145      1953525134   931.5 GiB   FD00  Linux RAID


  • Set the grub_bios flag on the small partition

    sudo parted /dev/sdc set <partition_number> bios_grub on

  • Once you have swapped out the disks each time, re-sync-ed and grown the raid.
    Boot via a rescue disk and fsck the raid metadevice and then resize the filesystem.

    e2fsck -f /dev/md0

    resize2fs /dev/md0

    mkdir /tmp/a
    mount /tmp/a /dev/md0
    df -h

  •  Reboot and you are done.

    # df -h | egrep "md|Filesys"
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/md0              917G  8.0G  863G   1% /
    /dev/md2              1.8T  456G  1.3T  27% /data


Resync on the old disks

md0 : active raid1 sdd1[2] sdc1[0]
      74920896 blocks [2/1] [U_]
      [>....................]  recovery =  2.6% (2012992/74920896) finish=41.5min speed=29240K/sec


Resync on the new

md0 : active raid1 sdd2[1] sdc2[0]
      976759424 blocks [2/2] [UU]
      [=>...................]  resync =  8.1% (79639488/976759424) finish=181.6min speed=82296K/sec

Some what faster - and a hell of a lot quieter.

No comments:

Post a comment