Back story: I was messing around with ubuntu and an HP laptop, and then remembered about an 2009 macbook with a broken screen I had in my garage. I plugged in the same hardrive as in the HP laptop and, to my surprise, it worked! It booted in the OS and everything worked OK.
That got me thinking, does ubuntu not care which hardware it is booted on (except when the hardware is incompatible)? Does ubuntu have some specific components it uses on a desktop computer than on a laptop? Is it possible to take a hardrive from one ubuntu machine and use it on totally different PC?
I have heard that windows has a "safety" feature that doesn't allow the OS to boot if different comp is used than last boot. Does ubuntu provide such a feature? Does ubuntu take track of the current hardware and store in a file somewhere?
How an operating system (Ubuntu or Windows) interacts with the hardware of a computer depends on various drivers. If you use Windows in a computer and attach a new hardware you may have dealt with installing new drivers for the new hardware. In Ubuntu things are a bit different.
2 Types of Drivers
In the world of Linux there are two types of drivers: Open Source, and Proprietary.
Open Source Drivers
These drives are built into the OS Kernel. When the computer boots the OS checks the hardware and loads the needed driver automatically.
Proprietary Source Drivers
There are some hardware that need Proprietary drivers. Typically these are graphics cards, WiFi cards etc. It is up to the hardware manufacturers to make the drivers open source or Proprietary. Typically these drivers are not installed automatically in the Ubuntu kernel. This means some hardware do not work with Ubuntu until the corresponding driver is installed.
Moving Ubuntu
I think the "safety feature" of Windows is mainly for the safety of Microsoft and protect their revenue streams. Since Ubuntu is open source and free, there is no such restriction. It depends on what kind of hardware the new computer has. If all the hardware in the new computer have existing opensource drivers, then there should be no problem moving the hard drive from the old to the new computer. If the new computer has a component that needs a proprietary driver, then that component won't work.
Full Disk Encryption with TPM
A Security Feature
Ubuntu 23.10 and above can be installed with an advanced option of full disk encryption where the decryption key is stored in the TPM chip. If you use this option during installation it will prevent that installation of Ubuntu from booting if the boot disk is taken out of the current computer and put in a different computer.
Hope this helps