Can I have an operating system on a USB that will boot up only when the USB is connected?
Do you mean you want your session to persist, so you can, for example, save documents, email, etc. to the USB, and install programs that will be available the next time you boot from it?
If that is the case, you need to create a persistent image on the USB with storage space. Caveat: Ordinary flash USB storage is much slower than running from a hard disk drive, much less SSD. Use the fastest drive feasible, perhaps a small external SSD, to avoid that issue.
The steps suggested by iTecTec require two USB drives, if you do not have a working Ubuntu installation. Basically,
- Install Ubuntu live on two USB drives.
- Boot Ubuntu from one of the USB drives,
- Run GParted to modify the second drive to add persistence.
This is also readily done from Windows using Rufus, which I find easier yet.