You are not logged in.

#1 2018-04-05 13:00:36

replabrobin
Member
Registered: 2010-05-06
Posts: 226

[SOLVED] moving installation to new drive uses wrong efi device

I have a working Arch linux installation on a 256Mb flash drive. I would like to transfer the installation to a 512Mb flash drive.

The source drive has

/dev/sda1 /
/dev/sda2 swap
/dev/sda3 /boot/efi/

I partitioned and formatted the destination drive  which is in a usb carrier

/dev/sdb1 /
/dev/sdb2 swap
/dev/sdb3 /boot/efi

mount /dev/sdb1 /mnt

then to copy files rsync -x -a --delete / /mnt & rsync -x -a /boot/efi/ /mnt/boot/efi

then installed grub on the /dev/sdb device with

grub-install --target x86_64-efi --efi-directory /mnt/boot/efi --boot-directory=/mnt/boot --removable

I checked and the grub.cfg seems correct ie refers to the sdb device uuids etc etc.

I also edited /mnt/etc/fstab to use the /dev/sdb uuids.

I rebooted to test and selected the new usb uefi as as boot device. All seems well; df shows the /dev/sdb1 device as /, but
it shows that my EFI drive is still /dev/sda3 where I was expecting it to be /dev/sdb3. Dates seem to imply that I installed
/boot/efi/EFI/arch/grubx64.efi OK, but obviously something is wrong.

If I reboot using the /dev/sda version of the system things seem to be fine. How can I get the proper setup?

Last edited by replabrobin (2018-04-14 14:17:24)

Offline

#2 2018-04-14 14:16:46

replabrobin
Member
Registered: 2010-05-06
Posts: 226

Re: [SOLVED] moving installation to new drive uses wrong efi device

For anyone interested I solved this problem using the following script

#!/bin/bash
set -e
set -x
sudo mount /dev/sdb1 /mnt
sudo mount /dev/sdb3 /mnt/boot/efi
sudo rsync -x -av --delete / /mnt
sudo rsync -x -av --delete /boot/efi/ /mnt/boot/efi

echo "UUID=$(lsblk -n -o UUID /dev/sdb1) / ext4  rw,relatime,data=ordered 0 1
UUID=$(lsblk -n -o UUID /dev/sdb3) /boot/efi vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro 0 2
UUID=$(lsblk -n -o UUID /dev/sdb2) none swap defaults 0 0" > /tmp/fstab

sudo arch-chroot /mnt /bin/bash -c "grub-install --target x86_64-efi --efi-directory=/boot/efi --boot-directory=/boot --bootloader=arch_grub --recheck --removable"
sudo arch-chroot /mnt /bin/bash -c "grub-mkconfig -o /boot/grub/grub.cfg"
sudo arch-chroot /mnt /bin/bash -c "mkinitcpio -p linux"
sudo mv /tmp/fstab /mnt/etc/fstab
sudo chown root:root /mnt/etc/fstab
sync
sudo umount /mnt/boot/efi
sudo umount /mnt

after execution I could reboot and boot from the new drive and see / /boot/efi & swap all coming from the new flash drive

Offline

#3 2018-04-14 16:37:41

cafe
Member
Registered: 2014-03-20
Posts: 156

Re: [SOLVED] moving installation to new drive uses wrong efi device

Here's another idea if you ever need to do that again: https://bbs.archlinux.org/viewtopic.php?id=221823

Offline

Board footer

Powered by FluxBB