Wiki‎ > ‎

SUSE12 clone OS Disk Grub2 ext4

posted Aug 19, 2016, 10:20 AM by Dong Xu   [ updated Aug 23, 2016, 5:38 PM ]
1. Use ddrescue to close to a new disk via USB3. Note that the source OS drive does not need umount
2. The new disk should be able to boot now without any grub2 mod
3. But if the new disk is larger, we need to resize the / partition to the entire disk space
4. While the new disk is still on USB, lauch parted

 parted /dev/sdb

 print free

Error: The backup GPT table is not at the end of the disk, as it should be.
This might mean that another operating system believes the disk is smaller.
Fix, by moving the backup to the end (and removing the old backup)?
Fix/Ignore/Cancel? Fix                                          
        
Warning: Not all of the space available to /dev/sdb appears to be used, you can
fix the GPT to use all of the space (an extra 39070080 blocks) or continue with
the current setting?
Fix/Ignore? Fix         

After fixing it, we can use either parted or fdisk to resize the partition

Inside parted:

resize 3 (#this for sdb3)
100% (#will use all free space)
quit

then

e2fsck -f /dev/sdb3

resize2fs  /dev/sdb3

Done!

========================
If there is any boot error asssociated with Grub2, try the trick below:

Here the newly cloned disk /dev/sdb (sdb3 is the OS partition) is connected via USB
mkdir /mnt/tmp
mount /dev/sdb3 /mnt/tmp
mount --bind /sys /mnt/tmp/sys
mount --bind /dev /mnt/tmp/dev
mount --bind /run /mnt/tmp/run
mount --bind /proc /mnt/tmp/proc
chroot /mnt/tmp
grub2-mkconfig -o /boot/grub2/grub.cfg
grub2-install /dev/sdb
mkinitrd

Comments