I have a machine with one drive, and 2 OSs installed in 2 partitions, one windows and one Ubuntu 16.04. Grub is installed.
I just got a new physical drive. After I assemble it in the machine, I would like to:
Copy the exact same Ubuntu that I have in one partition of the current drive to the new drive
Have a grub in place that allows me to choose to boot from windows, from the original Ubuntu, or from the new Ubuntu in the new drive
I have done research and I found a very similar thread (link here). In that thread, this is one of the solutions suggested:
Create an ext4 partition and a swap partition on the new drive.
Boot from LiveUSB.
Mount the old Ubuntu partition to some directory, mount the new one to some other directory.
Copy all files from the old one to the new one using cp -a command
Install grub to the new drive.
Update /etc/fstab with new UUIDs
Given that I already have a grub in the current drive, and that I will copy the Ubuntu which is there exactly the same as it is to the new drive, do I need to install it on the new drive?
Thanks
Grub access it's config files before drives/filesystems are mounted. Unless you duplicate the original drive, you will likely get a grub command prompt.
You will need to boot into the new OS and update grub. I have done the following in the same situation:
First of all, cp -a is not appropriate in this situation. What you want to do is CLONE the partition. Here we will use the 'dd' tool but there are others available with GUI etc if you prefer eg Clonezilla.
Connect both drives to your computer. Make sure the new drive is the same size or larger than the partition you want to copy. It does not need to be formatted or anything, just leave it raw.
Boot a live DVD/USB and run:
This will list all the drives and partitions on your computer. Make a careful note of the partition you want to copy, eg. /dev/sda1 and the new blank drive eg. /dev/sdb (no number).
Use dd to clone your partition to the new drive - be very careful, this can destroy your data if you type the wrong command! 'if' is the (old) partition you want to copy. 'of' is the new (blank) drive. Don't get these mixed up! So for example:
You can add bs=4096 if you want it to go faster, but I prefer not to. Now go away and do something else because it will take a while.
When it's done (you are still in the live session at this point) you can add a swap partition to the new drive if you want to, using gparted, then install/run Boot Repair as below - this will install a nice fresh Grub onto the drive of your choice (overwriting any existing one) and find any OS on any drive connected:
Reboot and enjoy. Note: you will want to make sure your BIOS is booting the drive with the fresh Grub on it.
~~~~~~~~~~
UPDATE: Sorry for the late reply. So yes, if you haven't already done it by now, what you said before is what you want to do. Create an empty ext4 partition of about 20Gb on the new drive, to install the new Ubuntu system. Clone the /home partition from your old drive onto the new one (make sure you have enough space), then finally add the swap partition. You will then be ready to install the system on the new drive from your USB session - select the 'something else' option during install, choose to install / on the empty 20Gb partition WITH formatting, select the new cloned partition for /home WITHOUT formatting and place Grub on the new drive (see the dropdown selection at the bottom, the new drive should already be selected by default) and that should do the trick.
Bear in mind that when you're done, Grub should show Ubuntu x2 and Windows x1 so make sure you're booting the correct one.