Raspberry pi updates

It has become a constant annoyance that every time I build a new Raspberry Pi, the thing which is the most difficult is doing updates. I have scripts written to set everything up, but the first thing the script does is attempt to update software. Before I even reach that point, the first thing the Pi itself does is ask to update software. And it always fails.

I think this may be because of where I live. I think that the Raspbian (now Raspberry Pi OS apparently) mirrors must have one locally that is unreliable, and it gives me that one.

Two things I need to do. One is that it tries to connect using ipv6, and fails. I have to tell it to use ipv4. So one thing I end up having to do is tell apt not to use ipv6:

echo 'Acquire::ForceIPv4 "true";' > /etc/apt/apt.conf.d/99-useipv4

The second thing is to change the location of the mirror. One can look up the mirrors at https://www.raspbian.org/RaspbianMirrors, and pick one nearby, and replace the entry in /etc/apt/sources.list.