Upgrading hard drive capacity of a linux system

There is obviously more than one way to clone a linux install, but here’s the way I used most recently, when upgrading a 500G RAID1 volume on a 3ware HBA to 2T.

Fortunately, we had two free slots available, so we just inserted the new 2T drives into the free slots.

  • Insert the new drives in the free slots [4 and 5].
  • Create the RAID1 volume with the twi_cli. You may first have to rescan the bus with the ‘rescan’ command.

    maint createunit c4 rraid1 p4:5

  • Create partition table on the new device, in this case,

    sdb1 / 25G
    sdb2 swap 12G
    sdb3 /home the rest

  • make file systems, mount points, and mount the partitions

    mke2fs -j /dev/sdb1
    mke2fs -j /dev/sdb3
    mkswap /dev/sdb2
    mkdir -p /mnt/new/root /mnt/new/root/home
    mount /dev/sdb1 /mnt/new/root
    mount /dev/sdb3 /mnt/new/root/home

  • Do the initial rsync, then just before switching, quiet the system and do it again. The one bit of magic here is to preserve hard links [H], which linux systems are full of.

    cd /
    rsync -vrpoglHDt --exclude=/proc --exclude=/sys \
    --exclude=/net --exclude=/tmp --exclude=/mnt/new \
    --delete . /mnt/new/root

    Here’s a key for the flags used above:

    -v, --verbose increase verbosity
    -r, --recursive recurse into directories
    -p, --perms preserve permissions
    -o, --owner preserve owner (super-user only)
    -g, --group preserve group
    -l, --links copy symlinks as symlinks
    -H, --hard-links preserve hard links
    -D same as --devices --specials
    --devices preserve device files (super-user only)
    --specials preserve special files
    -t, --times preserve modification times

  • Fix the permissions on /tmp

    chmod 1777 /mnt/new/root/tmp

  • Write grub

    grub-install --recheck --root-directory=/mnt/new/root /dev/sdb

  • Fix fstab so that it doesn’t use UUIDs [we can put those back after we get it booted happily off the new drives]. It’s probable that the UUIDs won’t change when we move the drives to the first two slots, but I didn’t test this.
  • Reboot.
  • manually set root=/dev/sda1 at the grub prompt
  • after booting, find the new uuids with ‘blkid’, and modify /etc/fstab accordingly.
  • run ‘update-grub’ to fix /boot/grub/grub.conf with the right uuids.
  • reboot again.
  • We also moved the two new 2T drives into slots 0 and 1, inserted a
    couple of spare 2T drives and used the tw_cli utility to assign those
    new drives as hot spares.

    Posted in Uncategorized | Leave a comment