Objective:
To upgrade the old HDD replace with new one without data loss. (New HDD size more than old HDD)
Releases:
Red hat Enterprises Linux 5.x
Procedure:
Note: Check the drives in Linux. /dev/sda should be your old drive. /dev/sdb should be your new drive.
- Copy the MBR (Master Boot Record) from first HDD to second HDD.
# dd if=/dev/sda of=/dev/sdb bs=446 count=1
- Copy the partition table from first HDD to second HDD
# sfdisk -d /dev/sda > part_back
# sfdisk /dev/sdb < part_back
Note: If you are having more than 4 partition means you need to follow the below steps for using the free spaces.
a. First redirect only 3 partition by editing the part_back file using the vi editor
# vi part_back
# Partition table of /dev/sda
Unit: sectors
/dev/sda1 : start= 63, size= 208782, Id=83, bootable
/dev/sda2 : start= 208845, size= 1044225, Id=82
/dev/sda3 : start= 1253070, size= 9012465, Id=83
b. Now redirect this partition dump file to 2nd HDD
# sfdisk /dev/sdb < part_back
c. Create the extended partition manually by using fdisk command
# fdisk /dev/sdb
d. Now dump this 2nd HDD partition table to different file.
# sfdisk –d /dev/sdb > part_back1
e. Once again take the partition dump of first HDD
# sfdisk –d /dev/sda > part_back
f. Replace the 4th partition details (extended) of part_back using part_back1 and save the file.
g. Now redirect to 2nd HDD by using sfdisk
#sfdisk /dev/sdb < part_back
- Now manually create the FS on all the partitions depending upon your partition ID.
# mke2fs –j /dev/sdb1
# mkswap /dev/sdb2
# mke2fs –j /dev/sdb3
# mke2fs –j /dev/sdb5
- Copy the partition
# dd if=/dev/sda1 of=/dev/sdb1 bs=64k
# dd if=/dev/sda2 of=/dev/sdb2 bs=64k
# dd if=/dev/sda3 of=/dev/sdb3 bs=64k
# dd if=/dev/sda5 of=/dev/sdb5 bs=64k
- Now booted through the 2nd hard disk OS will boot and also you are able to use the free spaces.
No comments:
Post a Comment