Full Install to USB Drive: Four Options

Write tutorials here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Please don't add support questions to tutorials,start your own thread in the appropriate sub-forum instead. Before you post please read this
User avatar
pbear
Level 10
Level 10
Posts: 3297
Joined: Wed Jun 21, 2017 12:25 pm
Location: San Francisco

Full Install to USB Drive: Four Options

Post by pbear »

I’m a big fan of full install to USB drive. IMHO, it’s the best way for a Windows user to try Mint. Simpler than dual install and has none of the unwind issues. It’s also useful for test boxes and a backup system, which is mainly how I use it. This question comes up often, but there’s no single tutorial, thread or article of which I’m aware which covers the subject, though there are many covering various aspects. What I’ve done in this tutorial is collect insights learned from many sources. None of this is original to me, nor should any of these be described as my methods.

No one strategy is appropriate for everyone. A crucial issue is whether the host machine (the one from which the installation will be done) uses UEFI or BIOS (legacy boot, CRM, etc.). This is crucial because there’s a bug in the Ubuntu installer, also used by Mint, which in UEFI will bollix the internal hard drive’s bootloader even if one specifies the new bootloader should be installed only to the USB drive. Installation in BIOS mode (below) doesn’t have this problem. In all, I know of six ways around the UEFI installer bug. One is to use BIOS mode on a session basis, i.e., the current boot only, for which a BIOS installed USB drive will be fine. Second is to remove the internal hard drive while installing to USB, but that’s not feasible for most folks with laptops. Third is to install as usual, ignoring the bug, then fix the internal bootloader afterwards. I’d rather do a root canal. Described below are the other solutions, which I call Hybrid Install, Unflag/Reflag and rEFInd Method. Of the three, Unflag/Reflag is the simplest and most like a standard UEFI installation. If you're not certain whether your system uses BIOS or UEFI, run one of the tests described in Tips & Options (below).

A second issue is which sort of USB drive to use. I strongly recommend a USB hard drive (SSD or HDD). It will last much longer than a flash drive, give better performance and, of course, have much more space. Besides, they’re cheap now. A flash drive is okay for a test system, but understand it’s going to burn out relatively quickly as they’re not engineered for this sort of thing. How quickly varies, but most reports on the Forum seem to run several months to a year. Also, don’t use a 2.0 flash drive; they’re simply too slow, though curiously a 3.0 drive on a 2.0 port does okay. As for size, I recommend 64 GB; has plenty of room for the system, additional apps and Timeshift snapshots (the system restore utility). You can get by with 32 GB, but don't try to install many apps and monitor space used by Timeshift. Even 16 GB will work if you forego Timeshift, but I don't recommend it.

A third issue is objective. This relates especially to partitioning. As with a standard installation, beginners generally should start with a simple scheme, just a root partition. See ELTP. (In earlier versions, a swap partition also was required, but LM19 by default uses a swap file instead.) With a flash drive, plan to keep data files on the internal drive (which, no doubt, is where they are now). Intermediate and advanced users might want to have a separate home partition, or even separate swap, data and/or Timeshift partitions. IMHO, though, none of those make sense for a flash drive. Yet another option (with a hard drive) is a multi-boot system with several versions of Mint/Linux, all sharing a single data partition.

Bear in mind this looks complicated because there are so many options. Once you pick a strategy, the actual work is scarcely any more than a standard installation. I’m going to assume you’ve already downloaded, verified and burned your ISO to USB or DVD. Note the target USB for full install has to be separate from the one used for the ISO. Also, I assume you have read the Installation Guide. The installer includes a module for setting up and/or modifying partitions, but I always do this before installation using GParted (included in the live ISO).

Note: Per Forum rules, if you have a question or need assistance, don’t post here. Read how to get help, then open a thread in the Installation Forum. Link to this tutorial (so folks will know what you’re trying to do), include an inxi output for your system, and state whether it’s BIOS or UEFI.
Last edited by pbear on Fri Apr 12, 2019 11:54 am, edited 7 times in total.
Time flies like an arrow. Fruit flies like a banana.
If your problem has been solved, please edit the thread title.

User avatar
pbear
Level 10
Level 10
Posts: 3297
Joined: Wed Jun 21, 2017 12:25 pm
Location: San Francisco

Re: Full Install to USB Drive: Four Options

Post by pbear »

BIOS Install

This is the easy procedure, suitable for BIOS computers (generally, those originally sold as Win7 or earlier). Also can be used on more recent computers set up to run in BIOS mode, also known as legacy boot or CRM, or more recent computers which can be set to run in BIOS mode on the fly, i.e., for the current boot only.

Boot live ISO. Turn off screensaver, screen lock and display shutoff. Set up internet connection. If desired, open Firefox, navigate to the Forum and open this tutorial for reference. Attach USB drive to which will be installing.

Simple Installation. This is the default method, what you would get, for example, if you had the installer set up a dual boot system. As mentioned above, it’s the best choice for beginners and (imho) the only sensible choice for a flash drive. Double-click installer icon on desktop. Select language and keyboard; choose whether to install third party software. At screen where choose installation method, select “Erase disk and install.” Notice there’s nowhere to say which disk. It’s okay. Click “Install now” and you get that option on the next screen.* Get this right, obviously. From the dropdown menu, select target USB. If booting the live session from USB, that generally will be sdb and the target USB will be sdc; if booting from DVD, the target USB generally will be sdb. Click “Install Now” again and off we go. Installer will set up a single root partition and install the bootloader to the MBR of the target drive. (For LM18, also will create a swap partition.) When done, click “Continue,” then shutdown and remove the live USB/DVD.

* If you get instead a screen asking you to confirm formatting of sda, STOP! This means you either forgot to attach the USB drive or it’s formatted in such a way that the system doesn’t recognize it. Whatever the problem, fix before proceeding. Plainly, you don’t want to format the internal hard drive.

Advanced Installation. Use this for a more complex setup, e.g., multi-boot or separate root and home partitions. Before initiating install, set up partitions with GParted. Will open with a box displaying partitions of sda, the internal hard drive. USB drives are accessed with a dropdown in the upper-right. From the Menu, select Device: Create Partition Table. For a simple scheme (four partitions or less), msdos type (also known as MBR) is fine. For more complex schemes, rather than muck around with an extended partition, you’re generally better off using gpt (backwards compatible with BIOS), which allows up to 128 primary partitions. For the “how to” on that, see tutorial by austin.texas. Once have set up partitions, close GParted. Double-click "Install" icon on desktop. Initiate install to target USB drive using “Something Else” option. (Let installer unmount partitions when asked.) Select partition planning to use for root, e.g., sdc1 (assuming target is sdc); click Change; Use as: Ext4 system (but don’t tick format box) and select mount point as root (“/”) (annoyingly, you can’t see the mount point option until you’ve selected “use as”). Select and define mount point for other partitions, e.g., sdc2 for /home if that's what you set up in GParted. In lower section of the box, select sdc for grub (important: select the drive, not one of the partitions). Double-check not making any changes to the internal hard drive. Run install (confirm no format, which we did in GParted), selecting other options as preferred (see Installation Guide). Shut down live session and remove the live USB.

For LM18, you need a swap partition; generally should be equal in size to RAM; format linux-swap. LM19 by default uses a swap file, so no need for a partition, but make sure root is large enough to accommodate. I use 30 GB plus swap. The installer swap file is less than 2 GB, so 32 GB for root will be plenty. If planning to enable hibernation, which you do post-installation (see gm10's tutorial), make root = 30 GB + RAM. Note this doesn't come up for simple install, even if planning to set up hibernation, because it’s all one large partition.

Post-Installation. Boot the newly installed system. As with any operating system, there are a bunch of options and settings. Main thing to know straight away is that the screensaver by default locks the system after five minutes (requires password to unlock). You can remove the lock or extend the timeout with the Screensaver configuration app. Also, if you’re booting on a Windows machine, set Mint to use the system clock rather than UTC; otherwise, every time you boot the USB it will reset the system clock, which then has to be set back with Control Panel (well, it’ll sync itself eventually, but annoying in the meantime). Easy to do. Open Terminal and run timedatectl set-local-rtc 1. Done.
Last edited by pbear on Fri Apr 12, 2019 12:30 pm, edited 5 times in total.
Time flies like an arrow. Fruit flies like a banana.
If your problem has been solved, please edit the thread title.

User avatar
pbear
Level 10
Level 10
Posts: 3297
Joined: Wed Jun 21, 2017 12:25 pm
Location: San Francisco

Re: Full Install to USB Drive: Four Options

Post by pbear »

UEFI - Hybrid Install

This method is pretty cool, as it produces a USB drive which will boot in either BIOS or UEFI. It's the method I generally use because I have two laptops, one of each. Indeed, I’ve done it more times than I can count. Definitely works (so long as the computers involved don’t require special drivers). Credit to someone called msavini, who posted this to the Ubuntu Forum, where it was ignored and sank into obscurity.

Overview. It’s a two stage process. First, boot the live session in BIOS mode and install to the USB drive, then reboot and manually install a UEFI bootloader. It’s essential to use BIOS or legacy mode for the installation and first post-installation boot. After that, the USB will boot in either mode. Easiest with a BIOS machine. Otherwise, either use on-the-fly BIOS mode or switch over the whole system then switch back when finished.

Note: The simple “erase and install” method can’t be used here because Hybrid Install uses a special partition scheme. Instead, we must use the Something Else method. I still recommend a root-only system, though, for beginners and flash drives.

Boot live ISO. Turn off screensaver, screen lock and display shutoff. Set up internet connection. If desired, open Firefox, navigate to the Forum and open this tutorial for reference. Attach USB drive to which will be installing.

Partitioning. Open GParted. Will open with a box displaying partitions of sda, the internal hard drive. USB drives are accessed with a dropdown in the upper-right. Generally, if booting from USB, it will be sdb and the target USB will be sdc; if booting from DVD, the target USB generally will be sdb. From the Menu, select Device: Create Partition Table: gpt type (the UEFI format); Apply (note warning). From Menu, select Partition: New. Set up three partitions: #1: 2MiB (unformatted, at very bottom of drop down menu); #2: 200MiB (format fat32); #3: [remaining space] (format ext4). Apply. When complete, right-click #1 and set flag as bios-grub.. Close GParted.

This is a simple partition scheme. If desired, additional partitions may be specified for home, data, etc. For LM18, which requires a swap partition, I put that in position #3 (moving root to #4) so I don’t have to worry about moving it later. FYI, partition #1 is called a BIOS boot partition. It’s standard procedure for using a gpt table in BIOS. See austin.texas’s tutorial (same link as above). Clears space at the head of the drive, which in gpt doesn’t have an MBR, so the installer will have somewhere to put the bootloader.

Installation. Double-click "Install" icon on desktop. Initiate install to target USB drive using “Something Else” option. (Let installer unmount partitions when asked.) Select sdc3 (assuming the target is sdc); click Change; Use as: Ext4 system (but don’t tick format box) and select mount point as root (“/”) (which you can’t see until you’ve selected “use as”). If have set up a home partition, assign that mount point also. Select sdc for grub (important: select the drive, not one of the partitions). Double-check not making any changes to the internal hard drive. Run install (confirm no format, which we did in GParted), selecting other options as preferred (see Installation Guide). Shut down live session and remove the live USB.

UEFI Bootloader. Boot the newly installed system, still using BIOS or legacy boot (in fact, it can't boot in UEFI yet). Turn off screensaver and display shutoff. Set up internet connection. Install GParted (included by default in the live version but not the installed one); open; right-click partition #2 (now probably sdb2) and mark with boot and esp flags; close GParted. Open Firefox, navigate to the Forum and open this tutorial for reference. Open Terminal and run, one line at a time (using copy and paste):

Code: Select all

$ sudo apt-get install grub-efi-amd64-bin
$ sudo mkdir -p /mnt/esp
$ sudo mount /dev/sdb2 /mnt/esp
$ sudo grub-install /dev/sdb --efi-directory=/mnt/esp --boot-directory=/boot --target=x86_64-efi --removable
Installing for x86_64-efi platform.
Installation finished. No error reported.
$ sudo umount /mnt/esp
$ sudo rm -r /mnt/esp 
Note: After entering the first command, you’ll be asked for a password. This is the same as your user password, selected during installation. FYI, the fifth and sixth lines are text Terminal will display if the crucial command (the fourth line) runs correctly.

Troubleshooting. Occasionally, the system will balk at installing grub-efi-amd64-bin (e.g., complaining about unmet dependencies). What has worked for me is to update the package information, so apt update (or sudo apt-get update, if you prefer). Very occasionally, a system won’t boot from a BIOS boot partition. Per rene, one workaround is to set a boot flag on the protective MBR. Run sudo fdisk -t dos /dev/sdb, then p to print (display) the protective MBR, then a to make it active, w to write and q to quit. As regards UEFI boot, be aware the USB only will work if secure boot is disabled. This is because we’re using the generic backup bootloader rather than the registered Ubuntu bootloader. There’s a way around this problem (see below), but it's pretty complicated. Disabling secure boot isn’t a big deal, IMHO, but does require administrative access to the firmware settings.

Post-Installation. Boot the USB drive again, this time in UEFI. As mentioned for BIOS install (above), you may want to remove the system idle lock or extend the timeout with the Screensaver configuration app. Also, if booting on a Windows machine, run timedatectl set-local-rtc 1 so the USB drive won’t reset the system clock.

Note: Grub will reflect the internal bootloader present at the last update, i.e., that of the machine on which it was running at the time. You can update that with sudo update-grub if you change machines, but I generally don’t bother.
Last edited by pbear on Sat Dec 28, 2019 12:12 am, edited 6 times in total.
Time flies like an arrow. Fruit flies like a banana.
If your problem has been solved, please edit the thread title.

User avatar
pbear
Level 10
Level 10
Posts: 3297
Joined: Wed Jun 21, 2017 12:25 pm
Location: San Francisco

Re: Full Install to USB Drive: Four Options

Post by pbear »

UEFI - Unflag/Reflag Method

After nearly two years looking at this issue, I recently found a simple solution for the UEFI bug. It's functionally equivalent to removing the internal hard drive, but done with GParted rather than a screwdriver. Posted to askubuntu in July 2018 by a fellow named Tim Richardson. Be aware the USB drive will boot in UEFI only; if you want to be able to boot in BIOS also, use Hybrid Install.

Overview. After booting the live ISO, use GParted to unflag the internal drive's EFI partition. Install to the USB drive, then restore the internal drive boot flags. Sounds a bit like catching a bullet in your teeth, but I've tested on a Win10 machine and it works. The reason, apparently, is that the installer is simplistic, which is why there's a bug in the first place. With the boot and esp flags removed, the installer doesn't recognize the EFI partition and, so, leaves it alone. Instead, it installs the entire bootloader on the USB drive, which is precisely what you want.

If the installer asks whether to force installation in UEFI, cautioning this may create a conflict, answer “yes.” This means the installer has detected the internal drive’s operating system (doesn’t always) and noticed there’s no (active) EFI partition. You may proceed because (a) the new EFI partition will be placed on the target USB drive and (b) you’re going to restore the internal EFI partition’s boot flags at the end, so there’s no conflict.

Boot live ISO. Turn off screensaver, screen lock and display shutoff. Set up internet connection. Attach USB drive to which will be installing. Open GParted. Find EFI partition on sda (the internal drive); right-click and untick boxes for boot and esp (GParted will automatically assign the msftdata flag instead). Close GParted.

Simple installation. Like BIOS Install, the simple “erase and install” option can be used here. The installer will create an EFI boot partition,* then a root partition for the remaining space. (In LM18, it also will create a swap partition.) Double-click installer icon on desktop. Select language and keyboard; choose whether to install third party software. At screen where choose installation method, select “Erase disk and install.” Notice there’s nowhere to say which disk. Click “Install now” and you’ll get that option on the next screen.** Get this right, obviously. From the dropdown menu, select target USB. If booting the live session from USB, that generally will be sdb and the target USB will be sdc; if booting from DVD, the target USB generally will be sdb. Click “Install Now” again and off we go. When done, click “Continue” (don't shutdown) and proceed to Post-Installation (below).

* To be precise, the installer will create the partition and place in it a folder called EFI, which will have two subfolders, BOOT and ubuntu. The BOOT subfolder has only bootx64.efi, which is the backup bootloader. The ubuntu subfolder has several bootloaders, to wit, fwupx64.efi, grubx64.efi, mmx64.efi and shimx64.efi.

** If you get instead a screen asking you to confirm formatting of sda, STOP!. This means you either forgot to attach the USB drive or it’s formatted in such a way that the system doesn’t recognize it. Whatever the problem, fix before proceeding. Plainly, you don’t want to format the internal hard drive.


Advanced installation. Use this for a more complex setup, e.g., multi-boot or separate root and home partitions. Before initiating install, set up partitions with GParted. Select target USB; from Menu, select Device: Create Partition Table: gpt type (the UEFI format); Apply (note warning). From Menu, select Partition: New. Create the EFI boot partition; 200MB is plenty, as it’s going to be used only for one OS, this one; format fat32; right-click and set boot and esp flags. (If installing LM18, set up a swap partition next; generally should be equal in size to RAM; format linux-swap.) Create remaining partitions as preferred. Close GParted. Double-click "Install" icon on desktop. Initiate install to target USB drive using “Something Else” option. (Let installer unmount partitions when asked.) Select partition planning to use for root, e.g., sdc2 (assuming target is sdc); click Change; Use as: Ext4 system (but don’t tick format box) and select mount point as root (“/”) (which you can’t see until you’ve selected “use as”). Select and define mount point for other partitions, e.g., sdc3 for /home (if that's what you set up). In lower section of the box, select sdc1 for grub (unlike a BIOS install, select the partition, not the device). Double-check not making any changes to the internal hard drive. Run install (confirm no format, which we did in GParted), selecting other options as preferred (see Installation Guide). When installation completes, click dialogue button for Continue (don't shutdown).

Post-Installation. Still in the live session, open GParted again. Right-click EFI partition of sda, then restore boot and esp flags. Now shut down the live session and remove both USB drives. Boot computer to make sure works correctly. Now boot the new USB drive to test that. If booting on a Windows machine, run timedatectl set-local-rtc 1 so the USB drive won’t reset the system clock. In his tutorial (link above), Tim Richardson modifies the EFI menu to distinguish the USB OS from the internal (he's running Ubuntu on both), but this is optional and I don’t. It's a bigger issue with a multi-boot USB, but the same objective is achieved more easily IMHO by editing lsb-release files (see ELTP).
Last edited by pbear on Wed Jan 15, 2020 1:45 am, edited 6 times in total.
Time flies like an arrow. Fruit flies like a banana.
If your problem has been solved, please edit the thread title.

User avatar
pbear
Level 10
Level 10
Posts: 3297
Joined: Wed Jun 21, 2017 12:25 pm
Location: San Francisco

Re: Full Install to USB Drive: Four Options

Post by pbear »

UEFI - rEFInd Method

If Unflag/Reflag makes you nervous, this option is foolproof and scarcely any more work. Only downside is that it uses tools and methods unfamiliar to most Linux users, unless you happen to be using rEFInd on your system already. Credit to fabien85, from whom I learned of the method, and rEFInd developer Rod Smith who had the initial inspiration (though he never developed it fully, as far as I can tell).

Overview. In sum, you boot the live session (can be UEFI or BIOS), install to the USB drive without a bootloader (using a special command) and then manually install a boot manager called rEFInd which doesn’t trigger the bug. Notably, rEFInd is installed only to the USB drive, not the internal, so the Windows system isn’t modified in any way. Be aware the USB drive will boot in UEFI only; if you want to be able to boot in BIOS also, use Hybrid Install.

Note: Like Hybrid Install, the simple “erase and install” method can’t be used here because we’ll be using a special partition scheme. Instead, we must use the Something Else method. I still recommend a root-only system, though, for beginners and flash drives.

Boot live ISO. Turn off screensaver, screen lock and display shutoff. Set up internet connection. Open Firefox, navigate to the Forum and open this tutorial for reference (as you’ll see, at the last stage, there’s a bit of complex code to copy and paste). Attach USB drive to which will be installing.

Partitioning. Open GParted. Will open with a box displaying partitions of sda, the internal hard drive. USB drives are accessed with a dropdown in the upper-right. Generally, if booting from USB, it will be sdb and the target USB will be sdc; if booting from DVD, the target USB generally will be sdb. From Menu, select Device: Create Partition Table: gpt type (the UEFI format); Apply (note warning). From Menu, select Partition: New. Set up two partitions: #1: 200MB (format fat32); #2: [remaining space] (format ext4). Apply. When complete, right-click #1; mark with boot and esp flags. Close GParted.

As mentioned, this is a simple partition scheme. If desired, additional partitions may be specified for home, data, etc. For LM18, which requires a swap partition (generally equal in size to RAM and formatted linux-swap), I put that in position #2 (moving root to #3) so I don’t have to worry about moving it later.

Installation. For this method, don’t use the desktop “Install” icon. Instead, open Terminal and type ubiquity -b. This will bring up the installer, but a version which doesn’t install a bootloader. Initiate install to target USB drive using the “Something Else” option. (Let installer unmount partitions when asked.) Select sdc2 (assuming the target is sdc); click Change; Use as: Ext4 system (but don’t tick format box) and select mount point as root (“/”) (which you can’t see until you’ve selected “use as”). If have set up a home partition, assign that mount point also. Unlike a regular install, because of the -b tag, there’s no option to designate a destination for the bootloader. Double-check not making any changes to the internal hard drive. Run install (confirm no format), selecting other options as preferred (see Installation Guide). When install completes, choose continue session.

Install rEFInd. In Firefox, open rEFInd download page and download “binary zip file” (currently, version 0.11.4); close Firefox. Open File Manager, navigate to Download folder and extract (unzip) package; close File Manager. Return to Terminal. Navigate to folder with unzipped files, e.g., cd Downloads/refind-bin-0.11.4/. Install rEFInd to the target USB drive with the following command (use copy and paste): ./refind-install --alldrivers --usedefault /dev/sdc1 (assuming, as mentioned, that sdc is the target); notice the period before /refind-install, without which the command won’t work; also, there’s a space between --usedefault and /dev/sdc1. Shutdown live session and remove live USB.

Post-Installation. Boot the newly installed system. You should get a rEFInd boot menu listing all installed operating systems on the USB drive and the internal drive (including Windows, if you have it). Toggle with arrow keys to select, then Enter to boot. rEFInd will hand you off to Mint (or Windows) and disappear. As mentioned for BIOS install (above), you may want to remove the system idle lock or extend the timeout with the Screensaver configuration app. Also, if booting on a Windows machine, run timedatectl set-local-rtc 1 so the USB drive won’t reset the system clock.

Note: To access backup kernels (installed but not active), press F2, Insert or Tab; use up and down arrow keys to select, then Enter to boot. If you’re familiar with advanced boot options in Grub, this is how you do the same thing in rEFInd.
Last edited by pbear on Sat Sep 28, 2019 11:27 pm, edited 4 times in total.
Time flies like an arrow. Fruit flies like a banana.
If your problem has been solved, please edit the thread title.

User avatar
pbear
Level 10
Level 10
Posts: 3297
Joined: Wed Jun 21, 2017 12:25 pm
Location: San Francisco

Re: Full Install to USB Drive: Four Options

Post by pbear »

Tips & Options

BIOS vs. UEFI? For purposes of the installer bug, what matters is the boot mode of the already-installed system. For Windows, a rough rule of thumb is that, if Win7 was the original OS, it will be BIOS mode (technically, an early version of UEFI set to legacy mode). Win8 generally will be UEFI and all Win10 systems (if the original OS, upgrade might be BIOS). To confirm boot mode in Win8 and Win10, press Win+R to open Run. Type msinfo32 into the "Open" field; click OK. A System Information report will appear; BIOS mode is line fourteen. Remember, legacy mode = BIOS mode.

Confirming Win7 is more difficult, as its version of msinfo32 doesn’t report boot mode. Best method is to look at the system disk with GParted in a Mint live session. (Make sure it’s the system disk, not a data disk.) Go to View > Device Information. Partition table: msdos = MBR = BIOS format, whereas gpt is the UEFI format. You can double-confirm UEFI by looking for a smallish partition (200 to 500 MB), usually at the beginning of the drive, formatted fat32 with boot/esp flags. That’s an EFI partition, so definitely UEFI install.

Linux is easier. To confirm boot mode, open Terminal and run ls /sys/firmware (ls = list). If “efi” is listed, you’re booted in UEFI mode; if not you’re booted in BIOS mode. It’s that simple. Alternatively, copy the following command into Terminal. Like magic, it will tell you the boot mode:

Code: Select all

[ -d /sys/firmware/efi ] && echo "Currently in UEFI mode" || echo "Currently in Legacy mode"
Note: If the main system boots in BIOS mode and the live session in UEFI, this means your firmware has a version of CSM which can boot either way, usually with preference to UEFI if the boot device supports it. Cross booting this way is a big problem for conventional dual boot, but not for installation to USB drive. The USB drive can have a different boot mode because it’s separate, with boot order specified by the firmware. So, you can force BIOS boot and install that way. Or you can stay with UEFI boot and install per the Unflag/Reflag method, leaving out the unflag/reflag part because there’s no EFI partition to protect. You’ll end up with a USB drive which boots in UEFI only.

BIOS/UEFI settings. These are discussed in the Installation Guide (linked above), but I will mention for emphasis. On both, it’s almost always necessary to modify boot order so the USB port is used before the internal drive. On UEFI systems, you generally can run the installer without disabling secure boot, but I've had trouble letting the installer temporarily disable secure boot to install third party software. It's just as easy and safer to disable secure boot in the firmware settings, then re-enable after installation if desired. If you want Mint to be able to access data files on the internal drive, also disable Fast Startup, a Power Option setting in Control Panel. By the way, it's not essential, but if you'd like to know more about UEFI, How-To Geek has a nice introduction. For a deeper look, see Rod Smith and Happy Assassin.

Take notes. Before starting the actual installation, I recommend highly that you create a word processing or notepad document for taking notes. Keep track of everything you do: every step, every setting you modify, every app you install and every app setting you modify. This document eventually will evolve into an installation script (in the non-technical sense), which everyone should have for whatever operating system they run. Into every life, a certain amount of reinstalling will fall. Don’t be afraid of reinstalls. Be prepared.

Persistence distinguished. To be clear, the procedures described above create a full install system which works the same as one installed the regular way to an internal hard drive. Persistence is something else, useful in some cases but not as complete, stable or updatable. It only became a “thing” because USB storage used to be limited in size and expensive. IMHO, persistence is now mostly obsolete. If that’s what you want, I’d recommend Pendrive’s UUI, sudodus’ mkUSB (about) (more), or MultiSystem (about). Laurent85 has a tutorial using only standard Mint tools plus rEFInd, though it’s a bit advanced. Do not use the widely touted LinuxLive USB Creator; was last updated in Sept 2015, last worked with Mint 17.2, and has since been abandoned by its developer (see 2/3’s down page). I’ve also had trouble with YUMI (Pendrive’s multiboot app), UNetBootin and MultiBootUSB, but YMMV.

Encryption. I’m not a fan of system encryption, though I do use container encryption (Veracrypt) for the relatively small subset of data files I want secured. To install, run sudo add-apt-repository ppa:unit193/encryption, then apt update and apt install veracrypt. If preferred, home folder encryption is easily done - it’s an option on the same screen as where select user name and password - but entails a performance penalty. LUKS (full disk) encryption is faster, but only supported in the installer when using the simple “erase and install” method (select both "Erase" and "Encrypt," which also selects "LVM"). I’ve tested this for BIOS Install and Unflag/Reflag, and it worked for both. From various threads on the Forum, e.g., here, here, here and here, I believe LUKS can be done manually for the other options, but I’ve not seen a tutorial directly on point.

VirtualBox. If you want to be absolutely certain the install to USB drive can’t modify your main system, installing from VirtualBox will give you that. (Credit to Valsodar for reminding me of this option; see askubuntu.) Also, saves the effort of burning the source ISO to USB or DVD, as VBox will mount it directly to a virtual CD drive. This strategy is only worth the trouble, though, if you already have VBox installed and running, as the learning curve is substantial. Moreover, installation will take longer, which isn’t surprising as VBox tends to be slower than “bare metal” systems. Can run the installation from an existing VM (take a snapshot), but easier and safer to make a new one; allocate as much memory as feasible; don’t bother with a virtual hard drive (won’t be using anyway); insert source ISO to virtual CD drive; attach target USB to host computer. By default, VBox VMs boot in BIOS mode; if want to install in UEFI mode, select “Enable EFI” from Settings: System. Start VM, which will bring up a live session; turn off screensaver and display shutoff. From the VBox menu, select Devices: USB, then click target USB, which will be mounted to the VM (as sda if the VM doesn't have a virtual hard drive). Double-click installer icon and off you go. Can use the simple “erase and install” method (with or without LUKS) or Something Else. If using an existing VM, it generally will have been installed in BIOS mode, so there will be no EFI partition to unflag when installing to USB drive, even though you have temporarily changed the boot mode. When install completes, shut down live session. If created a bare VM as suggested, can be deleted now or retained for future use; if used an existing VM, roll back with snapshot. Boot USB to test, then do post-installation tweaks mentioned above.

Multi-Boot System. As mentioned, one good use for a USB hard drive is a test box with multiple versions of Mint and/or other Linux systems. Easy to do now, with external hard drives so inexpensive. Be advised that managing multiple Grubs is a bit tricky. What I find works best is to pick one OS as primary and plan not to change it. That becomes the primary Grub. Then, when installing other OSs, put their bootloaders on the corresponding OS partition. So, if installing Ubuntu 18.04 to sdc7, specify that destination for the bootloader also. Understand, you won't be able to boot the secondary OS until you update the primary Grub. As the secondary Grubs aren't used, you might as well disable os-prober for their updates, so they will run faster; edit /etc/default/grub to add GRUB_DISABLE_OS_PROBER=true. See Ubuntu Help, Item 16. Of course, don't do this for the primary Grub. Note: If have occasion to use Timeshift on one of the secondary OSs, untick reinstall of Grub or that OS will become primary. I’ve never tested multi-boot with the rEFInd Method, so don’t know whether it’s able to manage secondary systems without installing any bootloaders, but assume the answer is yes.

Data Partition. I’m not going to try cover this here, but it’s a good idea for multi-boot systems and preferred by some for single install. There are many threads on the topic. I found most useful this tutorial by gold_finger. FWIW, I like to put the Data partition early in the partition scheme, before the operating systems, so I don’t have to worry about moving it later, but that’s merely personal preference.

Backups. Bear in mind, external hard drives fail the same as internal ones. And, as mentioned, full install will burn out a flash drive relatively quickly. The USB drive never should have the only copy of anything you care about. No drive should.
Last edited by pbear on Tue Jan 14, 2020 5:00 pm, edited 6 times in total.
Time flies like an arrow. Fruit flies like a banana.
If your problem has been solved, please edit the thread title.

User avatar
elvino1
Level 1
Level 1
Posts: 9
Joined: Thu Aug 04, 2016 9:25 pm
Location: Taveuni, Fiji

Re: Full Install to USB Drive: Four Options

Post by elvino1 »

Thi is a superb tutorial, answering questions I have been struggling with since UEFI reared its head. Many many thanks pbear
Mint19, full install 128gb flashdrive

User avatar
pbear
Level 10
Level 10
Posts: 3297
Joined: Wed Jun 21, 2017 12:25 pm
Location: San Francisco

Re: Full Install to USB Drive: Four Options

Post by pbear »

You're welcome and thanks for the kind words. Remember, if you have a question, please open a thread in the Forums rather than post here. Good luck.
Time flies like an arrow. Fruit flies like a banana.
If your problem has been solved, please edit the thread title.

wd0d
Level 1
Level 1
Posts: 3
Joined: Sat Apr 27, 2019 2:22 pm

Re: Full Install to USB Drive: Four Options

Post by wd0d »

Great tutorial.

I had previously tried the first three methods, and was just as successful as I would have been performing self-administered root canals, but found the fourth method worked extremely well. I would add some minor clarification for the dinosaurs like me who might try this.

After downloading the rEFInd zip file, I went to the downloads folder and choose to extract it into that folder. What I should have done next was then click on the extracted folder and chosen to open it in a terminal window. Then used the "./refind-install --alldrivers --usedefault /dev/sdc1" to install the divers. What I did was something else, which resulted in me getting a rEFInd bootloader on my laptop main hhd. This is not a real problem but it does clutter things up. I eventually got it right and I'm good to go.

By the way, is it normal to get a lot of script after choosing to boot Mint and then again on shutting down the system?

Thanks again for a great solution to a perplexing problem.

Bob

User avatar
pbear
Level 10
Level 10
Posts: 3297
Joined: Wed Jun 21, 2017 12:25 pm
Location: San Francisco

Re: Full Install to USB Drive: Four Options

Post by pbear »

Sorry about difficulties with the first three options. I realize this would be easier with screenshots, but would take about a hundred of them to cover all options. That's not only infeasible, ultimately it would be even more confusing (I think). Regarding the rEFInd hiccup, in my defense, you skipped a step, "Navigate to folder with unzipped files, e.g., cd Downloads/refind-bin-0.11.2/." Anyhoo, glad you got it working in the end.

Lots of stuff flying by on screen would be normal for LMDE3, but not for any of the regular versions. If it bugs you, please open a thread on the Forums.
Time flies like an arrow. Fruit flies like a banana.
If your problem has been solved, please edit the thread title.

User avatar
farkas
Level 4
Level 4
Posts: 363
Joined: Mon Sep 21, 2015 6:10 pm
Location: Oregon

Re: Full Install to USB Drive: Four Options

Post by farkas »

Great tutorial pbear! Your responses helped me out several times. Thank you.

I'm wondering if its possible to install LM on an external HDD and plug it into any other PC other than the one which the install was performed on.
Portable external USB 3.0 HDD prices are reasonable, $30 USD to $50 USD for 250 GB to 500 GB HDD.

Because Win7 support is expiring early next year some friends were asking about Linux. I'm thinking about giving a them a Christmas present (maybe an early one) of a Mint installed on an external HDD ready plug in and go. Which option?
I understand that I'd have have to explain how to boot from USB.
Does widows prevent it? I don't know, haven't used it since it ended XP support.
They could check it out without interfering with their current OS. Running Mint on a live DVD or USB ISO not quite the the same as a fully functional install.
If they don't like it they can reformat it and use it for something else. Hopefully that won't happen.
If your query has been resolved, edit your first post and add [SOLVED] to the subject line.
If you found a solution on your own please post it.
A generation which ignores history has no past and no future.

User avatar
pbear
Level 10
Level 10
Posts: 3297
Joined: Wed Jun 21, 2017 12:25 pm
Location: San Francisco

Re: Full Install to USB Drive: Four Options

Post by pbear »

Cool idea. My experience has been that a full install USB drive works fine on other machines, i.e., isn't tethered to the one used to create it. This is subject to the important caveat that neither machine needs a special graphics driver or other customization. Fortunately, Win7 vintage hardware seems to be well supported by the Linux kernel, but it's an issue you should keep in view.

As for which option, if I were doing this, I'd keep it simple. So, I'd use the BIOS method and give them a USB drive which boots only on their current computer. Or you could go clever and use Hybrid Install. Both will boot easily without the newbie understanding what's happening. OTOH, their partitions won't look like what they'll see in tutorials and blogs. OTTH, if you're going to be available to explain things, maybe that's not a big deal. Also, you want to do Hybrid Install if they're going to need to get a Win10 machine anyway (e.g., for work reasons).

As for Windows, it doesn't care tuppence about a full install USB. Doesn't even recognize it as a competing OS. On a Win7 machine, all you have to worry about is the BIOS boot setting. UEFI (Win8 or 10) is a little more complex. Secure boot should be okay, but sometimes needs to be disabled. Most sources say to disable Fast Boot, which is a UEFI setting that bypasses certain diagnostic tests. And they definitely want to disable Fast Restart, a Control Panel setting under Power Options, as that hibernates the internal hard drive, making it inaccessible to Mint. Again, none of these are an issue for Win7.

A few tips. Be sure to supply also a DVD or USB from which they can boot a live session. Needed for various system repair tasks. Go ahead and set up Timeshift for them. In particular, if you're giving them separate root and home partitions, set up Timeshift to save snapshots in the home partition. If it were me, I'd set up one of the data file backup apps (whichever you use, so they can get help). The absence of a good data file backup utility (the current one is pathetic) is the biggest hole in Ubuntu/Mint, IMHO. Last but not least, explain about the no-antivirus thing.

Hope it works out. Good luck.
Time flies like an arrow. Fruit flies like a banana.
If your problem has been solved, please edit the thread title.

crlMIDI
Level 1
Level 1
Posts: 6
Joined: Mon May 09, 2016 12:34 pm

Re: Full Install to USB Drive: Four Options

Post by crlMIDI »

I just tried the 'UEFI - Hybrid Install' option on a HP Elitebook 8740w, which has one of those transitional versions of UEFI. My disk (Mint Cinnamon 19.1, 32 bit, on an ancient hard disk with a USB adapter) booted OK, but the 'Install Linux' icon was missing. Based on information on the web, I installed ubiquity on the USB disk, but it crashed (a known problem in that situation).

Usually, I use balenaEtcher or Unetbootin to make bootable USB drives, because they they have always worked until today. For a change, I tried Rufus 3.5.1497. This has an tickbox to 'add compatibility options for old BIOS' (translation: Rufus speaks French on my computer). With the box duly ticked, the USB disk booted on the old HP and the installation proceeded as normal.

User avatar
pbear
Level 10
Level 10
Posts: 3297
Joined: Wed Jun 21, 2017 12:25 pm
Location: San Francisco

Re: Full Install to USB Drive: Four Options

Post by pbear »

FYI, I'm taking a break from the Forum, so I won't be in a position to answer questions or respond to comments. On the other hand, everything here uses standard Linux tools, so other users should be able to assist if needed. (Bear in mind, I didn't invent any of this.) As mentioned in the OP, help requests should be made in the Installation Forum, not here. Before posting, read how to get help. Include a link to this tutorial so folks will know what you’re trying to do, provide an inxi output for your system with the target USB drive attached, and state whether the system uses BIOS or UEFI.
Time flies like an arrow. Fruit flies like a banana.
If your problem has been solved, please edit the thread title.

nesti
Level 1
Level 1
Posts: 15
Joined: Tue Jul 02, 2019 9:48 am
Location: Luxemburg

Re: Full Install to USB Drive: Four Options

Post by nesti »

pbear wrote:
Thu Mar 21, 2019 1:21 am
I believe LUKS can be done manually for the other options, but I’ve not done it and haven’t seen a tutorial directly on point.
Some time ago i was trying to set up LUKS manually for the installation of Arch Linux. I was making myself a little challenge as I am normally using Linux Mint XFCE.

If anyone is interested, I can send/post a step by step list which I found some time ago and which I changed to my needs.

greetings

nesti

fabien85
Level 7
Level 7
Posts: 1641
Joined: Tue Mar 11, 2014 4:30 pm

Re: Full Install to USB Drive: Four Options

Post by fabien85 »

Hi pbear,
nice tutorial. The Hybrid install is similar to what I showed in viewtopic.php?f=42&t=256750 , although I did it a bit more manually.
pbear wrote:
Tue Feb 05, 2019 3:27 am
UEFI - Hybrid Install
[...]
As regards UEFI boot, be aware the USB only will work if secure boot is disabled. This is because we’re using the generic backup bootloader rather than the registered Ubuntu bootloader. If there’s a way to set up a USB drive to use the registered bootloader, I’ve not seen it.
You could copy the booloader from the live USB : EFI/BOOT/bootx64.efi (=shim, which is signed) and EFI/BOOT/grubx64.efi ; copy them to ESP:EFI/BOOT/ on the new USB, and perhaps also copy EFI/ubuntu/grub.cfg on EFI/BOOT/grub.cfg. I did this some years ago.
I have found that it's quite useful to have your USB compliant with secure boot in some cases. Say you are traveling, get access to a computer without manual, and you do not have 1h to spend trying to find the damn key to get into the BIOS, understanding how to disable secure boot, people wondering what you are doing with the computer... and once you have made your use, go back into the BIOS to re-enable secure boot to leave the machine as before.

User avatar
pbear
Level 10
Level 10
Posts: 3297
Joined: Wed Jun 21, 2017 12:25 pm
Location: San Francisco

Re: Full Install to USB Drive: Four Options

Post by pbear »

fabien85 wrote:
Mon Dec 23, 2019 12:53 pm
The Hybrid install is similar to what I showed in viewtopic.php?f=42&t=256750 , although I did it a bit more manually.
Well, yes. Bear in mind you reference in that tutorial my original post of the Hybrid method.
You could copy the booloader from the live USB : EFI/BOOT/bootx64.efi (=shim, which is signed) and EFI/BOOT/grubx64.efi ; copy them to ESP:EFI/BOOT/ on the new USB, and perhaps also copy EFI/ubuntu/grub.cfg on EFI/BOOT/grub.cfg. I did this some years ago.
Interesting idea. I'll give it a shot at some point. Frankly, not much use to me, but might be to others.

Speaking of ancient history, I finally figured out how to install Grub to a system installed in UEFI with ubiquity -b, using chroot. Egads it was painful, though it does get around the installer bug. Turns out the live session doesn't load the UEFI installer automatically, plus there's a sub-directory missing at target (/usr/lib/grub/x86_64), which I copied in from the live session after manually installing the UEFI package (doesn't exist until then). Frankly, it's so complicated I didn't bother adding to the tutorial, even as an option.

ETA: Alas, didn’t work for me. No matter which order I did the steps, I ended up with error: file ‘/boot/’ not found. Not saying it can’t be done, but not simple. Notably, the live USB boots fine with secure boot enabled, so that’s not the problem. Did not try to copy grub.cfg, by the way, as ISTM the live USB file (under /boot/grub) isn't suitable for a full install USB.

ETA2: Puzzling over this, it occurred to me the opposite strategy might work, i.e., install in UEFI mode and add the BIOS bootloader afterwards. So, set up partitions as for Hybrid Install, but do installation per Unflag/Reflag using the Something Else method (placing bootloader on the EFI partition). This will be a signed bootloader, properly configured with the boot files. After installation, add the BIOS bootloader with grub-install or chroot. Interestingly, I had the /usr/lib/grub problem again (see above), only this time the /i386 folder was missing, so copied in from another bootable USB drive (alternatively, could have added a --target=i386 grub-install parameter). Wouldn’t call this solution easy, but I tested and it does work with secure boot.
Time flies like an arrow. Fruit flies like a banana.
If your problem has been solved, please edit the thread title.

User avatar
pbear
Level 10
Level 10
Posts: 3297
Joined: Wed Jun 21, 2017 12:25 pm
Location: San Francisco

Re: Full Install to USB Drive: Four Options

Post by pbear »

Reverse Hybrid Install

With some hesitation, I'm going to elaborate on the installation method described in the preceding post. My concern is that it's too complicated for most new users and only useful in rare circumstances. (If you want a portable computer, the right answer is to carry one, not to count on being able to boot a USB drive on someone else's.) So, even more than usual in Linux land, this method is presented "as is," with no warranty of any kind.

Overview. It's a two stage process. First, boot the live session in UEFI mode and install to the USB drive using the Unflag/Reflag method. Then, still in the same live session, manually install the BIOS bootloader. For this to work, the partition scheme must be similar to that for regular Hybrid install, i.e., a GPT partition table with both a BIOS boot partition and an EFI partition.

Preparation. For simplicity, disable secure boot before installation,* then re-enable afterwards if you like. Boot live ISO; turn off screensaver, screen lock and display shutoff. Attach target USB drive. Set up internet connection. Open Firefox and navigate to this tutorial for reference.

* Secure boot has to be disabled to install third party software. The installer does that temporarily with something called MokManager. To my great annoyance, when I tried this, it bollixed my UEFI settings, requiring me to reflash the firmware to repair. It’s just as easy, and safer, to use the regular firmware tools to disable secure boot then re-enable after installation. Alternatively, you can avoid the problem altogether by using the VirtualBox method (see Tips & Options).

Partitioning. Open GParted. Will open with a box displaying partitions of sda, the internal hard drive. I’m going to assume the live ISO has been booted from a USB drive, so it’s sdb and the target USB is sdc; adjust designations below if your situation is different. Now, find the EFI partition on sda; right-click and untick boxes for boot and esp (GParted will automatically assign the msftdata flag instead). Next, create a partition table for target (sdc). From Menu, select Device > Create Partition Table > gpt type; Apply. From Menu, select Partition > New. Set up three partitions: #1: 2MiB (unformatted, at very bottom of drop down menu); #2: 200MiB (format fat32); #3: [remaining space] (format ext4); if desired other partitions may be specified, e.g., home and/or data. Apply. When complete, right-click #1 and set flag as bios-grub, then right-click #2 and set flags for boot and esp. Close GParted.

Both here and regular Hybrid Install, I put the BIOS boot partition first because it’s a logical place and tucks it out of the way in case you want to rearrange other partitions later. The BBP doesn’t have to be first, though. So, if you’ve come to these instructions because you already installed with Unflag/Reflag and now want to add BIOS boot, you can do that. Clear 2 MB of room anywhere convenient (usually at the end of the partition table, but doesn’t have to be) and put the BBP there. Skip the next paragraph, as presumably the system already has been installed. When installing the BIOS bootloader, you’ll probably have to modify the mount line for chroot, as it’s unlikely the root partition is sdc3.

Installation. Double-click "Install" icon on desktop. Initiate install to target USB drive using “Something Else” option. (Let installer unmount partitions when asked.) Select partition planning to use for root, i.e., sdc3 (assuming target is sdc); click Change; Use as: Ext4 system (but don’t tick format box) and select mount point as root (“/”) (which you can’t see until you’ve selected “use as”). Select and define mount point for other partitions, e.g., sdc4 for /home (if that's what you set up). In lower section of the box, select sdc2 for Grub. Double-check not making any changes to the internal hard drive. Run install (confirm no format), selecting other options as preferred. When done, click Continue (don’t shutdown).

BIOS Bootloader. First, we need to copy /usr/lib/grub/i386-pc from the live ISO to the target USB. Open File Manager; right-click somewhere blank (i.e., not a file) and select Open as Administrator; from Menu, select View > Extra Pane. In each pane, navigate to /usr/lib/grub, live ISO on the left and target USB on the right; right-click i386-pc in the left pane and select copy to other pane. Close both sessions of File Manager (as administator and as regular user). Second, open Terminal and run the following commands, one line at a time (use copy and paste):

Code: Select all

$ sudo mount /dev/sdc3 /mnt # mount root
$ for i in /dev /dev/pts /proc /sys; do sudo mount -B $i /mnt$i; done
$ sudo chroot /mnt
# grub-install /dev/sdc --target=i386-pc
# update-grub
# exit
$ for i in /sys /proc /dev/pts /dev; do sudo umount /mnt$i; done
$ sudo umount /mnt
These commands use something called chroot, which is far more complicated than I’m going to try to explain here. Either do your own research or take my word for it.

Post-Installation. Still in the live session, open GParted. Right-click EFI partition of sda, then restore boot and esp flags. Shut down live session and remove both USB drives. If desired, re-enable secure boot in the firmware, if disabled earlier. Boot computer to make sure it works correctly. Now boot the new USB drive to test that. If booting on a Windows machine, run timedatectl set-local-rtc 1 so the USB drive won’t reset the system clock.
Last edited by pbear on Sat Feb 15, 2020 1:47 pm, edited 2 times in total.
Time flies like an arrow. Fruit flies like a banana.
If your problem has been solved, please edit the thread title.

Longbottom
Level 1
Level 1
Posts: 25
Joined: Mon Sep 05, 2016 10:26 am

Re: Full Install to USB Drive: Four Options

Post by Longbottom »

Hi, I have a possibly stupid question: If I make a USB install with the BIOS version, what will happen if I put it in a computer with UEFI and windows 10? Will it just not work, or will I damage windows? Asking since I have made a USB for my job computer, and old W7 machine with BIOS. Its works badly, and the IT guys at work have told me they're going to install W10 on it in a week or two. Thing is I don't know if they will update the BIOS to UEFI as well, and they couldn't tell me. I'm not allowed to install Mint on it, but it's OK to run it from a USB or external disk as long as it doesn't damage anything. In worst case I guess I could just redo the USB installation... :roll:

User avatar
pbear
Level 10
Level 10
Posts: 3297
Joined: Wed Jun 21, 2017 12:25 pm
Location: San Francisco

Re: Full Install to USB Drive: Four Options

Post by pbear »

Longbottom wrote:
Thu Jan 16, 2020 3:36 pm
If I make a USB install with the BIOS version, what will happen if I put it in a computer with UEFI and windows 10? Will it just not work, or will I damage windows?
Not a stupid question, but not a problem either. That is, at worst, it won't work. FWIW, I'm pretty sure there's no way to update BIOS to UEFI. What may be true is that you have a UEFI machine running Win7 in compatibility mode, but then I would expect you to have had trouble installing to the USB drive in BIOS mode (in that scenario, it seems the live session generally boots in UEFI mode).

Anyhoo, no sense borrowing trouble. Let them do the upgrade. Win10 can be installed in BIOS mode, by the way. Then see whether your USB drive works. If not, ask IT whether there's a way to boot the USB drive in BIOS mode (usually there is). Or, as you say, you could reinstall. Just beware of the bug!
Time flies like an arrow. Fruit flies like a banana.
If your problem has been solved, please edit the thread title.

Post Reply

Return to “Tutorials”