Migrate standard RHEL installation from one hard disk to another
You have one standard installation of RHEL, you need migrate the installation from one hard disk to another, this is required due to technology improvement.
The server is productive and has running critical services, so is important minimize the migration window, this procedure requires only one reboot, if you want to apply all changes immediately but you can program the restart after.
For x86_64
Scenario:
vda -> Old Disk
vdb -> New Disk
centos -> root volume group
Partitioning:
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 18G 983M 17G 6% /
devtmpfs 487M 0 487M 0% /dev
tmpfs 497M 0 497M 0% /dev/shm
tmpfs 497M 6.7M 490M 2% /run
tmpfs 497M 0 497M 0% /sys/fs/cgroup
/dev/vda1 497M 164M 333M 33% /boot
tmpfs 100M 0 100M 0% /run/user/0
tmpfs 100M 0 100M 0% /run/user/1000
# fdisk -l
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 1026047 512000 83 Linux
/dev/vda2 1026048 41943039 20458496 8e Linux LVM
Steps:
Clean yum cache:
# yum clean all
Clone partitioning scheme:
# sfdisk -d /dev/vda | sfdisk --force /dev/vdb
Move Logical Volume to new disk:
# pvcreate /dev/vdb2
# vgextend centos /dev/vdb2
# pvmove /dev/vda2
# vgreduce centos /dev/vda2
# pvremove /dev/vda2
Clone /boot:
# umount /boot/
# dd if=/dev/vda1 of=/dev/vdb1 bs=512 conv=noerror,sync
# mount /boot
Copy boot sector:
# dd if=/dev/vda of=/dev/vdb bs=1 count=512
Install GRUB in new disk:
# grub2-install /dev/vdb
Sync changes:
# sync
Reboot your physical or virtual machine, please make sure that your new disk is the default boot device or remove old disk but don't delete data, can be useful in a rollback situation.
For POWER
Scenario:
Scenario:
sda -> Old Disk
sdb -> New Disk
ca -> root volume group
Partitioning:
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/ca-root 28G 1.1G 27G 4% /
devtmpfs 449M 0 449M 0% /dev
tmpfs 495M 0 495M 0% /dev/shm
tmpfs 495M 12M 484M 3% /run
tmpfs 495M 0 495M 0% /sys/fs/cgroup
/dev/sda2 497M 143M 354M 29% /boot
tmpfs 99M 0 99M 0% /run/user/0
# fdisk -l
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 10239 4096 41 PPC PReP Boot
/dev/sda2 10240 1034239 512000 83 Linux
/dev/sda3 1034240 62914559 30940160 8e Linux LVM
Steps:
Clean yum cache:
# yum clean all
Clone partitioning scheme:
# sfdisk -d /dev/sda | sfdisk --force /dev/sdb
Move Logical Volume to new disk:
# pvcreate /dev/sdb3
# vgextend centos /dev/sdb3
# pvmove /dev/sda3
# vgreduce centos /dev/sda3
# pvremove /dev/sda3
Clone PPC PReP Boot partition:
dd if=/dev/sda1 of=/dev/sdb1 bs=512 conv=noerror,sync
Clone /boot:
# umount /boot/
# dd if=/dev/sda2 of=/dev/sdb2 bs=512 conv=noerror,sync
# mount /boot
Copy boot sector:
# dd if=/dev/sda of=/dev/sdb bs=1 count=512
Install GRUB in new disk:
# grub2-install /dev/sdb
If you receive this message: grub2-install: error: the chosen partition is not a PReP partition. maybe you can try with:
# grub2-install /dev/sdb1
Sync changes:
# sync
Reboot your physical or virtual machine, please make sure that your new disk is the default boot device or remove old disk but don't delete data, can be useful in a rollback situation.