To be an advocate of open-source may require you to also be one's technician. You may know what you are doing as an administrator on your own machine, but you may not know what to do with a newbie's machine when you established a LUG between your friends and family a few years back.
This is for people who need to upgrade other people's machines, and want to do so with as little teeth-grittting and nail-biting as possible. If you are just getting into a consultant role commercially, this is also handy information to know so whatever necessary changes can be made before return to a customer.
What to do before beginning
While it is not recommended for the average user to do this. since you will not know the user's password (nor should they share it), you should advise them, if they are trusting you with their data, to unlock access of the system via root. Whenever possible, attempt to gain access of the root user account by use of the
passwd command as demonstrated:
sudo passwd root
Once the user enters their account password (no peeking), that is when you should enter your own password, so you can act as
root with implied consent. If a user is concerned about data privacy, they're always free to learn about how to handle it themselves, but if you're a close friend consent shouldn't be difficult to acquire.
From hereon, it is assumed you will be signed in and using
rootto perform all actions below, hence the exclusion of
sudo. If you are following this guide yourself as a regular user, append commands with
sudoand if you cock up,
sudo !!should work to revise failed commands.
Knowing what to keep
There are many packages which make up a Debian-based Linux system, and a lot of these libraries will be kept or upgraded during the update process to the newest version of Ubuntu. However, there are some packages you will be unable to keep or upgrade during this process because of lacking maintenance or age of software.
Anything shown with a greater-than (>) symbol is entirely up to you. FIlenames shown are expressly for examples shown.
Before committing to the update process, a couple things should be done to ensure once the machine is upgraded, it is returned exactly as they left it, aside from a new Ubuntu version.
Finding held packages
When upgrading, held packages are your worst enemy. Just so the output isn't lost, do this to show all held packages if there are any:
apt-mark showhold > ~/heldpkgs
To remove them, they must first have their hold cancelled. While you can get around this using
--allow-change-held-packages there's really no reason why you can't unhold first:
xargs -a ~/heldpkgs apt-mark unhold
-aisn't strictly necessary for
xargsnow, it will be later on.
Once all holds are released, all held packages (and dependencies) can then be removed as shown:
xargs -a ~/heldpkgs apt remove apt autoremove
Before continuing, you should have on-hand whatever third-party sources were used for the software on the machine. To retrieve this information, use of
tail as a hack to print output of all files in
sources.list.d serves this need perfectly;
tail -n +1 /etc/apt/sources.list.d/*.list > ~/3rdpartylist
In case you need it, also get only the list of sources. This can better aid people who think the output of the above is just a bit too cluttered;
ls /etc/apt/sources.list.d/*.list > ~/3rdpartydirs
You should not need anything else — So long you are able to boot into the system and log in as root, you will have everything you need for restoring the intended functionality of somebody else's machine.
Upgrading the system
Typical stuff. But there are some things I do personally as part of my upgrade routine. This is more to just have as few things running as possible during the upgrade process. After logging off;
In a TTY:
service lightdm stop do-release-upgrade
do-release-upgradefails out, try appending
-dto the command, which is a hacky way to force an upgrade should a newer release of Ubuntu be available.
Remember that list of held packages? Yeah, you can't use those quite yet, you'll need to open each
.list file in
/etc/apt/sources.list.d or edit sources using
apt update to cycle through and make sure all sources are working, and if not then try to figure it out as best you can. You want to eventually get to a point where this can be done to reinstall everything previously on-hold;
xargs -a ~/heldpkgs apt install xargs -a ~/heldpkgs apt-mark hold
Make sure everything the user wants to run is working. If you absolutely have to, create another user account and sign into that to emulate a regular user. Don't forget to delete the account and all files therein afterward. Once finished, clean up, lock root and get out;
rm -rf ~/heldpkgs ~/3rdparty* passwd root -ld systemctl poweroff
Getting root access:
Build and execute command lines from standard input:
tail to print output at a single file, with headings per-file:
How to upgrade when upgrading isn't an option: