2

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

  • I would have used Windows Disk management to create space for Ubuntu, Then used GParted to copy / paste the system partition from your USB to the empty space. I would then boot the Full install USB and run sudo update-grub This adds the Ubuntu on the SSD to the USB's boot menu. If the internal Ubuntu boots okay from the USB, you can install grub to the SSD overwriting Windows boot loader. This worked for me. – C.S.Cameron Feb 28 '21 at 12:51
  • With UEFI you have gpt partitions. You should not clone one gpt partition. The GUID is in the partition, the primary partition table & backup partition table. Better to just do a new install & copy /home. If you changed any system wide configuration files in /etc, you may want to copy those. And if you installed lots of apps, you need to export list & reinstall from that list. This would be just like restoring from your backup when your drive has failed. Also grub is correctly installed. https://askubuntu.com/questions/545655/backup-your-home-directory-with-rsync-and-skip-useless-folders – oldfred Feb 28 '21 at 15:04
  • To properly clone Ubuntu you need to setup UUID's correctly in grub and etc/fstab like this script does: https://askubuntu.com/questions/1028604/bash-script-to-backup-clone-ubuntu-to-another-partition – WinEunuuchs2Unix Feb 28 '21 at 18:37

1 Answers1

2

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

  • Thanks for your answer ! I have several questions though. How do I boot in EFI mode specifically ? I thought I was in but when I run sudo umount /boot/efi it says no mount point specified. And after sudo mount /dev/nvme0n1p1 /boot/efi it says mount point does not exist. So I suppose I may not be in EFI mode... – Andersyes Feb 28 '21 at 16:08
  • It should be set to do it now your disk is configured with that partition at the start of it, the tiny 100MB. With my firmware when booting I use the F12 to get list. The EFI precedes them boot options, if seeing a P0 or similar it is option to boot in BIOS mode. This can be turned on or off in the firmware. Look for EFIonly booting or disable CSM compatibility, the old BIOS booting method. Without booting in the proper mode the /boot/efi will not be there. The installer needs to be one created with the EFI option included in it, most are universal detecting method of booting. –  Feb 28 '21 at 16:16
  • I would add if booted in the correct mode and it still does not let you umount or mount let it go on, it may be able to do it without the specific commands I do, I just try to leave it no choice but to find the correct location with those. –  Feb 28 '21 at 16:19
  • Okay, so I am in EFI mode, so it just does not let me mount and unmount, saying there is no /boot/efi. But then I do not really understand the editing of fstab. I am not used to the cat command and I do not see what to do – Andersyes Feb 28 '21 at 16:53
  • You edit the lines in the /tmp/new/etc/fstab to match your new locations that you got from the blkid command. Do sudo mkdir /tmp/new/boot/efi to ensure it has the location on the new install to mount for that when done. Skip the mount and umount as I told you to do, then run the repair. The editing of the file is done with the nano command. –  Feb 28 '21 at 17:13
  • Okay, I understand better now. I am editing fstab but when trying to save the file it's says Error writing /tmp/new/etc/fstab: No such file or directory. So I suppose I missed something... Should I just create it ? – Andersyes Feb 28 '21 at 17:32
  • Hum maybe I've done something wrong. I've done sudo mount /dev/sdb2 /tmp/old caus/dev/sdb2 is the partition with the boot flag, but maybe should I've done it with /dev/sdb1 ? – Andersyes Feb 28 '21 at 17:47