I have a Centos 6 server resided in cloud environment that I want to move the root partition from the existing harddisk to another one.
In the original harddisk(/dev/xvda1), it has other folder like
/usr, and I don't want to move them over, so I can't simply
dd the whole old harddisk to a new one (/dev/xvdh1).
I have now
rsync all the content in
/ (except those mentioned above) to
/usr to another harddisk (/dev/xvdg). I have modified the following file in the new harddisk to use the new UUID:
Here is the output of
/dev/xvdh1: UUID="9b84e28c-5a12-4889-804a-753e56645333" TYPE="ext4"
/etc/fstab that do the
/ mount :
UUID="9b84e28c-5a12-4889-804a-753e56645333" / ext4 defaults 1 1
default=0 timeout=1 title CentOS 6 (2.6.32-573.18.1.el6.x86_64) root (hd0,0) kernel /boot/vmlinuz-2.6.32-573.18.1.el6.x86_64 ro root=UUID=9b84e28c-5a12-4889-804a-753e56645333 rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD console=ttyS0,115200 crashkernel=auto SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM initrd /boot/initramfs-2.6.32-573.18.1.el6.x86_64.img
I have also
dd the boot sector code from
dd if=/dev/xvda of=/dev/xvdh bs=446 count=1
Output of both harddisk metadata:
# file -s /dev/xvda /dev/xvda: x86 boot sector; GRand Unified Bootloader, stage1 version 0x3, boot drive 0x80, 1st sector stage2 0x8cc500, GRUB version 0.94; partition 1: ID=0x83, active, starthead 32, startsector 2048, 16775168 sectors, code offset 0x48 # file -s /dev/xvda1 /dev/xvda1: Linux rev 1.0 ext4 filesystem data (needs journal recovery) (extents) (large files) (huge files) # file -s /dev/xvdh /dev/xvdh: x86 boot sector; GRand Unified Bootloader, stage1 version 0x3, boot drive 0x80, 1st sector stage2 0x8cc500, GRUB version 0.94; partition 1: ID=0x83, active, starthead 32, startsector 2048, 4192256 sectors, code offset 0x48 # file -s /dev/xvdh1 /dev/xvdh1: Linux rev 1.0 ext4 filesystem data (needs journal recovery) (extents) (large files) (huge files)
When all the above steps done, I detached the old harddisk and attached the new harddisk as
/dev/xvda1, then boot. However when I boot the machine I stuck at the error on grub:
Booting from Hard Disk... Geom Error
/dev/xvdh1 are different, and obviously their UUID is different too. So my question is: do I need to do a
grub-install in order to make the modification I done on the
grub.conf to goes into the boot sector code? Or there is never need to do that because the boot code is just the same and root partition info is never stored over there , where the boot code will able to read the
grub.conf to get the info without extra step needed ?
Please shed some light if I need to change any other file in order to make the grub boot the server, thanks. (grub version: 0.94)