Both sides previous revisionPrevious revisionNext revision | Previous revision |
misc:acpi_patch [2025/04/29 00:10] – rqm | misc:acpi_patch [2025/06/29 00:26] (current) – 92.40.32.213 |
---|
| |
| |
| |
---- | |
FIXME FIXME FIXME | |
PLEASE DISREGARD BELOW FOR THE TIME BEING, IT IS A WIP AND KNOWN TO BE INCORRECT. | |
FIXME FIXME FIXME | |
---- | ---- |
| |
=== II. The Custom Installer Way === | |
| |
Creating a custom installer requires you to have another amd64 machine running OpenBSD. You will be able to build the kernel at the version your OpenBSD machine is already on. You need to make sure you are fetching the appropriate version of the sources, like above. | ===== Updating the patched system ===== |
| If you want to avoid having to wait 2+ hours again TWICE everytime you have to update your system, there is, fortunately, a much quicker way to do it. Basically the less painfully slow update method is a hybrid of manual and automatic installation with custom-compiling the kernel. Credits go to [[https://marc.info/?l=openbsd-tech&m=175031825008339&w=2|Stuart Henderson]] for pointing out this possibility. |
| |
The procedure, in short, involves building the custom GENERIC.MP image as well as a custom RAMDISK, but WITHOUT running ''make install'' at the end. Then you create a ''vnode'' device out of the downloaded ''installXX.img'', mount it, then overwrite the installer's {bsd,bsd.mp,bsd.rd} files with the ones you created. | The below will be a walkthrough that follows ''-current'', a few commands will be different for ''-stable'', these will be indicated. |
| |
== 0. Preliminaries == | ==== 0. Preparation ==== |
| === 0.a. READ UP. Seriously. === |
| Read through the [[https://www.openbsd.org/faq/upgrade77.html#NoInstKern|OpenBSD Manual Installation howto in the FAQ]] first as well as the man pages linked above, if you have not done so. They will make your life much much easier. |
| |
You will also need a copy of ''installXX.img'' and a flash drive. (Some Macs cannot boot off an SD card so best to stick with USB flash drives). | === 0.b. Preparation === |
| Follow the "Preparation" steps on the Manual Upgrade page: especially on becoming root "properly" and installing the boot blocks. Make sure you install the boot blocks to the appropriate drive, do not just go with "sd0" as it was in the tutorial, if, say your root is on e.g. sd3. |
| |
If you are on ''-current'' then you need to make sure that the installer you download corresponds to the snapshot you are on. To see what version exactly you are on, run: | ==== 1. Get the upgrade files ==== |
| Fetch the updates and move them to a new location. When you run ''sysupgrade'' the installer files are stored in ''/home/_sysupgrade'', and two extra files are created, ''/bsd.update'' and ''/auto_upgrade.conf''. You want to copy the installer files from ''/home/_sysupgrade'' somewhere else, and delete the auto-update files. |
<code> | <code> |
$ sysctl kern.version | # sysupgrade -ns |
kern.version=OpenBSD 7.7-current (GENERIC.MP) #0: Wed Apr 23 20:21:10 BST 2025 | # mkdir /usr/update |
[..snip..] | # mv /home/_sysupgrade/* /usr/update/ |
| # rm /{bsd.update,auto_upgrade.conf} |
</code> | </code> |
| **NB**: On ''-stable'' you want to run ''sysupgrade -n''. |
| |
Note the date; in the above example, it's **"Apr 23 2025"**, so you need the installXX.img from that same snapshot - as it's on **7.7-current** it will be ''install77.img''. | ==== 2. Update the source tree ==== |
| Follow the **Anonymous CVS** guides for updating the source tree to the latest version. |
A good place to get previous snapshots is on ''ftp://ftp.hostserver.de/archive/'', choosing the ''YYYY-MM-DD-HHSS'' format directory that corresponds to the date of your ''kern.version'' date; so in this example, the file needed would be at: | ☛ **ASIDE** - What to do if acpi.c changes drastically and the patch doesn't work anymore? ((The file we have been patching, ''/usr/src/sys/dev/acpi/acpi.c'', might change in the future. It is good to check the CVS logs, or keep an eye on the [[https://github.com/openbsd/src/commits/master/sys/dev/acpi/acpi.c|acpi.c on GitHub's CVS mirror]]. If you would see that the lines we have been working with have changed in the source or new features have been introduced, then you need to revert your local modifications to the CVS version. To do this, you need to run, |
| |
''%%https://ftp.hostserver.de/archive/%%**2025-04-23-0105**/snapshots/amd64/**install77.img**'' | |
| |
==== Upgrading your system after patching ==== | |
Should a new release come out, unless there's a rewrite of ''acpi.c'', you will need to re-patch your kernel upon upgrade. | |
| |
On your working, normally booting system, you need to patch in place like with "The Slow Boot Way" above. | |
| |
First, you need to **follow the "anoncvs" tutorial on the OpenBSD website and upgrade the source tree.** | |
| |
When updating it will skip "acpi.c" because you have manually changed the file locally. Overwrite the local changes by running: | |
<code> | <code> |
# cd /usr/src/sys/dev/acpi/ | $ cd /usr/src/sys/dev/acpi/ |
# cvs update -C acpi.c | $ cvs update -C acpi.c |
</code> | </code> |
| CVS will tell you where it stashed the previous file, it usually starts with ".#" or similar. You can then run ''diff'' and see what the changes were, decide whether you need to find the lines that were previously around :823 and automatically or manually patch again, or not.)) |
| |
This will then move your own version of ''acpi.c'' to a hidden backup file, something like ''.#acpi.c.1.444'' or similar, keep a note of the command output. Run a diff on the freshly fetched acpi.c and the one you had: | To update the source tree on ''-current'', run: |
<code> | <code> |
# diff acpi.c .#acpi.c.1.444 | $ cd /usr/src |
| $ cvs -q up -Pd -A |
</code> | </code> |
| **NB**: On ''-stable'' you want to use '' -rOPENBSD_7_7'' as the last parameter instead of "-A". |
| |
If the only two lines that differ are the ones you commented out with the above patch, just ''mv'' back ''.#acpi.c*'' to ''acpi.c'' because there were no changes. If the output of ''diff'' is more substantial, you might need to edit out the two lines by hand again; if they still exist, and give us a shout so we can also update this tutorial. | ==== 3. Re-compile the GENERIC.MP Kernel ==== |
| See above, but run ''# make clean'' before compiling and **do not** run ''# make install'' at the end: |
=== Download the upgrade === | |
Fetch the release you are upgrading to, but without rebooting and installing automatically. | |
| |
On ''-current'' this will be: | |
<code> | |
# sysupgrade -ns | |
</code> | |
| |
On ''-stable'' this will be: | |
<code> | |
# sysupgrade -n | |
</code> | |
| |
Sysupgrade will download the new files for the download, you will find then under ''/home/_sysupgrade''. | |
| |
=== Make and install the Ramdisk === | |
To build ''bsd.rd'', follow the instructions for building as above, but instead of ''GENERIC.MP'' you need to build build ''RAMDISK''. | |
<code> | <code> |
$ doas -s | # cd /sys/arch/amd64/compile/GENERIC.MP/ |
# cd /sys/arch/amd64/compile/RAMDISK | # make clean |
# make obj | # make obj |
# make config | # make config |
# make | # make |
[...eventually...] | |
ctfstrip -S -o bsd bsd.gdb | |
# install -bp /sys/arch/amd64/compile/RAMDISK/obj/bsd /bsd.hax | |
</code> | </code> |
| Your newly compiled kernel file, ''bsd.gdb'' will be in the symlinked ''obj'' directory. The symlink points to ''/usr/obj/sys/arch/amd64/compile/GENERIC.MP/bsd.gdb''. |
| |
This will give you a "bsd.hax" ramdisk that you can boot to on next reboot. But don't just reboot yet. | Now we have: |
| * The latest update files stored away safely |
| * The latest kernel, compiled with our own patch |
| |
=== Make and install the patched kernel again === | So it is time to move on to the installation. |
| |
Before rebooting, you need to re-compile ''bsd.mp'' and put it ''/home/_sysupgrade'': | ==== 4. Manual installation ==== |
| This follows closely the official [[https://www.openbsd.org/faq/upgrade77.html#NoInstKern|manual installation guide]], but diverges for the installation of the kernel. |
| |
| === 4.a. Make sure you have done all the preparation in the official guide === |
| Did you? |
| |
| === 4.b Install the newly compiled kernel === |
| We did not run ''make install'' after compiling because we are going to do this little dance as suggested: |
<code> | <code> |
$ doas -s | # cd /usr/update |
# cd /sys/arch/amd64/compile/GENERIC.MP | # ln -f /bsd /obsd |
# make obj | # cp /usr/obj/sys/arch/amd64/compile/GENERIC.MP/bsd.gdb /nbsd && mv /nbsd /bsd |
# make config | # cp bsd.rd / |
# make | # cp bsd /bsd.sp # You might not even have this file, relatively safe to skip this last one if you do not intend to run in single-processor mode |
[...eventually...] | |
ctfstrip -S -o bsd bsd.gdb | |
# install -bp /sys/arch/amd64/compile/GENERIC.MP/obj/bsd /home/_sysupgrade/bsd.mp | |
</code> | </code> |
| |
Reboot... Done! | === 4.c follow the rest of the Manual Install Process === |
| Follow closely the linked manual installation guide, and continue the process: Enable KARL; Install new userland. Reboot. Run MAKEDEV, update the boot loader, run ''sysmerge'' and ''fw_update''. |
| |
| DONE! |