Copying OpenWrt to new disk

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:~# USB_STICK=/dev/sdc
root@OpenWrt:~# HDD_DRIVE=/dev/sda
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
2 Likes