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.
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?
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.
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.
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.
I'm gonna try image builder now to see how it works
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
Tnx a lot for the tips! 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.