You can install an operating system onto a flash drive and use it like a laptop by utilizing tools such as Rufus on Windows or Disk Utility on Mac. No matter which method you choose, you will need the operating system installer or an image file, format the USB flash drive, and install the OS onto the drive. Don't forget to enable USB boot in the BIOS on Windows or change the boot disk on Mac!
Steps
Create a Bootable Windows or Linux Drive Using Rufus

Enable USB Boot in BIOS. BIOS (Basic Input/Output System) helps manage hardware in your computer. Press the required key during boot to enter BIOS (typically F2 or Del). Use the arrow keys to navigate to the 'Boot' tab. Move USB to the top of the list with the ↵ Enter key. Select 'Save and Exit,' and the computer will reboot with the new settings.
- Different manufacturers use different types of BIOS in their computers. You should check the manufacturer's specifications to know exactly which key to press to access and modify the BIOS settings.

Choose the Right USB Flash Drive. You'll want a flash drive with at least 16 GB of storage. USB 2.0 will work, but it's recommended to use a faster USB 3.0 for better speed.
- If you plan to store something other than the operating system on the drive, consider using a 32 GB USB. It doesn't cost much more to increase storage (about a $5 difference between 16 GB and 32 GB)!

Download the "disk image" (ISO) of the operating system you wish to install. The website Rufus provides multiple links to OS images you can download, listed at the bottom of the page under 'Non-exhaustive list of ISOs Rufus is known to work with'. The file you need to download is called an ISO.

Download and open Rufus. Rufus is a portable program that doesn't require installation—just download it and open it directly.

Plug the USB flash drive into the computer. It will appear in the list of drives under 'This PC.'

Click on 'Device' and select the USB flash drive from the list.

Click on 'Partition Scheme' and select 'MBR for BIOS or UEFI'. MBR (Master Boot Record) is the older, yet widely used disk structure found in most Windows computers.
- You could also choose GPT (GUID Partition Table), a newer technology, but you may encounter compatibility issues when installing some operating systems.

Click on the dropdown menu 'Filesystem' and choose the appropriate file system. Select 'NTFS' if you're installing Windows, and 'exFAT' if you're installing Linux onto the USB drive for booting purposes.

Check the 'Create Bootable Disk' box to enable it. This option, located under 'Format Options', will allow you to use the ISO to create a bootable USB drive. An ISO (or disk image) is a digital file that contains the contents of a disk— in this case, the operating system you'll be installing.

Select 'ISO image' from the dropdown menu next to the checkbox.

Click the disk icon and choose the disk image you downloaded. The disk icon is located to the right of the 'ISO image' dropdown menu you selected earlier.

Click 'Start'. The progress bar will display the current status. You will be notified once the process is complete.
- Note: This process will format the flash drive. Formatting the USB drive will erase ALL data. If there's anything you need to keep on the USB flash drive, be sure to copy it to your computer first for backup.

Restart your computer to test booting from the drive. Once USB Booting is enabled, your computer will reboot and use the USB drive to boot from the disk image.
- Some BIOS setups have a dedicated menu for selecting the boot drive. This menu may have different access keys when booting from the regular BIOS menu. Check the manufacturer's specifications to see if this could be why you're facing issues booting from the flash drive.
Install macOS/OSX on a portable drive

Purchase a suitable USB flash drive. To install the latest version of macOS/OSX, you'll want a flash drive with at least 16 GB of storage. USB 2.0 is usable, but USB 3.0 is recommended for faster speeds.
- If you plan to store anything else on the drive besides the operating system, consider a 32 GB or larger USB drive. The cost difference is minimal, with only about a $5 difference between a 16 and 32 GB drive!

Download the operating system installer from the App Store. Search for the version of macOS/OSX you want to install and click 'Download'. Once the download completes, the installer will appear in the Applications folder.

Insert the USB flash drive into your computer. The drive will automatically mount and appear on your desktop.

Navigate to 'Applications > Utilities' and open Disk Utility. Disk Utility is used to manage and modify drives. Your flash drive will show up in the list of drives on the left.

Select the flash drive from the list and click 'Partition'. This process divides the drive's storage into separate sections. This button can be found under one of the tabs listed below the menu bar. The tab offers several options for formatting the USB drive and preparing it to be bootable.

Open the Partition Layout menu and choose '1 Partition'. A single partition will maximize the available space for the operating system you're installing.

Open the Format menu and select 'Mac OS Extended (Journaled)'. This is the required format for running the operating system.
- Note: Formatting the USB drive will erase ALL data. If there's anything you need to keep on the flash drive, be sure to back it up on your computer first.

Click 'Options...'. This button is located below the partition table and opens a menu with multiple options for selecting the partition scheme.

Select 'GUID partition table' and click 'OK'. You need to do this in order for the partition to be bootable.
- Other options are used for making the drive bootable on Windows or PowerPC computers, but newer macOS/OSX versions will not run properly on non-Mac hardware.

Click 'Apply' and then click 'Partition' in the prompt that appears. A progress bar will show up to indicate the formatting and partitioning process. This may take a few minutes. Once complete, the progress bar will disappear.

Open the macOS/OSX installer. The installer will appear in the Applications folder.

Click 'Continue' to begin the installation process.

Click “Agree” and then click “Agree” again in the pop-up window. By selecting this option, you acknowledge the copyright information displayed in the installer window.

Click “Show All Disks”. This action allows you to choose the disk where the operating system will be installed.

Select the flash drive from the list of available disks and click “Install”. The installation process will begin, and it may take about 30 minutes or more. You will be prompted to set up the operating system once the installation is completed.
- You may be asked to enter your computer login information after you click install to confirm the action.

Enter the necessary setup information for the operating system. You will be asked to fill out details such as username/password, location, and Wi-Fi information to configure the new operating system installation. Once completed, the system will boot from the portable disk.

Navigate to “Applications > System Settings” and open “Startup Disk”. Ensure that you change the default boot disk to the computer's internal hard drive to avoid any issues after removing the flash drive.

Select your computer's hard drive and click 'Restart'. Your system will boot from the computer's hard drive, and now you can safely remove the flash drive.
Advice
- Using a macOS/OSX external drive on a Windows machine or vice versa might cause severe issues due to compatibility problems. However, installing Portable Linux might allow it to work on both operating systems.