move a centos / scientificlinux install to a new drive

While dd / partimage might work just fine, these steps detail exactly what data is where and how it got to the disk during install. Assuming old=sda new=sdb

  1. fdisk -ucl /dev/sda, create identical ones on sdb, I’ll assume just a small ext4 sdb1 for boot and LVM sdb2 that fills the disk
  2. pvdisplay && pvcreate /dev/sdb2
  3. vgdisplay && vgcreate rootvg /dev/sdb2 -s 32M
  4. lvdisplay &&  lvcreate -L 300G -n rootlv rootvg
  5. mkfs.ext4 /dev/sdb1
  6. mkfs.ext4 /dev/mapper/rootvg-rootlv
  7. optional tune2fs -c 0 -i 0 /dev/mapper/rootvg-rootlv
  8. mount /dev/sdb1 newboot && mount /dev/mapper/rootvg-rootlv newroot
  9. rsync -aADHvxX /boot/ newboot/
  10. rsync -aADHvxX / newroot/
  11. rsync -aADHvxX /dev/ newroot/dev/
  12. blkid /dev/sdb1, write the UUID in newroot/etc/fstab
  13. mkswap /dev/mapper/rootvg-swaplv
  14. edit fstab
  15. edit newboot/boot/grub.conf
  16. mount –bind newboot/ newroot/boot
  17. mount –bind /dev/ newroot/dev
  18. mount -t proc none newroot/proc
  19. mount -t sysfs none newroot/sys
  20. chroot newroot
  21. echo -e “rootnoverify (hd1,0)\nsetup (hd1)” | grub –batch
  22. sync && poweroff

Bad Behavior has blocked 78 access attempts in the last 7 days.