This was written because Ulysse had a failing hard drive. The main NVME drive went into Write-Protect mode and needed to be salvaged. Denis bought a new drive so we needed to migrate his old system to the new drive with minimal problems.
NOTE: This article is a work in progress.
Turn off machine that needs to be replaced.
Use another machine to create a bootable USB Drive as found in KB1000
Boot the newly created USB Drive and select Try Ubuntu. This will load a live version of the operating system.
Attach a portable drive to the machine. This needs to be large enough to hold your current, failing hard drive.
Mount that portable drive to a spot on the live installation. You can do this by opening the drive inside of Nautilus (the file explorer that is installed by default) or by the following commands:
sudo su
lsblk
# Find your drive
mount <YOUR PORTABLE DRIVE> /mnt
lsblk to find it. Be sure to do this from the bootable USB as lsblk might not show your failing drive from the normal operating system. You'll need to match the drive kind and size to the entry in lsblk. If your drive is a NVMe drive, it will be listed under /dev/nvme?n?, where ? is replaced with a number.sudo su # if not root already...
dd if=<YOUR FAILING DRIVE> of=/mnt/<name of computer>_backup.<date>.img bs=4M status=progress
sync
Now that we have a good copy of your drive, turn off the machine (nicely) and replace your drive.
Boot the newly created USB Drive and select Try Ubuntu again.
Mount your portable drive again.
Now we are going to copy everything back:
sudo su
dd if=/mnt/<name of computer>_backup.<date>.img of=<YOUR NEW DRIVE> bs=4m status=progress
sync
Shutdown, remove the bootable USB, and turn on. You should have working computer again!
Be sure to copy your ssh keys and bash settings to the new machine