OpenWrt x86 on USB stick

I want to boot OpenWrt (x86) from a USB stick and looking at:-

https://downloads.openwrt.org/releases/22.03.2/targets/x86/64/

I'm not really sure what to choose, even after reading some explanations here:-

I just want a file that I can 'dd' to USB stick and boot from it.

openwrt-x86-64-generic-ext4-combined-efi.img.gz
openwrt-x86-64-generic-ext4-combined.img.gz
openwrt-x86-64-generic-squashfs-combined-efi.img.gz
openwrt-x86-64-generic-squashfs-combined.img.gz

Apart from having to gunzip them first, you can use either of those. Differences being the permutations of ext4 vs squashfs and BIOS vs UEFI (which 'should' also boot on BIOS/ legacy CSM systems). If in doubt, openwrt-x86-64-generic-squashfs-combined-efi.img.gz would be my advice (unless you have reasons for one of the other).

3 Likes
  • You have a thread to make an ISO. Once the ISO is complete, put it on a USB
  • Or follow @slh advic to simply put the x86_64 image on USB
1 Like

I like to use the "openwrt-x86-64-generic-squashfs-combined*.gz" for headless x86 machines like ThinClient and VirtualMachine, because:

  • upgrading them is just as easy as upgrading an AP/Router with OpenWRT through CLI-command sysupgrade or the GUI approach via LuCI
  • They can be powered off anytime without fearing corrupting the filesystem

The default size of the rootfs is sufficient for a typical setup. If I want to utilize the capacity of the storage medium I build the images with ImageBuilder.

Here is an example for a ThinClient, which included upgrading it and reinstall the most recent restic package version from head:

#!/bin/bash

#Documentation: https://openwrt.org/docs/guide-user/additional-software/imagebuilder

HOST="mydevice.lan"
OUTPUT="$(pwd)/images"
BUILDER="https://downloads.openwrt.org/releases/22.03.2/targets/x86/64/openwrt-imagebuilder-22.03.2-x86-64.Linux-x86_64.tar.xz"

KERNEL_PARTSIZE=$((2*1024)) #Kernel-Partitionsize in MB
ROOTFS_PARTSIZE=$((5*1024)) #Rootfs-Partitionsize in MB

# download image builder
if [ ! -f "${BUILDER##*/}" ]; then
	wget "$BUILDER" || exit 1
	tar xJvf "${BUILDER##*/}" || exit 1
fi

mkdir "$OUTPUT"
cd openwrt-*/ || exit 1

# list all targets for this image builder, consider 'make help' as well
#make info; exit 0

# clean previous images
make clean || exit 1

#adjust partition sizes
sed -i "s/CONFIG_TARGET_KERNEL_PARTSIZE=.*/CONFIG_TARGET_KERNEL_PARTSIZE=$KERNEL_PARTSIZE/g" .config || exit 1
sed -i "s/CONFIG_TARGET_ROOTFS_PARTSIZE=.*/CONFIG_TARGET_ROOTFS_PARTSIZE=$ROOTFS_PARTSIZE/g" .config || exit 1

# Packages are added if no prefix is given, '-packagename' does not integrate/removes a package
# not needed: qemu-img qemu-x86_64-softmmu kmod-kvm-x86 qemu-bridge-helper kmod-tun
make image PROFILE="generic" \
           PACKAGES="luci-base luci-ssl luci-mod-admin-full luci-theme-bootstrap \
                     collectd-mod-ping luci-app-statistics collectd-mod-uptime collectd-mod-disk collectd-mod-df collectd-mod-sensors collectd-mod-cpufreq \
                     fdisk block-mount lsblk htop \
                     kmod-usb-storage e2fsprogs fdisk resize2fs \
                     debootstrap debian-archive-keyring gpgv2 \
                     openssh-sftp-server sshfs bash screen haproxy \
                     restic-rest-server ccrypt screen tar" \
            BIN_DIR="$OUTPUT" || exit 1

#rescue the previous config
ssh root@$HOST "sysupgrade -v --create-backup /tmp/$HOST.backup.tar.gz" || exit 1
scp root@$HOST:/tmp/$HOST.backup.tar.gz "$OUTPUT/" || exit 1

#rescue /root-folder
ssh root@$HOST 'tar -c -z -p -v --numeric-owner -f - /root' > "$OUTPUT/$HOST.rootfolder.tgz" || exit 1

#perform the update
scp "$OUTPUT"/openwrt-*-x86-64-generic-squashfs-combined-efi.img.gz root@$HOST:/tmp/ || exit 1
ssh root@$HOST 'sysupgrade -v -c -u /tmp/openwrt*img.gz && exit'

#wait for device to reappear on the network
echo "Please wait"
sleep 90
while true; do
	echo -n .
	ping -c 1 $HOST > /dev/null && break
	sleep 1
done

#put root-Folder back in place
scp "$OUTPUT/$HOST.rootfolder.tgz" root@$HOST:/root/ || exit 1
ssh root@$HOST "cd /root && tar -xvpzf $HOST.rootfolder.tgz -C / --numeric-owner" || exit 1

#restore restic
ssh root@$HOST "wget https://downloads.openwrt.org/snapshots/packages/x86_64/packages/restic-rest-server_0.11.0-1_x86_64.ipk -O /tmp/restic-rest-server_0.11.0-1_x86_64.ipk" || exit 1
ssh root@$HOST "opkg install /tmp/restic-rest-server_0.11.0-1_x86_64.ipk" || exit 1
ssh root@$HOST "wget https://downloads.openwrt.org/snapshots/packages/x86_64/packages/restic_0.14.0-1_x86_64.ipk -O /tmp/restic_0.14.0-1_x86_64.ipk" || exit 1
ssh root@$HOST "opkg install /tmp/restic_0.14.0-1_x86_64.ipk" || exit 1
ssh root@$HOST "/etc/init.d/restic-rest-server restart" || exit 1

exit 0
2 Likes

Creating a USB stick from an ISO image didn't work.

I used 'dd' but was unable to boot from the USB stick.

Copying one of the supplied images to a USB stick has worked and I'm quite happy with the result.

You use a CD creation tool, not dd.

(Most Linux distros have one.)

Not sure where that idea came from.

What I would like to do is install OpenWrt on the first partition of a GPT disc as a rescue partition, and boot other OSes via GRUB.

Not really sure how to go about this.

Is this a separate inquiry than creating a USB disk?

It seems you already have a thread for that.

See: https://openwrt.org/docs/guide-user/installation/openwrt_x86#installing_openwrt_in_an_internal_drive

1 Like

your old thread .... Installing OpenWrt x86 on GPT disk, not sure if it's still true though.

trial and error.

2 Likes

Looks like I've been trying to this for over four years!!!!

How time flies...

1 Like

What full command have you used?
Correct version of command is:
dd if=openwrt-22.03.2-x86-64-generic-ext4-combined.img bs=1M of=/dev/sdX
Make sure, you are writing *.img file, not *.gz

1 Like

That seems is the OP's only option.

If so, they would have to make more partitions, configure GRUB for their other OSes, etc. That's all unrelated to OpenWrt, though.

  • I suggest running GParted on the offline drive after you successfully moved the OpenWrt image to disk for setup/sizing of the other partitions
  • I would advise nesting GRUB into the boot of a distro's GRUB instance, and having that distro do boot loading for all the other OSes - then you only have to alter the OpenWrt's GRUB once, and OpenWrt should [be configured to] boot on failure of rolling to the other GRUB for OSes
  • :warning: If it's not clear, I wouldn't advise using sysupgrade after you've completed the setup you desire
1 Like

OK, but for this case OP should use openwrt-22.03.2-x86-64-generic-ext4-combined-efi.img file.

1 Like

Ummmm...OK.

Doesn't matter, both are ext4; and the disk processes proceeding are unrelated to OpenWrt (i.e. no matter which, the OP must properly address the other partitions in the subsequent GRUB).

That seems to just be a preference.

Yes, as the OP wants to use GPT. Good catch!

... assuming that 4 y.o statement is still valid.

1 Like
1 Like

Steps to use Rufus to create a bootable USB stick for OpenWRT:

  1. Download Rufus:
  • If you don't already have Rufus installed, you can download it from the official website (https://rufus.ie/).
  1. Insert the USB Stick:
  • Plug in your USB stick into an available USB port on your computer. Ensure that you have backed up any important data on the USB stick, as the process will erase it.
  1. Run Rufus:
  • Launch Rufus by double-clicking its executable file.
  1. Select Your USB Device:
  • In the "Device" dropdown, select your USB stick from the list of available devices. Make sure you choose the correct one, as all data on the selected device will be erased.
  1. Choose the OpenWRT ISO Image:
  • In the "Boot selection" section, click on the "Select" button next to "Boot selection." Choose the OpenWRT ISO image file that you want to write to the USB stick.
  1. Set Partition Scheme and File System:
  • In the "Partition scheme" section, select the appropriate scheme for your system. If you're unsure, "MBR" is generally a safe choice for most computers.
  • In the "File system" section, select "FAT32."
  1. Set the Volume Label and Cluster Size:
  • You can set a name for your USB stick's volume label, or you can leave it as the default.
  • The cluster size can usually be left at the default value.
  1. Check for Bad Blocks: (Optional)
  • You can perform a quick format or check for bad blocks. It's typically safe to leave this option unchecked.
  1. Create a Bootable Disk:
  • Click the "Start" button to initiate the process. A warning message will appear, informing you that all data on the USB stick will be destroyed. Confirm and proceed.
  1. Wait for Rufus to Complete:
  • Rufus will start writing the OpenWRT ISO image to the USB stick. This process may take a few minutes, depending on the size of the image and the speed of your USB stick.
  1. Completion:
  • Once Rufus has finished, you'll see a "READY" status in the lower-left corner of the Rufus window.
  1. Eject the USB Stick:
  • Safely eject the USB stick from your computer.

Now, you have a bootable USB stick with OpenWRT ready for use. You can use this bootable USB stick to install or run OpenWRT on compatible hardware. Choose "boot from USB" in your bios and enjoy. It's a great method to test releases without installing them.

This works:-

 fetch -o - https://downloads.openwrt.org/releases/22.03.5/targets/x86/64/openwrt-22.03.5-x86-64-generic-ext4-combined.img.gz |  gzip -dc > /dev/da0

fetch is a FreeBSD tool, although wget may provide similar functionality.