All my configs were reset when I sysupgraded from 21.02.0-snapshot to 21.02-rc1

There is no way to keep installed packages with default images. There are scripts or commands floating around on the forum to remedy that. You could also use the image builder to repackage your own image and include all the packages you use. Similar result, but a cleaner approach if you ask me: you don't need your devices to have internet access and it's a one-time operation (to be repeated with each new image you install of course, but installing packages afterwards would need that as well).

Sysupgrade can be told to backup all the files you'd like to keep. That's in /etc/sysupgrade.conf.

1 Like

Ok so on https://downloads.openwrt.org/releases/21.02.0-rc1/targets/x86/64/ I download openwrt-imagebuilder-21.02.0-rc1-x86-64.Linux-x86_64.tar.xz.

https://openwrt.org/docs/guide-user/additional-software/imagebuilder describes how to build image using make image.

So, on every new release, instead of downloading the file openwrt-21.02.0-rc1-x86-64-generic-ext4-combined.img.gz, I build the image adding to it all packages I want.

Then, how to properly sysupgrade it? If it has all the packages, then I can keep my configs. Or is it easier to just give up on them and copy them back after the sysupgrade?

If we have to resize rootfs and copy configs back after each sysupgrade, then building the image is the same as sysupgrading default image, resizing rootfs and installing the packages from opkg, right?

Is it possible to save configs on a 3rd partition, in example mounting it on /etc? If there's a 3rd partition, is there any risk of sysupgrade destroying it?

Sorry I'm rly confused now :-x

More choice isn't always better right? :wink:

Sysupgrade doesn't care if your image is vanilla or not. So you can still use it with your custom images. Either you include the configuration files there as well, or you just add all the configs that you'd like to keep (but aren't kept now) into /etc/sysupgrade.conf. Then sysupgrade will preserve them (unless you use -n of course).

It's less intensive to configure sysupgrade to retain the configs than to copy them back and forth every time you change them. Of course, regardless of the option you pick, it makes sense to have a separate backup anyway, in case stuff goes wrong somehow.

Resizing rootfs means doing it yourself post-installation (manually, I reckon, which you probably do now already?) or compiling an image (using the buildroot, not the image builder).

It sure is possible to add a third partition, but that is again manual work. If told to do so sysupgrade will back up your configuration files and restore them in the sysupgrade process. So a separate partition just sounds like extra work. I'm not sure about the sysupgrade internals, and how it manages x86 installations.

1 Like

Yes, building your own image is the fastest way to obtain an image with the packages you need. Than forget about sysupgrade, use dd.
Considering that the x64 build has only one profile, just use something like ...
make image PACKAGES="pkg1 pkg2 pkg3 -pkg4 -pkg5 -pkg6"
You will obtain several images, use the x64 combined one (EFI if you like)
As an example, here is what I use. You can see that it is highly configurable !
make image PACKAGES="luci luci-theme-material intel-microcode kmod-ata-ahci kmod-usb2 kmod-usb3 -ppp -ppp-mod-pppoe -bnx2-firmware -kmod-bnx2 -kmod-e1000 -kmod-e1000e -kmod-ixgbe -r8169-firmware -kmod-r8169 -kmod-forcedeth kmod-ath10k-ct ath10k-firmware-qca988x-ct wpad-wolfssl openvpn-openssl openvpn-easy-rsa luci-app-openvpn openssh-sftp-server"

Ok, so I add to /etc/sysupgrade.conf all files and folders I wanna preserve. This avoids having to bring them back manually. This includes /usr/script/ where I'm saving my custom python scripts. The most troublesome case is network which takes the router down from LAN subnet.

Then there's the issue of rootfs size. It was enough after I installed everything I use ATM, it has around 100MB and has 40MB free. But the SSD is 256GB, so there's a lot of wasted space.

I'd like to either increase rootfs size, or save installed apps on another partition. Which is the most compatible and reliable?

Backup isn't an issue for me. I'm using a Subversion repo to keep track of all my settings and scripts. OpenWRT's subversion-client doesn't support HTTPS and I'm unable to find how to compile it myself, so I'm keeping the working copy on my server and using a script full of rsync to sync them.

Does it support setting the partition size? Then I could build it having boot partition with 512MB and rootfs partition with 5GB. That's big enough to hold it on Parted Magic on /tmp. Then I add network, dhcp, sync script and authorized_keys files to it, dd it into SSD. It'd have LAN access and be able to easily sync all other configs and scripts back.

How does it look like?

The size of boot partition is automatic, and there is no need to change it. You can set the size of rootfs but it will take longer time to dd.

1 Like

I forgot about an option : while building an image, you can pass custom files, and so configure settings.

1 Like

tnx a lot I'm gonna try to build my own image and test it.

About the FILES=files/ parameter, how can I pass multiple files to it?

It copies everything that is inside the directory "files/". :sunglasses:

1 Like

I mean, if I wanna set some files on a folder like /etc/config/. And how to set multiple files.

And how to set where they are placed inside the image.

This command copy every files and directories that are inside the files/ directory.

Create a directory files/
Put every files and other directories you need inside, such as etc/, etc/config/ ...
using FILES=files/ will copy everything
Beware of the path

Note: The files/ folder is best in the imagebuilder root folder ( where you issue the make command ) otherwise it is best to use an absolute ( full ) path.

1 Like

oh so what's inside files/ go inside rootfs / including folders in it?

So /etc/config/network will go files/etc/config/network?

oh so what's inside files/ go inside rootfs / including folders in it?

Yes. Very convinient isn't it ?

So /etc/config/network will go files/etc/config/network?

No
files/etc/config/network will go to /etc/config/network
:wink:

1 Like

I made the test.

I restored on a VM my backup from before the sysupgrade, then I ran sysupgrade for RC1 and partition sizes were changed back to img sizes. Oddly, config files weren't lost.

Then I restored it back, and now I created a 200GB ext4 partition on the end of the disk and left some GB free on the middle of it. After sysupgrade, partitions kernel and rootfs were back to default sizes... and the 3rd is gone!!

So, yeah, as it is now, OpenWRT doesn't allow to use the disk for anything else. Neither to increase partitions sizes or to add extra partitions to the disk.

I'm gonna study image builder to learn its features, specially if it supports changing default partitions sizes.

My guess ATM for the best solution is to create a custom image with all the packages I like and use squashfs. I know very little of it yet, it seems it leaves rootfs as readonly and has a 3rd partition where it writes any changes. So, I could add my custom long time configs and packages to the img, hopefully increase the partitions size, and leave on a 3rd partition my scripts and short time configs.

I must confess that on x64, I never use sysupgrade, and always use dd to write image : it allows a clean start. Than I use a partition manager to resize rootfs, and luci to restore the config. I know I can include the config in the image (FILES parameter), but I prefer do it manually so I can use the latest backup.

OpenWRT doesn't allow resizing rootfs because it is mounted. But you can create an extra partition.

Setting a bigger rootfs size means more time to dd it, and most of the content will be empty. It seems faster to use a small size for image, dd it, than increase the size with a partition manager. Also if you use squashfs, you can't resize the partition.
Best thing to do now is to learn the image builder. It's an interesting tool. Look for packages you don't need (ppp, nic kmod drivers ...) and add some fitting your need (vpn ...). Have fun.

1 Like

My issue with partition size is the case of adding too many packages and it becoming too small and don't fit.

It's useless to resize it, what I did, if on next upgrade this extra size is lost.

https://openwrt.org/docs/guide-user/installation/openwrt_x86 says that we can use TARGET_ROOTFS_PARTSIZE to change it. I'm gonna try to find out where it is set.

I'm gonna try image builder now to see how it works :slight_smile:

Update. Well it was pretty easy to build a custom image. It's damn easy to add all packages we need to the image, as long as they fit on the small space of course. I also copied all my configs and scripts directly to it, and once the image is installed they are all there and I just need to ln -s the scripts. Even my vm.network which I use when installed/restored on a VM is immediatelly available.

Once I have everything configured I'll hardly change anything, so it will be a set and forget and upgrade will be easy. Of course, I'll try on VM before and will have backup rdy if needed :slight_smile:

Ok, I almost did it! Here's what I did:

  1. built image for 19.07.7
  2. used dd to write openwrt-19.07.7-x86-64-combined-ext4.img on sdb
  3. booted and everything working
  4. created sdb3 with 200GB on the end of the disk, leaving some free GB on the middle
  5. built image for 21.02.0-rc1
  6. used dd to write openwrt-21.02.0-rc1-x86-64-generic-kernel.bin on sdb1 and openwrt-21.02.0-rc1-x86-64-generic-ext4-rootfs.img on sdb2

Because I wrote images to partitions and not to disk, sdb3 wasn't lost and remained available. I'm able to mount sdb2 (on Parted Magic) and all files are there.

But sdb1 failed and I lost boot. It stays on the basic shell waiting for commands, which I guess is on MBR special area. I'm unable to mount sdb1.

It looks that kernel.bin isn't a image file and isn't meant to be written on a partition. So, what to do with it? And what to do on the boot partition when we use ext4-rootfs.img?

I also noticed that 19.07.7 uses GRUB2 1.02 and 21.02.0 uses 1.04, so it's not only the kernel that needs to be upgraded.

If I find out how to write the boot partition, then it will be solved!

Building a custom image is indeed easy. How much diskspace do you need for your packages ?
Some tips:

  • include kmod-ata-ahci for disk access.
  • tools to handle, mount partitions (see using storage page)
  • include CPU microcode (intel or AMD) for updating
  • remove unnecessary nic drivers

kernel.bin is obviously not an image and you can't dd it.

1 Like

Tnx a lot for the tips! :smiley: I haven't noticed there's a amd64-microcode

I noticed that 21.02 uses much more storage than 19.07, and kept the same partition size.

As I said, for now the default size is enough. ATM I'm considering use the spare 250GB on a 3rd partition. That would help in storing backups in example.

In the future I'm gonna use Yamon or some other tool to measure traffic consumption. On my EdgeRouter I had to place it on my NAS and use cifs to access it from the router. Now I wanna keep it on a nice local safe partition.

It seems it's possible to set custom rootfs size, but that requires menuconfig, which is available only for compiling the whole thing including kernel. I had tried it but am not comfortable to use it on production.

It's the only file resembling boot partition. How to build and dd it?

I have not tested to create custom sized rootfs. I need a few packages, so it always fits in the default size.
About kernel.bin ... good question ! I haven't figured out yet how to use this. If it is provided, it obviously fit a need.

1 Like