Transplanting Ubuntu 24.04.1 server to new hardware, best approach?

Bo Berglund bo.berglund at gmail.com
Sat Jan 25 21:31:44 UTC 2025


On Mon, 20 Jan 2025 23:10:50 +0000, Liam Proven <lproven at gmail.com> wrote:

>> OK, I thought that I *needed* to install fresh using an Ubuntu in order for it
>> to fix the start menu on the totally empty disk by creating the EFI partition
>> and populating the same..
>
>Well, you could do that to build an ESP, then over-write that copy
>with your server copy.
>


>
>> So:
>> If I copy just the partitions used by the server over to the new drive will
>> it then be able to boot or do I have to create an EFI partition and how is
>> that populated in that single-boot case?
>
>I would copy the existing one. Ignore the Windows entries. Or, get it
>booting, then delete them afterwards.
>
>> My end state for this is to have my existing server running on new hardware
>> preferably all alone on the drive except for the data partitions holding
>> the Subversion repositories and video library etc.
>
>Understood.
>
>Bottom line/summary
>
>I think you accidentally overwrote "Desktop Ubuntu" and have a copy of
>the ESP in that partition now.
>
>I'm amazed Grub still boots but it explains why you can't update it!
>
>I think reinstalling Grub, either by hand with the Stack Exchange link
>I sent before, or with Boot Repair and the link in this email, should
>get you working as expected.
>
>Once your server installation is in control of the boot loader, you
>can delete the other copy of Ubuntu.


So a bit later I now have found this way of transplanting to the new hardware,
which I partly understand but I am not sure how it really works....:

A: Prepare the Transfer Drive:
------------------------------
1. Boot the old system with GPartedLive on a USB.
2. Copy the system, home, and data partitions to the transfer drive.

B: Prepare the New Hardware's SSD:
----------------------------------
1. Boot the ASUS NUC with GPartedLive.
2. Create a GPT partition table on the SSD.
3. Create the EFI partition:
   - Add a 512 MB FAT32 partition at the start of the SSD.
   - Set the boot flag on this partition.
   - Label it `EFI`.
4. Copy the partitions from the transfer drive to the SSD.
   GParted will preserve the UUIDs unless you choose to modify them.

C: Install the Bootloader:
--------------------------
1. Boot from an Ubuntu Live USB:
   - Insert the Ubuntu Live installation USB.
   - Boot into "Try Ubuntu" mode.

2. Mount the System Partition:
   - Identify the partitions using lsblk or blkid  
   - Mount the system partition to /mnt
     (Replace /dev/sdXn with your system partition):  
     sudo mount /dev/sdXn /mnt

3. Mount the EFI Partition:
   - Create the mount point:  
     sudo mkdir -p /mnt/boot/efi
   - Mount the EFI partition
     (Replace /dev/sdYn with your EFI partition):
     sudo mount /dev/sdYn /mnt/boot/efi

4. Bind Mount System Directories:
   - Mount essential system directories for chroot:  
     sudo mount --bind /dev /mnt/dev
     sudo mount --bind /proc /mnt/proc
     sudo mount --bind /sys /mnt/sys

5. Chroot into the System:
   - Enter the system environment:
     sudo chroot /mnt

6. Install GRUB for UEFI:
   - Install the GRUB bootloader:  
     apt update
     apt install grub-efi-amd64

   - Install GRUB to the EFI partition:
     grub-install --target=x86_64-efi \
     --efi-directory=/boot/efi \
     --bootloader-id=ubuntu

   - Update GRUB configuration:  
     update-grub

7. Exit Chroot and Unmount:
   - Exit the chroot environment:  
     exit

   - Unmount the directories:  
     sudo umount /mnt/dev /mnt/proc /mnt/sys /mnt/boot/efi /mnt

D: Test Booting:
----------------

1. Reboot the system and enter the BIOS/UEFI settings.
2. Ensure the boot order prioritizes the EFI partition.
3. Test the boot process.

Apparently this method ensures you create a valid EFI partition and configure
the bootloader to recognize the transferred system....

But I am not sure how it works, since you are in a "test live system" and mount
real hardware partitions, does that mean that the transferred system is modified
to now control the Grub boot EFI system?

What do you think?

Is this a valid approach to get a new system with a fresh grub controlled from
my server?
By reading it it seems to not involve many hard to grip operations....


-- 
Bo Berglund
Developer in Sweden





More information about the ubuntu-users mailing list