I had an Ubuntu 14.04 running on a 1024 GB disk (disk A), which only used up to 130 GB spaces. I want to clone it to a 256 GB SSD disk ( disk B ). But failed.
gparted to shrink the partitions on disk A to be only about 180 GB for the preparation for disk B successfully.
Can you tell me where I was wrong?
1) restore the partition table
I did backup the partition table of disk A.
└──╼ $ sudo sfdisk -d /dev/sda # partition table of /dev/sda unit: sectors /dev/sda1 : start= 2048, size= 997376, Id=83, bootable /dev/sda2 : start= 999424, size= 15624192, Id=82 /dev/sda3 : start= 16623616, size=337020928, Id=83 /dev/sda4 : start= 0, size= 0, Id= 0
Save partition table
sudo sfdisk -d /dev/sda > partition.table
Then I tried to restore the partition table to disk B (
/dev/sdc in this scenario ).
sdc in file
partition.table. Then it looks like:
# partition table of /dev/sdc unit: sectors /dev/sdc1 : start= 2048, size= 997376, Id=83, bootable /dev/sdc2 : start= 999424, size= 15624192, Id=82 /dev/sdc3 : start= 16623616, size=337020928, Id=83 /dev/sdc4 : start= 0, size= 0, Id= 0
Then do the restore successfully.
sudo sfdisk /dev/sdc < partition.table
2) migrating disk partition content
sudo dd if=/dev/sda1 of=/dev/sdc1
sudo dd if=/dev/sda2 of=/dev/sdc2
sudo dd if=/dev/sda3 of=/dev/sdc3
After migration, those partitions on /dev/sdc can be mounted and viewed.
But if I plugged the SSD disk (disk B) into my laptop, it would not boot up after some Thinkpad BIOS output. No error came out but a blinking cursor...
I bet the BIOS even did not detect the
/boot on disk B when doing booting.
Can you help me? Many thanks!
Some one suggested me to use
grub-install /dev/sdc to do the trick.
I searched what
grub-install is capable -- link Let me try. And I am pretty sure disk A ( had MBR installed ).
dd if=/dev/sda of=/dev/sdc bs=512 count=1 , insert disk B only, it's still the same blinking cursor. Nothing really after BIOS.
grub-install --boot-directory=/mnt/mypartition/boot /dev/sdc I went to boot it up, only disk B.
But grub console came out . And reported
Now it is working!!!
Here's how I did it, on the PC running disk A as OS and the disk B (
/dev/sdc) as a USB hard drive.
sudo mount /dev/sdc3 /mnt sudo mount /dev/sdc1 /mnt/boot sudo grub-install --boot-directory=/mnt/boot /dev/sdc3
Then went to the
/mnt/boot/grub/grub.cfg, I did replaced 2 things in file
grub.cfg. (remember to give write permission to the file
Then save the file. -> Power off computer -> Insert disk B via SATA and take out disk A forever. -> Boot -> See grub error but still boot up
If you met error
Error: invalid environment block. Press any key to continue, please check this to solve it. Press any key will boot your system. https://askubuntu.com/questions/191852/error-invalid-environment-block-press-any-key-to-continue
Then, run each command, one-by-one.
cd /boot/grub rm grubenv grub-editenv grubenv create grub-editenv grubenv set default=0 grub-editenv grubenv list update-grub
Now go rebooting, it will work!
This is how I shrank my 1024GB disk hard drive and migrated the entire system to a new 256GB SSD disk.