Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| docs:guide-user:installation:openwrt_x86 [2021/10/31 03:55] – [Resizing F2FS overlay] vgaetera | docs:guide-user:installation:openwrt_x86 [2024/12/11 21:31] (current) – [Upgrading] remove misinformation about x86 upgrades efahlgren | ||
|---|---|---|---|
| Line 14: | Line 14: | ||
| * **Geode** is a custom Legacy target customized for Geode SoCs, which are still in use in many (aging) networking devices, like the older Alix boards from PCEngines. | * **Geode** is a custom Legacy target customized for Geode SoCs, which are still in use in many (aging) networking devices, like the older Alix boards from PCEngines. | ||
| - | Now you will see different | + | Once you select a target, there are multiple disk image files with different characteristics: |
| - | * **squashfs-combined.img.gz** This disk image uses the traditional OpenWrt layout, a squashfs read-only root filesystem and a read-write partition where settings and packages you install are stored. Due to how this image is assembled, you will have only 230-ish MB of space to store additional packages and configuration, | + | * **ext4-combined-efi.img.gz** This disk image uses a single read-write ext4 partition without a read-only squashfs root filesystem. As a result, the root partition can be expanded to fill a large drive (e.g. SSD/ |
| - | * **ext4-combined.img.gz** This disk image uses a single read-write ext4 partition with no read-only squashfs root filesystem, which allows to enlarge | + | * **ext4-combined.img.gz** This disk image is the same as above but it is intended to be booted with PC BIOS instead of EFI. |
| - | * **ext4-rootfs.img.gz** | + | * **ext4-rootfs.img.gz** This is a partition image of only the root partition. It can be used to install OpenWRT without overwriting the boot partition |
| - | * **rootfs.tar.gz** This contains all files from root partition. | + | * **kernel.bin** |
| + | * **squashfs-combined-efi.img.gz** This disk image uses the traditional OpenWrt layout, a squashfs read-only root filesystem and a read-write partition where settings and packages you install are stored. Due to how this image is assembled, you will have less than 100MB of space to store additional packages and configuration, | ||
| + | * **squashfs-combined.img.gz** This disk image is the same as above but it is intended | ||
| + | * **squashfs-rootfs.img.gz** | ||
| + | * **rootfs.tar.gz** This contains all the files from the root partition. | ||
| ===== Hardware support ===== | ===== Hardware support ===== | ||
| Line 34: | Line 38: | ||
| NVMe SSD support is available since OpenWrt 21.02. | NVMe SSD support is available since OpenWrt 21.02. | ||
| + | |||
| + | ===== Packages to consider on x86 ===== | ||
| + | OpenWrt has a minimalist philosophy regarding packaging strategy due to limited space on embedded devices. | ||
| + | |||
| + | One strategy to identify needed modules is to boot into a live Linux distro (for example [[https:// | ||
| + | |||
| + | Another option if building your own image is to build all modules '' | ||
| + | |||
| + | Beyond the kmods, some common packages to consider installing on x86 are listed below: | ||
| + | * For CPU/APU microcode updates for AMD processors, [[: | ||
| + | * For disk monitoring, [[: | ||
| + | * For hardware monitoring, [[: | ||
| + | * For hardware watchdog support, see: [[: | ||
| + | * For kernel entropy, [[: | ||
| ===== Installation ===== | ===== Installation ===== | ||
| Line 42: | Line 60: | ||
| Installation procedure differs depending from what OS you are using to write the raw disk image from, mostly because of different tools you have to use. | Installation procedure differs depending from what OS you are using to write the raw disk image from, mostly because of different tools you have to use. | ||
| - | < | + | <WRAP important> |
| - | **WARNING: writing | + | Writing |
| + | Be sure to select the correct drive so you do not delete | ||
| </ | </ | ||
| Line 66: | Line 85: | ||
| gunzip openwrt-*.img.gz | gunzip openwrt-*.img.gz | ||
| - | # Identify disk | + | # Identify disk (to replace sdX in the following command below) |
| lsblk | lsblk | ||
| # Write image | # Write image | ||
| - | dd if=openwrt-21.02.0-x86-64-generic-ext4-combined.img of=/dev/sdX | + | dd if=openwrt-21.02.0-x86-64-generic-ext4-combined.img |
| </ | </ | ||
| - | ===== Installing OpenWrt | + | ===== Installing OpenWrt |
| - | If you want to write OpenWrt in Sata or IDE drives or CF Cards or SD cards, you can just remove them from the device and flash the image raw from your PC. | + | If you want to write OpenWrt in SATA or IDE drives or CF Cards or SD cards, you can just remove them from the device and flash the image raw from your PC. |
| Also sometimes eMMC is removable or can be put in "usb write mode" in some devices. | Also sometimes eMMC is removable or can be put in "usb write mode" in some devices. | ||
| Line 109: | Line 128: | ||
| The x86 image is using the following partition layout (as seen from inside of the device): | The x86 image is using the following partition layout (as seen from inside of the device): | ||
| - /dev/sda1 is a 16MB ext4 /boot partition where GRUB and the kernel are stored. | - /dev/sda1 is a 16MB ext4 /boot partition where GRUB and the kernel are stored. | ||
| - | - /dev/sda2 is a 256MB partition containing the squashfs root filesystem and a read-write f2fs filesystem OR the ext4 root filesystem (depending on what image you have chosen). | + | - /dev/sda2 is a 104MB partition containing the squashfs root filesystem and a read-write f2fs filesystem OR the ext4 root filesystem (depending on what image you have chosen). |
| Any additional space in the device is unallocated. | Any additional space in the device is unallocated. | ||
| - | ===== Resizing partitions | + | ===== Expanding root partition and filesystem |
| - | :!: Make sure to [[docs: | + | See also automated script on: [[docs: |
| - | | + | ==== Expanding root partition ==== |
| - | - Use fdisk to show the partitions. | + | <WRAP important> |
| - | - Write down the starting sector address of / | + | When installing OpenWrt on a VM, be sure to [[docs: |
| - | - Use fdisk to delete | + | </ |
| - | - Use fdisk to create a new partition 2, choose/type the starting sector address you wrote down earlier (as by default it will try to place it somewhere else), and leave the default end sector address (this will mean the partition will now use all available space). | + | |
| - | - Write the partition table changes to disk. It may complain | + | Use [[man> |
| + | |||
| + | <code bash> | ||
| + | # Install | ||
| + | opkg update | ||
| + | opkg install parted | ||
| + | |||
| + | # Identify disk name and partition number | ||
| + | parted -l -s | ||
| + | |||
| + | # Expand root partition | ||
| + | parted -f -s /dev/sda resizepart 2 100% | ||
| + | |||
| + | # Apply changes | ||
| + | reboot | ||
| + | </ | ||
| + | |||
| + | ==== Expanding root filesystem ==== | ||
| + | <WRAP important> | ||
| + | Be sure to [[docs:guide-user:installation: | ||
| + | |||
| + | It is possible to expand the root filesystem online while OpenWrt is booted. | ||
| + | You can also perform this operation offline to reduce the chance of filesystem corruption. | ||
| + | </ | ||
| + | |||
| + | Use [[man> | ||
| + | |||
| + | <code bash> | ||
| + | # Install packages | ||
| + | opkg update | ||
| + | opkg install losetup resize2fs | ||
| + | |||
| + | # Map loop device to root partition | ||
| + | losetup /dev/loop0 /dev/sda2 2> /dev/null | ||
| + | |||
| + | # Expand root filesystem | ||
| + | resize2fs -f / | ||
| + | |||
| + | # Apply changes | ||
| + | reboot | ||
| + | </ | ||
| + | |||
| + | ==== Expanding root partition with fdisk ==== | ||
| + | You can also use '' | ||
| + | The easiest way to do this is from the machine booted with a "live CD" distro like [[https:// | ||
| + | |||
| + | Here's an overview of the steps: | ||
| + | - Use fdisk to display | ||
| + | - Write down the starting sector address of the root partition (Usually '' | ||
| + | - Use fdisk to delete partition 2 but don't write the changes to disk yet. | ||
| + | - Use fdisk to create a new partition 2. | ||
| + | - choose/type the starting sector address you wrote down earlier (as by default it will try to place it somewhere else). | ||
| + | - leave the default end sector address (this will mean the partition will now use all available space). | ||
| + | - Write the partition table changes to disk. | ||
| + | - When it warns about partition signatures | ||
| + | - Proceed with updating ''/ | ||
| - | An example fdisk operation on a 8GB flash drive: | + | Example output: |
| < | < | ||
| Line 140: | Line 214: | ||
| Device | Device | ||
| / | / | ||
| - | / | + | / |
| Command (m for help): d | Command (m for help): d | ||
| Line 167: | Line 241: | ||
| </ | </ | ||
| - | Automated method: | + | Be aware that deleting and recreating the root partition can change its UUID. |
| + | Make sure to update the root partition UUID in your GRUB configuration ''/ | ||
| <code bash> | <code bash> | ||
| - | opkg update | + | # Update GRUB configuration |
| - | opkg install fdisk | + | ROOT_BLK="$(readlink |
| - | BOOT="$(sed -n -e "/\s\/boot\s.*$/{s/// | + | '$9=="/dev/root"{print $3}' |
| - | DISK="${BOOT%%[0-9]*}" | + | ROOT_DISK="/dev/$(basename |
| - | PART="$((${BOOT## | + | ROOT_DEV="/dev/${ROOT_BLK##*/}" |
| - | ROOT="${DISK}${PART}" | + | ROOT_UUID="$(partx -g -o UUID "${ROOT_DEV}" "${ROOT_DISK}")" |
| - | OFFS=" | + | sed -i -r -e " |
| - | echo -e "p\nd\n${PART}\nn\np\n${PART}\n${OFFS}\n\nn\np\nw" | + | |
| - | </code> | + | |
| - | + | ||
| - | Be sure to update the GPT partition UUID in the GRUB configuration when using **efi.img.gz**: | + | |
| - | + | ||
| - | <code bash> | + | |
| - | opkg update | + | |
| - | opkg install lsblk | + | |
| - | BOOT="$(sed -n -e "/ | + | |
| - | DISK="${BOOT%%[0-9]*}" | + | |
| - | PART="$((${BOOT## | + | |
| - | ROOT="${DISK}${PART}" | + | |
| - | UUID="$(lsblk -n -o PARTUUID | + | |
| - | sed -i -r -e " | + | |
| - | </ | + | |
| - | + | ||
| - | ===== Resizing filesystem ===== | + | |
| - | :!: Make sure to [[docs: | + | |
| - | Note that online resizing should work for both F2FS and Ext4 on OpenWrt 19.07, although F2FS requires rebooting to apply changes. | + | |
| - | + | ||
| - | ==== Resizing F2FS overlay ==== | + | |
| - | Resize F2FS overlay for **squashfs-combined.img.gz**: | + | |
| - | + | ||
| - | <code bash> | + | |
| - | opkg update | + | |
| - | opkg install losetup f2fs-tools | + | |
| - | LOOP=" | + | |
| - | ROOT=" | + | |
| - | OFFS=" | + | |
| - | LOOP=" | + | |
| - | losetup -o ${OFFS} ${LOOP} ${ROOT} | + | |
| - | fsck.f2fs -f ${LOOP} | + | |
| - | mount ${LOOP} /mnt | + | |
| - | umount ${LOOP} | + | |
| - | resize.f2fs ${LOOP} | + | |
| - | reboot | + | |
| - | </ | + | |
| - | + | ||
| - | ==== Resizing Ext4 rootfs ==== | + | |
| - | Resize Ext4 rootfs for **ext4-combined.img.gz**: | + | |
| - | + | ||
| - | <code bash> | + | |
| - | opkg update | + | |
| - | opkg install losetup resize2fs | + | |
| - | BOOT=" | + | |
| - | DISK=" | + | |
| - | PART=" | + | |
| - | ROOT=" | + | |
| - | LOOP=" | + | |
| - | losetup ${LOOP} ${ROOT} | + | |
| - | fsck.ext4 -y ${LOOP} | + | |
| - | resize2fs ${LOOP} | + | |
| - | reboot | + | |
| </ | </ | ||
| Line 236: | Line 258: | ||
| Any remaining space will be unallocated and the drive will have a normal MBR partition table. | Any remaining space will be unallocated and the drive will have a normal MBR partition table. | ||
| - | Any partition management tool that supports MBR and ext4 can be used to create extra partitions on the drive, | + | Any partition management tool that supports MBR and ext4 can be used to create extra partitions on the drive, |
| But attention must be taken for future upgrades. | But attention must be taken for future upgrades. | ||
| Line 242: | Line 264: | ||
| ===== Upgrading ===== | ===== Upgrading ===== | ||
| - | On most embedded devices, upgrading | + | On most embedded devices |
| - | On x86 machines, on the other hand, upgrading is more complex than the first installation. | + | |
| - | One of the advantages of x86 is the easiness to backup and restore drives, using any normal backup tool that supports MBR and ext4. | + | Use any of the usual [[: |
| - | Always make a proper backup of the whole drive and test its restore before any upgrade procedure. | + | |
| - | It's also recommended to restore the backup on a virtual machine and execute the upgrade on it prior to upgrading | + | |
| - | On all procedures on this section, we must either connect the drive on a secondary PC running Linux, or boot the router with a Linux Live CD/USB. | + | <WRAP important 100%> |
| + | Your first step is always... | ||
| - | If you had used a **ext4-combined.img.gz** type of image to install, there are 4 options for upgrading: | + | **Make a backup!** |
| - | + | * From LuCI, go to **System | |
| - | | + | * From CLI use '' |
| - | - Use **sysupgrade**: this is default upgrading procedure, but the least recommended option for x86 machines. Proceed to [[docs: | + | //Just do it. Every time...// |
| - | | + | </ |
| - | | + | |
| - | + | ||
| - | The 2 last options require more steps to execute, but have the advantage of leaving MBR partition intact, therefore keeping boot and rootfs partitions sizes (in case of having resized them) and any extra partitions. | + | |
| - | At this time they are the most recommended methods of upgrading. | + | |
| - | The only exception is when new OpenWrt image brings a newer version of GRUB2. | + | |
| - | Part of GRUB2 is stored close to MBR and outside of partitions area, so we need to write a full ext4-combined.img.gz to update it. | + | |
| ==== Extracting boot partition image ==== | ==== Extracting boot partition image ==== | ||
| Line 279: | Line 293: | ||
| ==== Upgrading rootfs partition ==== | ==== Upgrading rootfs partition ==== | ||
| - | As said above, there are 2 options for upgrading rootfs partition, when we are using the ext4 file system | + | As said above, there are 2 options for upgrading rootfs partition, when we are using the ext4 filesystem |
| Writing **ext4-rootfs.img.gz** will delete any file on the partition. | Writing **ext4-rootfs.img.gz** will delete any file on the partition. | ||
| Line 308: | Line 322: | ||
| rm openwrt-19.07.8-x86-64-generic-rootfs.tar.gz | rm openwrt-19.07.8-x86-64-generic-rootfs.tar.gz | ||
| </ | </ | ||
| + | |||
| ===== Building your own image with larger partition size ===== | ===== Building your own image with larger partition size ===== | ||
| Anyone can compile OpenWrt from source, but it's a complex procedure with many options which require some experience, specially for using it on a production router. | Anyone can compile OpenWrt from source, but it's a complex procedure with many options which require some experience, specially for using it on a production router. | ||
| Line 320: | Line 335: | ||
| In many cases, OpenWrt will be back fully working on first boot after upgrading. | In many cases, OpenWrt will be back fully working on first boot after upgrading. | ||
| - | Another advantage for building a custom image is when the default rootfs partition size is too small to store all packages and we need to resize | + | Another advantage for building a custom image is when the default rootfs partition size is too small to store all packages and we need to expand |
| - | Note that, when following above procedures of installing then resizing | + | Note that, when following above procedures of installing then expanding |
| Doing so would result in the too large image file and would require enough RAM to store the whole file during building. | Doing so would result in the too large image file and would require enough RAM to store the whole file during building. | ||
| It's recommended to use on the image just enough size to store all packages plus a small amount of free space. | It's recommended to use on the image just enough size to store all packages plus a small amount of free space. | ||