Ubuntu 22.04 LTS servers and phased apt updates
utcc.utoronto.ca
utcc.utoronto.ca
/etc/machine-id isn't the only thing to worry about when duplicating a VM - think SSH host key, DHCP leases, various filesystem UUIDs, log files, MAC addresses in ifcfg-* files and udev-persistent-net rules...
You can use virt-sysprep[1] to clean up a disk image.
boot the clean base image and configure it on boot with packages, ssh keys, custom commands, etc.
# Hack: Change the default MAC address after network but before dhcpcd runs
systemd.services.setmacaddr = {
script = ''
/run/current-system/sw/bin/ip link set dev eth0 address ${macaddr}
/run/current-system/sw/bin/systemctl stop dhcpcd.service
/run/current-system/sw/bin/ip addr flush eth0
/run/current-system/sw/bin/systemctl start dhcpcd.service
'';
wantedBy = [ "basic.target" ];
after = [ "dhcpcd.service" ];
};
If you don't do this, it uses some black magic to decide the MAC address based on various hardware, making system migration and maintenance a nightmare.While I’m confused as to why the boot would need to decide on a MAC address (VM or cheap SBC without a burned-in address? the first case might be easier to correct from the outside), the general state of NixOS is that some things are very flexible while others only cover some common cases (ones that the original author needed to solve). Unlike a traditional distro where the package manager will complain if you replace distro-provided stuff, in NixOS it’s entirely possible to override parts that don’t work for you rather than paper over them with programmatic overrides like these. It’s not even hard to upstream your changes if you make them backwards-compatible, although the benefit can be limited because the testing is not particularly thorough so other changes may still inadvertently break them.
The next time I rebuild this server, I'll go back to Ubuntu or Debian and use build scripts for "good enough" determinism. For the time being, I just run everything important in LXC and Docker containers on top of this delicately balanced NixOS hypervisor for as long as it'll last.
Troubleshooting guides for NixOS are non-existent, but the system itself is not all that difficult to inspect: two things you can do is `nixos-rebuild build` without switching and meditate on ./result/; and inspect `(builtins.getFlake(toString ./.).nixosConfigurations` in `nix repl` (use import etc. if not using flakes) as that will include every derived setting down to the text of generated config files, not only those you specified explicitly.
But you might’ve just nerd-sniped me, we’ll see.
ETA: Looks like it’s indeed systemd-networkd’s doing[1]. For a static interface, setting `networking.interfaces.${NAME}.macAddress`[2] to the desired value should work.
[1] https://freedesktop.org/software/systemd/man/systemd.netdev...., see the description for MACAddress.
[2] https://search.nixos.org/options?show=networking.interfaces....
Given that OP uses dhcpcd, it's unlikely to be systemd-networkd.
And it looks like, curiously, explicitly configured interfaces have their setup expressed as .link units even if networkd is not in use[1]. A comment[2] states: “.link units are honored by udev, no matter if systemd-networkd is enabled or not”.
It seems that .link units are nowadays interpreted not by networkd (which NixOS gates with useNetworkd) but by udevd (which it does not). The documentation for them (but not for udevd) even points that out[3] if you’re the kind of person who reads introductions: “link.link: A plain ini-style text file that encodes configuration for matching network devices, used by systemd-udevd(8) and in particular its net_setup_link builtin”.
[1] https://github.com/NixOS/nixpkgs/blob/65e07f20cf04f5db9921dc...
[2] https://github.com/NixOS/nixpkgs/blob/65e07f20cf04f5db9921dc...
[3] https://www.freedesktop.org/software/systemd/man/systemd.lin...
kstenerud: I assume you tried that option?
Edit: ah, you caught that in an edit :-)
Trying to think of a use case I thought of wireless + wired, would be kind of neat if they had the same IP. But that falls apart completely if you have them connected at the same time (which I often do).
We’re there any obvious issues in such a setup?
I'm not sure how it'd fit into a Network Manager or systemd world. There really wasn't any particular trick to it, IIRC I used link monitoring to detect link failure, though I might have used ARP, and set the ethernet as the primary interface, just using the standard Linux bond driver.
Otherwise the clone would not properly register on the network. Perhaps it was only when speaking to the Domain Controller though.
IIRC the later versions of Norton Ghost, which was what we used, did this process for us automatically.
Russinovich eventually pulled the tool from circulation.
It's undeniable, in my experience, that the tool did help, despite all the swearing to the contrary. Making a leap from there to believing that it probably made it too easy to clone Windows machines in a way that Microsoft had no control on, and hence asked him to pull it, doesn't seem so crazy though.
Microsoft doesn’t care if you clone systems, (why would they?) they care about the volume of help desk tickets created by doing it wrong.
And a lot that are not helpful, iirc. It was probably 10 years ago when I had to deal with this, but my recollection is that Sysprep was messing with a lot of stuff - more than I needed.
> Microsoft doesn’t care if you clone systems, (why would they?)
Lol, licenses, of course. Nowadays they got a bit softer on the issue, but back then they were still very very twitchy about duplicating and virtualizing systems.
Huh? I’ll grant you that Microsoft was picky about being paid for their software, but they produced a ton of tools to support cloning and duplicating. License compliance was handled with audits and CALs, not some weird cabal of anti-imaging.
Update-Manager::Always-Include-Phased-Updates;
APT::Get::Always-Include-Phased-Updates: True;
Update-Manager::Never-Include-Phased-Updates;
APT::Get::Never-Include-Phased-Updates: True;
Surely the best setup would be to set some canaries to always include phased updates, and the rest of the fleet to never include them (so you get them once they are at 100% rollout and no longer phased)?> We could set some very important machines to only get updates when packages reach 100% and stop being phased updates, but Ubuntu has a good record of not blowing things up with eg OpenSSH updates.
Set this in some of your apt.conf.d:
Update-Manager::Always-Include-Phased-Updates;
APT::Get::Always-Include-Phased-Updates; Update-Manager::Never-Include-Phased-Updates;
APT::Get::Never-Include-Phased-Updates: True;"always include" effectively puts you in phase 0 - if an update is being phased, you're an eager beaver.
"never include" effectively puts you in phase 100 - if an update is being phased, you'll wait until the phasing is complete.
AIUI OP's problem isn't that he wants these updates on day 0, it's that he wants his environments to be consistent with each other, which either of these options would provide.
Update-Manager::Always-Include-Phased-Updates;
APT::Get::Always-Include-Phased-Updates: True;
In a file /etc/apt/apt.conf.d/99phased-updates. I've also tried the Never version of them. Neither one seems to have any effect. The only thing that seems to work is the suggested command-line setting: sudo apt -o APT::Get::Always-Include-Phased-Updates=true upgrade
[1]: https://askubuntu.com/questions/1246962/what-apt-configurati... Update-Manager::Always-Include-Phased-Updates;
APT::Get::Always-Include-Phased-Updates True;
Note the lack of a ":" in the APT:: line. Putting a : silently causes it to do phased updates.It sounds like this problem shouldn't / wouldn't affect most 'business' servers iff you were running the LTS (stable) branch, as security updates aren't phased (as per TFA's comment).
LTS Ubuntu, AIUI, is similar to Debian stable -- it only receives security patches, not new (feature) versions of any packages.
Reviewing apt & apt-get man pages here (I'm on 2.5.4) I see no references to 'phase'.
Reviewing Debian's changelog.gz I see the first phase reference in 2.5.1 (2022-07), and a subsequent reference in 2.5.3 (2022-09) - but nothing about 'phased updates' on the Debian wiki, and per Ubuntu's discourse[0] phased updates were first introduced to apt in version 2.1.16 - so I'm guessing it took a while for those to be fed upstream (to Debian - assuming they are still considered upstream for - dare I say it, the canonical owners of - apt/apt-get).
There's an askubuntu [1] post describing the what & why behind this change, and it sells the reader on the 'improved stability' claim, while downplaying TFA's concerns (potential random inconsistency), while acknowledging poor defaults, tooling, and documentation.
It does feel a bit of an odd solution to me - Debian provides a testing branch which seems to serve this function - some relatively small subset of users will use testing and find your bugs for you. If you seek safety & predictability then you stick with the stable / LTS branch.
In contrast, randomly selecting some subset of your users - with Ubuntu's typical opt-out default - to randomly get an early / deferred updating of some random subset of your installed packages just seems ... well, I can see why TFA was frustrated.
[0] https://discourse.ubuntu.com/t/phased-updates-in-apt-in-21-0...
[1] https://askubuntu.com/questions/1431940/what-are-phased-upda...
On review it doesn't make much sense - searching for 'phase' there's an 'Add support for phased updates' in 2.5.3, but a few months earlier, in 2.5.1, the comment is:
"(Temporarily) Rewrite phased updates using a keep-back approach."
I thought I'd done a case-insensitive search before, but obviously hadn't, as there's one earlier reference in 2021-01 (for v2.1.16), which kind of aligns with the askubuntu's historical mention of 2.1.16 on the timeline, but the description certainly doesn't sound like the base feature (phased updates) introduction.
"Add support for Phased-Update-Percentage, previously used only by update-manager."
On Wed, 2019-05-15 at 02:42:56 +0930, Dan Streetman wrote:
> in Ubuntu, sudo retains the calling user's $HOME > > this is different from upstream sudo as well as all other UNIXes and > even the sudo documentation we provide. Should we remove our custom > patch that adds this behavior?
Ubuntu is diverging.
You can simplify that to "sudo -i".
'sudo su -' instead executes the 'su -' command, giving you a root shell, as a superuser with 'sudo'. If you left the 'sudo' out, you'd have to type the root password.
$ sudo -l
[...]
User yrro may run the following commands on fw33748-02:
(ALL : ALL) ALL
(ALL : ALL) !/usr/bin/sudo, !/usr/bin/su, !/bin/su
So $ sudo su -
Sorry, user yrro is not allowed to execute '/usr/bin/su -' as root on fw33748-02.example.qq. $ sudo /bin/sh -c su -
It's never useful to deny certain commands to a user if that user is allowed to open a shell. Any shell. So you probably want to change that first line to (ALL : ALL) NOEXEC: ALL
and provide a whitelist for all tools that do spawn children as part of their normal operation (such as apt, dpkg, and probably half of all unix tooling).Other distros slowly started to adapt the "secure by default" policy and came up with different approaches. OpenSUSE for example still uses the root password for sudo. The patch to /etc/sudoers is massive.
I wouldn't expect sudo to behave the same across distros, there is a lot of history to it.
Indeed.
Try and install 22.04 on a server that has two exactly identical NVME drives, you're very likely going to be in for a very interesting adventure involving a strange beast called 'multipath' devices.
It was so bad I had to switch back to the legacy text installer for 20.04.
At install time?
All my attempts have failed in the following fashion:
. I boot the text only installer
. Once it runs I switch to a shell
. I edit the python code of subiquity / curtin to rip out anything that has to do with mutlipath
. I disable all systemd shite related to multipath
. I kill the installer (and systemd restarts it)
. When I get to partioning, I finally see my NVME devices instead of the weird multipath stuff
. I create a raid-0 partition on them
. The installer then fails miserably
Care to share your recipe?```
blacklist { devnode "^sd[a-z0-9]+" }
```
In /etc/multipath.conf (modify for nvme as needed)
This was an unusually badly communicated change. I'm fairly attentive to this type of stuff and was caught by surprise.
We're about to start rolling out 22.04 at work. I'll make sure to disable this on servers, non-determinism is not a desirable property for system updates.
"Haha here's how you disable the shitty ads ;)" isn't something I expected, even from Canonical.
The other big Ubuntu update hassle is a constant string of notifications demanding that you exit applications so they can be updated. However, you have to keep them closed long enough for an updating cycle to notice. And then there's the notification that you need to close the Snap daemon so it can update. The user doesn't start the Snap daemon; it starts at startup and has no desktop presence. Lame. This may have been fixed; I haven't seen that recently.
After a manual update it worked once again. Between the update and the fix there might be a few days in between tho as the updates were automatically installed, but the effect/issue can only be seen after a restart.
Sorry had to correct, for my own understanding =)
This is not a good idea, the machine ID is supposed to be unique and shouldn't change over the lifetime - a handful of software relies on this property and it's the best identifier for an installation if you can't rely on hostnames.
What we couldn’t do was get to both consistent and really timely patching states but this was a decade ago where that was arguably slightly less important.
I understand why there's people here who don't like that behaviour, but I like the idea of non-security phased updates, so I'll be leaving machines with the default behaviour until I encounter a problem caused by it.
After reading some of the replies here, I think that I ought to disable this feature on all of my systems, but I worry that the whole situation foreshadows the possibility that the Ubuntu maintainers want to play more fast and loose with the “stable” release feeds. You know, move fast and break things.
A practical problem with these phased updates is that you may end up with different versions of some software on your fleet of (until now) identical servers and you have no way of avoiding it.
.. a job they should have left to the sysadmins in charge of those machines receiving said updates.
If the OS developers have the ability to save thousands of man hours of their users they should do so.
How this works is that the package index contains a stanza Phased-Update-Percentage: giving a number between 0 and 100. Then your client picks a number in the same range, and accepts an update if the repository's value is higher than the client's value.
Whether the fixed value comes from your mirror or Ubuntu's, makes no odds - You still have a fixed value on the server and a variable value on the client, so the outcome is still variable. Caching the index, or mirroring it without regenerating it, still leaves this decision to the end client.
Something else I found interesting looking into this mechanism - the seed for the rng is sourcePackage-version-machineID. So you won't "that one machine that always updates last" or "that one machine that charges head-first into phased updates", it should be randomly distributed for each version of each package.
apt-cache policy x(a) add several more release channels? E.g., latest-phase-1, latest-phase-2, ..., latest-phase-n, or
(b) add highly granular, timestamped releases? E.g., 2023-01-01.1, 2023-01-02.1, 2023-01-02.2 (if needed), etc., or
(c) publish explicit rollout-group channels, and let user pick their group if they want? E.g., stable-stage{1...k}-group{1...j}, and also offer an optional technique for admins to participate in a lottery for which group they draw from?
Then individual computer owners could decide policy for themselves.
I really don't understand how Canonical's views on the proper role of a Linux distro provider could have diverged so far from my own. I think they're the ones who have changed, but I'm not sure.
Still though, the last thing I want the Linux community to do is drop everything to focus on $SOMETHING. The people using Linux are a diverse audience with many different use-cases, and naturally not all of them want another MacOS to babysit.