You are not logged in.

#1 2022-05-13 10:54:04

sarch2022
Member
Registered: 2022-05-13
Posts: 13

Trying to clone existing copy of Arch (Laptop) to a USB flash drive

Hi, i'm fairly new to Linux and Arch is the first Distro i have tried. i have been on it now for about a year so built the OS to my liking but i would like to make an exact copy of my install on a USB flash drive that i can boot from on any PC but i'm a bit lost.

i have followed the rsync guide on the wiki and also the copy Linux from existing Install guide and i think i have done it correctly but i get stuck with what to do after the Rsync has completed

Here is what i have tried -

boot into a separate live USB of arch

fdisk -l

mkfs.ext4 /dev/[FLASH DRIVE]

mount /dev/[ROOT] /mnt

mount /dev/[EFI PARTITION] /mnt/boot/efi

mount /dev/[USB DRIVE] /mnt/usbstick

and finally rsync -aAXHv --progress --exclude={"/dev/*","/proc/*","/sys/*","/var/lib/dhcpcd/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / /mnt/usbstick

it looks as though the EFI isn't moving over even though its mounted before the rsync.
the rsync completes but i cant figure out how to get it to boot. i know you need to reinstall grub etc but when i cfdisk into the USB there is only one partition with all the rsync files in it and if i try to re partition it using cfdisk it says an ext4 filesystem has been found and a write command will remove it. Even if i try to write anyway it says it cant complete the write.

if someone can point me in the right direction or let me know if im going wrong somewhere it would be much appreciated! Thanks.

Offline

#2 2022-05-13 11:11:30

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,660

Re: Trying to clone existing copy of Arch (Laptop) to a USB flash drive

Mounting does not create partitions. You need to partition the usb stick including a relevant EFI partition mount those correctly  so that the files carry over. I.e. you need to create a new FAT32 EFI partition on the stick and mount that to /mnt/usbstick/boot/efi after mounting the intended USB root to /mnt/usbstick.

Also, what you probably should and actually want to be doing is mount your actual root drive you do the copy from somewhere clearly distinct e.g. /mnt/oldRoot and the ESP to /mnt/oldRoot/boot/efi then mounting the stick to /mnt/usbstick and adjust the rsync command to copy from /mnt/oldRoot to /mnt/usbstick otherwise you are copying your live system rather than the actual root you want to copy from

Last edited by V1del (2022-05-13 11:18:16)

Offline

#3 2022-05-17 18:37:14

sarch2022
Member
Registered: 2022-05-13
Posts: 13

Re: Trying to clone existing copy of Arch (Laptop) to a USB flash drive

Hi, I've only just gotten around to trying this and I'm having a few more issues.

I have followed what you said so now I'm doing this.

This is done from a seperate live Arch install USB
SDX = USB | SDX1 = EFI | SDX2 =swap | SDX3 Linux filesystem

Mkfs.ext4 /dev/sdx

cfdisk /dev/sdx

select gpt disk then make 3 partitions 550MB EFI, 4GB swap & the rest Linux filesystem. (This is exactly the same as my working arch install on my laptop that I'm cloning)

Now I have the partitions I do

mount /dev/OLD ROOT LOCATION /mnt/oldroot/boot/efi
mount /dev/OLD EFI LOCATION /mnt/oldroot
mount /dev/sdx3 /mnt/usbstick ( i also tried /dev/sdx without the partiton number at the end but i get the same error)

but I get a message saying mount: wrong fs type, bad option, bad superblock on /dev/sdx,
       missing codepage or helper program, or other error

am I still doing something wrong? I'm currently running fsck /dev/sdx from a guide I read but I'm not sure if I'm doing the right thing?

also if I follow what you said do I have to do two separate rsyncs one for rync /mnt/oldroot and one for rsync /mnt/oldroot/boot/efi or once they are mounted will they both move over at the same time?

Thanks again!

[UPDATE]
i have managed to mount my usb so would this work as the sync command? rsync -aAXHv --progress --exclude={"/dev/*","/proc/*","/sys/*","/var/lib/dhcpcd/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} /mnt/oldroot/ /mnt/usbstick

Last edited by sarch2022 (2022-05-17 20:03:44)

Offline

#4 2022-05-17 20:46:11

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,660

Re: Trying to clone existing copy of Arch (Laptop) to a USB flash drive

The order of mounts is important, you'd swap the upper 2 lines in that mount invocation (you mount the root and "on top of that" the ESP to /mnt/oldroot/boot/efi). Yes this rsync command would pick up things correctly, again granted you did the mounting in the correct order for both/all relevant mount points. If you still have doubts post the output of

lsblk -f

in code tags once you have the mount setup like you think it is correct.

Last edited by V1del (2022-05-17 20:48:48)

Offline

#5 2022-05-18 17:41:30

sarch2022
Member
Registered: 2022-05-13
Posts: 13

Re: Trying to clone existing copy of Arch (Laptop) to a USB flash drive

sorry I think i mixed the mounts up in the post but not when i did it in my CLI

I've tried to copy the code but because it's on a live USB I cant figure out how to get it over so I've got a clear picture instead

photo of lsblk -l

i tried running 

rsync -aAXHv --progress --exclude={"/dev/*","/proc/*","/sys/*","/var/lib/dhcpcd/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} /mnt/oldroot/ /mnt/usbstick/

and it starts the rsync but eventually drops to kb/s on a random files and eventually hangs

do i need the / at the end of the source and destination on the rsync command or should i leave them open?

Last edited by sarch2022 (2022-05-18 17:48:56)

Offline

#6 2022-05-18 20:31:18

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,660

Re: Trying to clone existing copy of Arch (Laptop) to a USB flash drive

should be fine (... you still don't have a matching ESP on the stick itself which you'll need to boot the stick in EFI mode, but from a file copying perspective this shouldn't matter). In general some slowdown might be normal, when it hangs do you see any errors in dmesg writing to the stick? the / at the end should be fine afaik

Offline

Board footer

Powered by FluxBB