I've just installed OpenWrt (19.07.2) on a USB stick and would like copy it to a hard disk.
Can anyone advise me about how to do this?
My hard disk has two partitions on it. Should I expect to be able to copy the two partitions from the USB stick to the hard disk and get it to boot? Assuming I can change the UUID of the disk in the relevant config files?
Connect over ssh and determine your block devices, for example:
root@OpenWrt:~# opkg update && opkg install block-mount
root@OpenWrt:~# block info
/dev/sdc1: UUID="84173db5-fa99-e35a-95c6-28613cc79ea9" LABEL="kernel" VERSION="1.0" MOUNT="/boot" TYPE="ext4"
/dev/sdc2: UUID="ff313567-e9f1-5a5d-9895-3ba130b4a864" LABEL="rootfs" VERSION="1.0" MOUNT="/" TYPE="ext4"
/dev/sda1: UUID="5108af2c-8b6c-4886-bc4b-d18b5f778b79" VERSION="1.0" TYPE="ext4"
/dev/sda2: UUID="3056b613-66c9-4dc0-ab20-ae1b2cbfc923" VERSION="1.0" TYPE="ext4"
sdc1 and sdc2 are currently mounted, so this are your current running openwrt installation.
Assuming sda is your hard drive, do the following to copy the whole usb stick to your hdd with all partition meta data:
root@OpenWrt:~# dd if=$USB_STICK of=$HDD_DRIVE bs=1M
You can also write your downloaded openwrt image directly to your hdd from a running system:
root@OpenWrt:~# cd /tmp
root@OpenWrt:~# wget http://downloads.openwrt.org/releases/19.07.2/targets/x86/64/openwrt-19.07.2-x86-64-combined-squashfs.img.gz
root@OpenWrt:~# gzip -d -c openwrt-19.07.2-x86-64-combined-squashfs.img.gz | dd of=/dev/sda bs=1M
Actually I have three partitions, the third one being an Arch Linux partition. I use the disk as multiboot system. Is there any way to copy the partitions from the USB stick to the hard drive? Could I use dd to copy the partitions? I don't really want to lose the Arch Linux partition.
Yes, for sure.
But keep in mind that this will not copy the grub bootloader that is located between partition table and first partition.
Merge the files in the boot partition into the rootfs under /boot so everything OpenWrt needs is in one partition, then copy that partition to the hard disk. Boot Arch and run update-grub to find the new OS and add it to the boot menu.