Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision Next revisionBoth sides next revision | ||
| docs:guide-user:installation:openwrt_x86 [2023/03/25 09:01] – [Resizing root filesystem] vgaetera | docs:guide-user:installation:openwrt_x86 [2023/12/12 11:24] – [Expanding root partition] optimize code vgaetera | ||
|---|---|---|---|
| Line 38: | 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 118: | Line 132: | ||
| Any additional space in the device is unallocated. | Any additional space in the device is unallocated. | ||
| - | ===== Resizing | + | ===== Expanding |
| + | See also: [[docs: | ||
| + | |||
| + | ==== Expanding root partition | ||
| <WRAP important> | <WRAP important> | ||
| - | When installing | + | When installing |
| </ | </ | ||
| - | ==== Resizing root partition with parted ==== | + | Use [[man> |
| - | Use [[man> | + | |
| <code bash> | <code bash> | ||
| Line 132: | Line 148: | ||
| # Identify disk name and partition number | # Identify disk name and partition number | ||
| - | echo -e " | + | parted -l -s |
| - | # Resize | + | # Expand |
| - | parted -s /dev/sda resizepart 2 100% | + | parted |
| # Apply changes | # Apply changes | ||
| Line 141: | Line 157: | ||
| </ | </ | ||
| - | See also: [[docs: | + | ==== Expanding root filesystem ==== |
| + | <WRAP important> | ||
| + | Be sure to [[docs: | ||
| - | ==== Resizing | + | 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 | ||
| + | You can also use '' | ||
| The easiest way to do this is from the machine booted with a "live CD" distro like [[https:// | 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: | Here's an overview of the steps: | ||
| - Use fdisk to display the partition table. Notice the ~100MB root partition. | - Use fdisk to display the partition table. Notice the ~100MB root partition. | ||
| - | - Write down the starting sector address of the root partition (Usually /dev/sda2 or / | + | - 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 delete partition 2 but don't write the changes to disk yet. | ||
| - Use fdisk to create a new partition 2. | - Use fdisk to create a new partition 2. | ||
| Line 155: | Line 195: | ||
| - Write the partition table changes to disk. | - Write the partition table changes to disk. | ||
| - When it warns about partition signatures being present, type **n** to NOT remove the partition signature to proceed. | - When it warns about partition signatures being present, type **n** to NOT remove the partition signature to proceed. | ||
| - | - Proceed with updating | + | - Proceed with updating |
| Example output: | Example output: | ||
| Line 201: | Line 241: | ||
| </ | </ | ||
| - | ===== Updating GRUB configuration ===== | + | Be aware that deleting and recreating the root partition |
| - | If you resize your root partition | + | Make sure to update the root partition UUID in your GRUB configuration |
| - | + | ||
| - | See also: [[docs: | + | |
| - | + | ||
| - | ===== Resizing root filesystem ===== | + | |
| - | <WRAP important> | + | |
| - | Before resizing the filesystem, | + | |
| - | + | ||
| - | While it is possible to resize the rootfs online while OpenWrt is booted, you may want to perform this operation offline to reduce the chance of filesystem corruption. | + | |
| - | </ | + | |
| - | + | ||
| - | Use [[man> | + | |
| <code bash> | <code bash> | ||
| - | # Install packages | + | # Update GRUB configuration |
| - | opkg update | + | ROOT_BLK=" |
| - | opkg install losetup resize2fs | + | ' |
| - | + | ROOT_DISK=" | |
| - | # Map loop device to root partition | + | ROOT_DEV="/ |
| - | losetup | + | ROOT_UUID=" |
| - | + | sed -i -r -e " | |
| - | # Resize | + | |
| - | resize2fs -f /dev/loop1 | + | |
| - | + | ||
| - | # Apply changes | + | |
| - | reboot | + | |
| </ | </ | ||
| - | |||
| - | See also: [[docs: | ||
| ===== Adding extra partitions ===== | ===== Adding extra partitions ===== | ||
| Line 262: | Line 284: | ||
| FIXME Include instructions for EFI: '' | FIXME Include instructions for EFI: '' | ||
| + | |||
| ==== Extracting boot partition image ==== | ==== Extracting boot partition image ==== | ||
| The boot partition contains part of GRUB2 software, Linux kernel and '' | The boot partition contains part of GRUB2 software, Linux kernel and '' | ||
| Line 307: | Line 330: | ||
| 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 319: | Line 343: | ||
| 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. | ||
| Line 336: | Line 360: | ||
| We can either edit '' | We can either edit '' | ||
| Example '' | Example '' | ||
| - | |||
| - | ===== Extras ===== | ||
| - | ==== Resizing root partition ==== | ||
| - | Automatically identify root partition and resize it. | ||
| - | Preserve the script through firmware upgrade. | ||
| - | Automatically run after firmware upgrade. | ||
| - | |||
| - | <code bash> | ||
| - | # Install packages | ||
| - | opkg update | ||
| - | opkg install parted | ||
| - | |||
| - | # Configure startup scripts | ||
| - | cat << " | ||
| - | if [ ! -e / | ||
| - | && type parted > /dev/null \ | ||
| - | && lock -n / | ||
| - | then | ||
| - | BOOT_DEV=" | ||
| - | BOOT_PART=" | ||
| - | DISK_DEV=" | ||
| - | parted -l ---pretend-input-tty << EOI | ||
| - | ok | ||
| - | fix | ||
| - | EOI | ||
| - | parted -s " | ||
| - | touch / | ||
| - | reboot | ||
| - | fi | ||
| - | exit 1 | ||
| - | EOF | ||
| - | cat << " | ||
| - | / | ||
| - | EOF | ||
| - | |||
| - | # Resize root partition | ||
| - | sh / | ||
| - | </ | ||
| - | |||
| - | ==== Resizing root filesystem ==== | ||
| - | Automatically identify root filesystem and resize it. | ||
| - | Preserve the script through firmware upgrade. | ||
| - | Automatically run after firmware upgrade. | ||
| - | |||
| - | <code bash> | ||
| - | # Install packages | ||
| - | opkg update | ||
| - | opkg install losetup resize2fs | ||
| - | |||
| - | # Configure startup scripts | ||
| - | cat << " | ||
| - | if [ ! -e / | ||
| - | && [ -e / | ||
| - | && type losetup > /dev/null \ | ||
| - | && type resize2fs > /dev/null \ | ||
| - | && lock -n / | ||
| - | then | ||
| - | BOOT_DEV=" | ||
| - | BOOT_PART=" | ||
| - | DISK_DEV=" | ||
| - | ROOT_DEV=" | ||
| - | ROOT_TYPE=" | ||
| - | | jsonfilter -e " | ||
| - | case " | ||
| - | (ext4) LOOP_DEV=" | ||
| - | losetup " | ||
| - | (squashfs) LOOP_DEV=" | ||
| - | | sed -n -e " | ||
| - | esac | ||
| - | resize2fs -f " | ||
| - | touch / | ||
| - | reboot | ||
| - | fi | ||
| - | exit 1 | ||
| - | EOF | ||
| - | cat << " | ||
| - | / | ||
| - | EOF | ||
| - | |||
| - | # Resize root filesystem | ||
| - | sh / | ||
| - | </ | ||
| - | |||
| - | ==== Updating GRUB configuration ==== | ||
| - | <code bash> | ||
| - | # Install packages | ||
| - | opkg update | ||
| - | opkg install lsblk | ||
| - | |||
| - | # Configure GRUB | ||
| - | BOOT_DEV=" | ||
| - | BOOT_PART=" | ||
| - | DISK_DEV=" | ||
| - | ROOT_DEV=" | ||
| - | ROOT_UUID=" | ||
| - | sed -i -r -e " | ||
| - | </ | ||