Purchase Linux CDs / DVDs / Flash Drives at OSDisc.com

Welcome to Our Community

While Linux.org has been around for a while, we recently changed management and had to purge most of the content (including users). If you signed up before April 23rd, 2017 please sign up again. Thanks!

  1. More ways to get the info! - we shoot all of our new original content out as well as random messages on Twitter and our newsletter!. Twitter | Newsletter
    Dismiss Notice

Linux Full Install to USB stick

Discussion in 'Installation' started by Jarret B, Nov 27, 2018.

  1. Jarret B

    Jarret B Active Member

    May 22, 2017
    Likes Received:
    There are ways to install to a USB stick from a Live Linux Operating System. A problem can arise that the Boot Loader can be installed in the wrong place. Wrong partitions can be selected and important data lost.

    If you use a USB stick with Persistence you cannot access files on the USB stick from another Operating System. You cannot easily transfer files to and from the USB stick.

    A full install on a USB stick will make a perfect Fix stick. On a device with Persistence the Persistence is usually a compressed file which stores all of the data on the OS which is updated from the original install files. If the Persistence file should become corrupted then all data is lost. A main issue is that a Persistent drive does not allow for a kernel update. The full install will function just like a regular installation on a hard disk. The USB stick will make the OS more portable and, of course, allow for kernel updates.

    The USB stick should preferably be 32 GB or more in size to allow for a large amount of space for installing programs and storing data. The size of the Swap File will vary if you use one. Depending on your preference you can simply not use a Swap File.

    I have two methods for performing the full install to a USB stick. The first is with VirtualBox and the other from Virtual Machine Manager (see the article https://www.linux.org/threads/virtualization-–-libvirt-gui.4497/#post-12528 for more info on setting up the Virtual Machine Manager).

    NOTE: You can have VirtualBox and Virtual Machine Manager on the same system, but they cannot be run at the same time.


    Using VirtualBox to install Linux to a USB stick it can be done from VirtualBox installed on an OS other than Linux. It is best to have a 64-bit system running VirtualBox so you can either install a 32- or 64-bit Linux OS.

    Once VirtualBox is installed and you have downloaded the ISO file for the distro you want to install you can start. Also make sure you have installed the VirtualBox Extension Pack.

    It is easiest to have your USB stick formatted as one partition. The File System can be any type, preferably FAT32. When a USB stick is first bought it is a single partition that is FAT32.

    Open VirtualBox and select the ‘New’ icon to create a new virtual machine. The ‘Create Virtual Machine’ window should open and ask for the ‘Name and Operating System’. Name the machine something to remember what it is and what it is used to make. For example, I am going to use Linux Mint 19 so I will name mine ‘Linux-Mint-19-Live-USB’. The ‘Type’ and ‘Version’ should be filled in, but if they are incorrect then change them as you need. Click on the ‘Next’ button. The next screen gives you the option to specify the amount of memory to use for the virtual machine. The default should be set the minimum of the selected OS on the previous screen. The default memory allocated is usually 1 GB or 1,024 MB. Look closely at the bar showing the memory range. The value at the high end is the total RAM of the system. The left side of the bar has a green line and the right side is a red color. Keep your amount within the green portion of the bar since this is the amount of RAM not being used by the OS on the physical machine. Once you have specified a memory size click on the ‘Next’ button to continue setting up your virtual machine.

    The next screen allows you to set up a hard disk, or a virtual disk, made up of a single data file for your virtual machine. Keep in mind that we want to install the OS on a USB stick and not a virtual hard disk. Click on the option ‘Do not add a virtual hard disk’ and select ‘Create’. A small window should appear to warn you that you are creating a virtual machine without a hard disk. Click ‘Continue’ to proceed.

    Since we are not creating a storage file the virtual machine will take up very little space on your system. The ISO file from which the virtual machine is booting will take up the most space. The virtual machine at this point is only about 12 KB. The virtual machine works just like booting from a Live CD/DVD without requiring you to shutdown your main OS.

    Now the virtual machine is created, but there are still a few settings which need to be modified and added. Right-click on the virtual machine in the left pane of VirtualBox and select ‘Settings...’.

    In the left pane select ‘System’. In the right pane you can modify the memory to allocate for the virtual machine. If your system has multiple processors you can click on the ‘Processor’ tab and change the number of allocated ‘Processor(s)’ to use for the virtual machine.

    Click on ‘Display’ in the left pane and you can change the amount of ‘Video Memory’, which should be changed to 128 MB. Also check the box to ‘Enable 3d Acceleration’.

    In the left pane select ‘Storage’. The Optical drive is shown as ‘Empty’ so select it. On the far right is a CD with a drop down arrow. Choose it and then select ‘Choose Virtual Optical Disk File’. A file selection window will appear. Find the ISO file you downloaded and select it. The option which stated ‘Empty’ before should now show the ISO file you selected.

    The next item in the left pane you want to select is ‘Network’. Adapter 1 should be set to ‘NAT Network’. Enable Adapter 2 and set it to ‘Host Only Adapter’.

    Make sure your USB stick is inserted into your system. Now select ‘USB’ in the left pane. In the right pane make sure the option ‘Enable USB controller’ is checked. Select your appropriate USB Version for your system. On the right side of the window will be two icons. The lower one will let you add a new USB device. Left-click on the icon and select your USB stick. If you have multiple USB sticks inserted make sure you select the correct one.

    If no USB devices are shown after you left-click on the icon you can easily fix the problem. You need to add your user account to the ‘vboxusers’ group then logout and back in. Once you have done this you should be able to add a USB Device to your virtual machine. If the USB Devices are still not shown then you need to re-install the Extension Pack and try again.

    Click ‘OK’ in the bottom corner of the window and you should be ready to go.

    Select the virtual machine in the left pane and select ‘Start’ from the upper icons. If all of your settings are correct then the virtual machine should start. If the virtual machine does not start then you should go back and check all of the settings. If any errors were reported during the starting of the virtual machine use them to determine the problem.

    Once your virtual machine is running you need to click on the icon ‘Install Linux Mint’. Go through the process of installing the OS. Everything is normal as with any other install, but the Storage device may be a little different.

    If an option appears to install third-party software you should not check it. You want the system on the USB stick to be as basic as possible for drivers.

    When partitioning the USB flash drive the system will want to set up a swap partition. The size of the swap partition will be dependent on the amount of memory you specified when creating the Virtualbox Machine. You can change the default value if you wish.

    By default most Linux distros will use the Logical Volume Manager to make the storage device an LVM partition. It is best to make ‘Standard Partitions’ on the USB stick.

    If you have the option available you can select ‘I will configure partitioning’.

    A Boot partition of 1024 MB would be acceptable. Use the rest of the USB stick for the Root partition unless you want to reserve space for a Swap Partition.

    After all of the partitioning is done you can install the OS. Complete the process by answering a few more questions. When completed you can remove the USB stick and boot other systems with it. Be sure if the OS you installed is a 64-bit OS that you only try to boot it on 64-bit systems. A 32-bit OS should boot fine on any PC as long as the system and processor is compatible with the one you installed it from.

    You may find some problems arise when creating the stick on a desktop PC and booting it from a laptop.

    Virtual Machine Manager

    In this example I am installing a 32-bit version of Fedora 29. Download the ISO file and place it somewhere easily accessible. Also insert your USB stick into a USB port and make sure there isn’t anything on it that you do not want erased. The stick will be formatted later.

    Open Virtual Machine Manager then click on File and select ‘New Virtual Machine Manager’.
    The option for ‘Local install media’ should already be selected so click on the ‘Forward’ button.

    Under the option for ‘Use an ISO image:’ click on ‘Browse’ and find your ISO file. Click on the ‘Forward’ button to continue.

    For the options of RAM and CPUs these are completely up to you and your system. Be aware that the amount of RAM you specify will determine the amount of a swap file is created. The settings can be overwritten when the swap file is made. Click ‘Forward’ when done.

    The next option is very important. You have the option here to use hard drive space. Uncheck the option ‘Enable storage for this virtual machine’ then click ‘Forward’. If a message appears to warn about not having storage space just continue on.

    Give the Virtual Machine a name such as ‘Fedora29-i386-Live-USB’. Be sure to check the box for ‘Customize configuration before install’. Click ‘Finish’.

    Now the Virtual Machine settings should appear. In the left pane select ‘CPUs’. In the right pane click on the box for ‘Copy host CPU configuration’. Click ‘Apply’.

    At the bottom left side click on ‘Add Hardware’. In the left pane select ‘USB Host Device’. In the right pane you need to select the USB stick you have inserted into the system. If any message appears just click ‘Yes’.

    Click on ‘Begin Installation’ in the top left corner and the Virtual Machine should start.

    When Fedora 29 Live starts choose ‘Start Fedora’.

    I will not go through this installation process, but I will go to detail on partitioning the USB stick or ‘Disk’.

    When you get to ‘manage the installation media’ make sure the USB stick is checked and select the option for ‘Custom’ or ‘I will configure the partitioning’. Click on ‘Done’.

    If there are partitions on the stick already then click on the drop down arrow to display them. Delete all of the partitions. Change ‘LVM’ to ‘Standard Partition’ and click on ‘Click here to create the automatically’. Make changes to each partition and select ‘Update Settings’ when done. Label each partition accordingly in case you need to troubleshoot booting issues at the end of the article. Click on ‘Done’ when you are finished. ‘Accept the Changes’ when prompted.

    Complete the installation as required by the distro.

    When done close the Virtual Machine and use the USB stick to boot a system. Preferably it may be best to use the system you created it on and once booted perform an update.

    Problems with booting a USB stick

    Some distros may install better from VirtualBox or Virtual Machine Manager or vice versa. In most cases I had better luck with Virtual Machine Manager.

    The only distros I have had difficulty in using were CentOS and Kali. The problem with them was not the distro but GRUB. In both cases GRUB was set to boot by using the device address of SDA1. If the system you are using the USB stick already has and internal drive then the SDA1 mapping will not work. The USB stick will attempt to boot from the primary hard disk.

    To fix the issue let’s look at the /grub/grub.cfg file on the Boot partition.

    If you did not make a Boot partition, but made one large partition, then the file is in /boot/grub/grub.cfg.

    Find the entries for ‘menuentry’ and ‘submenu’ as shown in Figure 1.

    FIGURE 1

    There are two areas marked in the picture. In the file there should also be a third. These three items we will change. The hard coded entries must be changed to the disks UUID.

    To find the UUID of the entries we need to open the file /etc/fstab on the USB stick Root partition. Figure 2 shows an example of a file.

    FIGURE 2

    The first underlined information is for the Root partition. The second underlined section is for the Boot partition. Make a note of the Boot UUID (b8aaa102-daf2-41e3-99d5-1b76635266d8) because this will be used in the GRUB.CFG file.

    (Log in to hide this advertisement)

    Back in the GRUB.CFG file we will look at the three lines that were marked in Figure 1. The part of the line ‘root=/dev/sda2’ will be changed to ‘root=UUID=b8aaa102-daf2-41e3-99d5-1b76635266d8’. Any lines which use ‘/dev/sda1’ should be replaced with the UUID of the Root partition. Use the UUID from your FSTAB file to replace the UUID number I used for mine. Be sure to change all three lines. See Figure 3 for the changed lines. Watch closely that you get the correct UUID for SDA1 and SDA2 correctly.

    NOTE: You will need ROOT privileges to edit the GRUB.CFG file.

    FIGURE 3

    Save the GRUB.CFG file and and close your editor. You should now be able to boot from the USB stick and load you OS. One of the first things you need to do is to perform a system update after it is loaded. Be sure to update the kernel if you want. Install all required applications, but watch the free space left on the USB stick.

    This process will help you make Linux more portable. If your system supports USB 3.0 then you will want to buy a USB 3.0 USB stick with high data bandwidth. The faster the USB port and stick the better performance you will get from the Linux install.

    NOTE: On my Kali 64-bit install to the USB stick I have 19 GB free. I used 1 GB for the Boot partition and 28 GB for the Root partition. The Kali install used 8.5 GB of space. If you plan on installing a lot of applications you may want a USB stick larger than 32 GB.
    Jaimie and CptCharis like this.
  2. Rick

    Rick New Member

    Dec 23, 2017
    Likes Received:
    Re: Jarret B

    In your article, you made mention of "virtual box" and "virtual machine". Duly noted, however, are these methods the only way of running a Linux O.S. from a pendrive? I'm experiencing major lags/buffering and to a lesser degree, freezes when trying to operate LM 19.1 via "full install" from a pendrive. You also mentioned you employ (at least) a 32Gb pendrive. I must ask if that's really necessary? I'm trying to operate LM 19.1 from a 16Gb (2.0) PNY pendrive. As far as "persistence" I believe I should have all the necessary persistence "room" on the drive for I eliminate quite a few programs I don't run from the O.S. and tend to limit installing programs. Anyways...I've noticed I've had "problems" every since I've abandoned LM 17.3, which, for me, ran beautifully from a 4Gb pendrive. Yea, got the bright idea I should upgrade. So, could there be some inherent "flaw" in trying to run either 18 series or the 19 series via a pendrive? (either live or installed) And one last thing concerning 19.1...cannot get time/date program to work properly plus, time/date does not "show up" in task bar. Just wondering if you'd had any thoughts on what I've said.

    Keep Pushin'
  3. Jarret B

    Jarret B Active Member

    May 22, 2017
    Likes Received:
    Sorry to take so long to get back to you,
    If you used the method of the Full Install then there is no 'persistence'. Persistence is a compressed file which is used to store any changes made to the OS. A Full Install has no persistence file, but the whole USB stick is used exactly like a hard disk.
    If you are having lag issues then my first response is to make sure you have a USB stick that is USB 2.0 or higher so it is faster, Another issue is that Linux Mint is more memory and CPU intensive. I have had better luck with Fedora, kali and Lubuntu. Another issue can be the system you are running it on should be more than able to run the OS you have chosen. I have a system with an Atom Processor and 2 GB of RAM which can run Kali and Fedora fairly well. My other system is a dual Xeon quad core with 32 GB of RAM. On it I can run about anything with a USB 2.0 Stick or above.
    Yes, the USB Stick method can be a little laggy, but once a system or program is started it should be ok. The USB sticks are slower than hard disks.
    The full install is a great method for portability and making a Fix It Stick.
    As far as storage size of the USB stick, I only suggest a larger one to allow for the ability to install more apps as well as use it to back up some data from a system if needed.
    I hope this helps with your questions.
    wizardfromoz likes this.
  4. cat /dev/urandom

    cat /dev/urandom New Member

    Aug 5, 2017
    Likes Received:
    I had a usb pendrive fail on me after I did this (I was using Mint, if that makes a difference). Make sure to use a drive that you know is reliable and made by a reputable brand!

Share This Page