3

I have Ubuntu installed on a usb drive for a while now. I could not installed it along side Windows because my SSD was in RAID mode and not AHCI, so Ubuntu was not able to detect it. But recently I got a new laptop and switch to AHCI mode with no risk of loosing data because the PC was brand new.

Now Ubuntu can detect my internal SSD, and I want to clone it from my USB drive to a partition of my SSD, along side Windows 10. I chose to do it with the command dd (I've already used it with success for cloning Ubuntu from a usb key to another), but this time it does not work quite well.

I ran a live session of Ubuntu 18.04, plugged the usb key with my Ubuntu on it, and launched gparted in order to create a partition for the cloning operation. I unmount /dev/sdb (my Ubuntu usb key), as well as /dev/nvme01 (the SSD), and launched the command :

sudo dd status=progress if=/dev/sdb of=/dev/nvme01p4 

The process worked quite well but in gparted the partition nvme01p4 (supposed to contain the clone of my Ubuntu) is not correctly detected (see the screenshot) gparted screenshot after the dd command. It appears there is a new Ubuntu option in the boot menu, but it leads to a grub console where I don't know what to do.

So I am asking you what I possibly did wrong ?

Thanks,

Anderson

1 Answers1

3

You used a command meant to copy entire drive to a single partition. In addition that command is to be used on identical drive of the same size so you get everything copied from one to the other, without needing to manually resize the partitions to use the entire space if larger. It appears you have made the space for the Ubuntu so it should be a reasonably straight forward action to get it done now. Boot your install media in EFI mode or it will never work and try the following in the Terminal program.

sudo mkdir /tmp/old
sudo mkdir /tmp/new
sudo mkfs.ext4 /dev/nvme01p4
sudo mount /dev/nvme01p4 /tmp/new
sudo mount /dev/sd?? /tmp/old
sudo rsync -avP /tmp/old/* /tmp/new/
sudo mkdir /tmp/new/boot/efi
sudo umount /boot/efi
sudo mount /dev/nvme01p1 /boot/efi

You need to use the drive number and letter of the old install in place of the ??. At this point everything should be copied and installed on the new drive the edits just need to be made for it too be able to boot properly. You need to find the UUIDs for the system to run from the new disk. Here I show you mine.

root@zeus-H370M:~# blkid | grep nvme
/dev/nvme0n1p1: LABEL_FATBOOT="EFI" LABEL="EFI" UUID="67E3-17ED" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="f2d84cb4-e597-4ac4-a2b2-10f0351c8784"
/dev/nvme0n1p2: UUID="553b41c8-8991-4646-a221-46b9b700b213" TYPE="apfs" PARTUUID="a9e442d9-2bef-43f0-8cf1-8d0c6ddce488"

Now the /etc/fstab for those entries.

root@zeus-H370M:~# cat /etc/fstab 
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/nvme0n1p2 during installation
UUID=553b41c8-8991-4646-a221-46b9b700b213 /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/nvme0n1p1 during installation
UUID=67E3-17ED  /boot/efi       vfat    umask=0077      0       1
/swapfile                                 none            swap    sw              0       0

After you have done this editing.

sudo nano /tmp/new/etc/fstab

Changing to what you get from your blkid command for your values, the /dev/nvme0n1p4 partition for your install is the one needed for the /. Now you could try a chroot to install the boot loader but I think the idea in this posting may be the best to do it. You would unmount your old install drive and do it so it will not interfere with the process. After the repair you should have working install with both listed OSs of Windows and Ubuntu in the GRUB menu.

https://help.ubuntu.com/community/Boot-Repair