0

I bought a new SSD and decided to migrate my Ubuntu(in HDD).

/dev/sda (SSD)
/dev/sdb (HDD)

Using a Live USB I created a partition in SSD and copy /dev/sdb2(which is /) to /dev/sda1 using rsync -a. After that I changed UUID entry(SSD) for / in /dev/sda1/etc/fstab.

I have an efi partition and I did the following steps for grub installation in SSD

sudo mount /dev/sda1 /mnt
sudo mount /dev/sdb1 /mnt/boot/efi
sudo grub-install --efi-directory=/mnt/boot/efi --root-directory=/mnt /dev/sda

Now problem is doesn't matter which HDD I choose for first boot, grub always mount my old HDD as /. I cannot mount SSD as /.

shantanu
  • 8,599
  • 1
    Probably easier just to do a new install. Keep old install on HDD as backup. If you copied system, you have same UUID in fstab and grub, so it is using the UUID on HDD as default. You may be able to edit all those to new UUIDs on SSD. Best to have an efi partition on SSD for booting also. http://askubuntu.com/questions/461394/how-to-partition-ssdhdd – oldfred Nov 30 '15 at 19:21

2 Answers2

0

I have found the problem. When I tried to clone the HDD partition, it also copy /boot/grub from HDD to SSD. For some reason(maybe a bug) grub-install didn't update /boot/grub.

So I deleted /boot/grub from SSD and run grub installation process again.

sudo mount /dev/sda1 /mnt
sudo rm -rf /mnt/boot/grub
sudo mount /dev/sdb1 /mnt/boot/efi
sudo mount --bind /dev /mnt/dev
sudo mount --bind /sys /mnt/sys
sudo mount --bind /proc /mnt/proc
sudo grub-install --efi-directory=/mnt/boot/efi --root-directory=/mnt /dev/sda
sudo chroot /mnt
update-grub

Now everything is fine.

shantanu
  • 8,599
-1

Trying using a program called Clonezilla.

You can use it to make exact replicas of your system hard drives and can be used to replace one that is in use.

So say you have a 1TB drive as your main OS for Linux, make a clonezilla copy of it and restore that image onto your new SSD drive. By removing the old 1TB drive and replacing it with the new SSD you should be good to go.

Keep in mind going from a larger drive to a smaller drive might cause you some issues and may require you to shrink partitions to resolve the issue.

For help using Clonezilla there are numerous youtube videos explaining how to use the application to backup and restore hard disks.