Make a live USB Key running Ubuntu with large persistent storage for persistent mode

Today we are going to make a live USB key with persistent mode. This is a USB key that contain an operating system that runs just like the one on your computer.

A live USB key is a USB key that can boot from your computer. Not all live USB keys can boot right from the key : some are just used to install an OS on your computer, just like a CD. The mode where you can actually run the OS right from the USB key is called persistent mode.
Usual live USB keys with persistent mode made using Linux distributions usually cannot use more than 4GB of data for persistent mode, whatever the size of your USB key is. This is because of some FAT32 restriction. We are going to bypass these limitations so you can use as much space as you want for your portable live and persistent OS.

Installing the OS

  • Download LinuxLive USB Creator (LiLi for short).
  • Insert your USB Key and launch LiLi USB Creator. Select your USB key. Then, either choose an ISO you downloaded, or use the download button to let LiLi download the latest release of you selected OS. Here, we are going to use Ubuntu 14.04. Allow for some persistent space (the size does not matter, we are going to modify it later). The setup should look like this:Screen Shot 10-03-14 at 03.14 PMNow you are ready to click the lightning icon to start the installation.
  • Go to your USB key. You should have only one folder visibleclean usb keyThe installed files are actually hidden so you do not modify them too much. Go to  View -> Options -> View -> Disable temporarily Hide Protected operating system files. Now you should see the installed files on the key.Screen Shot 10-20-14 at 12.39 AMScreen Shot 10-20-14 at 12.55 AMGo to boot/grub/ and open grub.cfg to modify it. grub.cfg is the file used when the key boot, to show the options you have when running the key. Add the new entry below as the first menuentry:

menuentry "Run persistent mode" {
set gfxpayload=keep
linux      /casper/vmlinuz.efi persistent file=/cdrom/preseed/ubuntu.seed boot=casper quiet splash --initrd     /casper/initrd.lz
}

Save and exit.

Make a secondary partition

Key to allow for more than 4GB persistent storage is to make a secondary partition that will be used to store persistent data. Making multiple partition on USB keys is not common, and most OS do not cope with it. Windows for example will simply ignore secondary partitions. We will thus need EaseUS Partition Manager Software to do so. You can download it freely here.

By default, a file is created on the primary partition for storing all those files. Its name is “casper-rw” and it is located in the root of the key. Delete it.Screen Shot 10-20-14 at 12.56 AM

Let’s create a secondary partition now. Open EaseUS Partition software, select your USB key partition and click Resize-Move partition. Resize to the size you want (free the space on the right, as the second partition must come after the primary one). The primary partition will be used for the basic files of the OS and for usual USB key usage. The space you spare will be used for the persistent files only. It will be invisible to most OS. I personally used a 64GB USB key, kept 30GB for the primary partition and the rest for the persistent mode.

Then, format the free space you just spared. Use EXT3 or EXT4 format, name it casper-rw, and cluster size 4KB. Apply the modifications. The partition must be set to primary partition.

Boot from the USB drive

Now, you should be all set to use your new OS! It is now important to ensure that the computer you will use accept to boot using USB keys. You should look into the bios of your computer to ensure that USB-Storage is one of the possible boot option.

Most recent computers running Windows 8 or newer use secure mode to boot. This mode usually only allow you to boot from Windows, preventing other external system to take control of the computer. This mode can prevent the system from booting into your USB drive, even if you specify USB-Storage as one of your boot options. You will have to disable secure boot in order to boot from the Key. This setting can be found in the boot section of your bios.

If your computer still boots to your usual OS, press F12 repeatedly while the computer boots until you arrive on such screen:2014-10-20 01.35.17

There, select USB Storage Device.

Once this is done, you should be able to boot and have the grub menu showing. Enter the persistent mode.2014-10-20 01.35.49

You should now be able to use your Ubuntu OS and do whatever you want right from your USB key. Enjoy!

Ubuntu_Desktop_12.10

If you encounter any problem during the creation of the USB key or the booting, put a comment below to get some help.

Source

13 Comments

    1. If I understand correctly, your antivirus detected a malware on the installer of Lili (Linux Live USB Creator), is that correct? This is strange, since this is the official LinuxLive USB Creator link to the installer website, and it is a quite famous and reliable software. Can you provide more information (details about the download, Antivirus, OS, etc.) about your problem? Maybe it is a false positive?

      Like

  1. Somehow, I downloaded the latest version of EaseUS Partition, but there was no formatting in EXT4 possible — I chose EXT3 instead (only ext2 and ext3 available). I wonder why? Will it cause any problem? It seemed to be the closest one!

    Like

      1. Err, sadly, my USB key won’t boot proper $(something with initramfs). I am not quite sure what is causing the problem out of the possible variables, but I guess I will try installing the newest Ubuntu instead of an image of trusty tahr and try it out before attempting to make changes this time… ! (?) I basically have no idea what I’m doing. *sigh* But your tutorial is so easy to understand and follow! So it gives me hope. Thank you!

        Like

  2. When modifying the grub.cfg using the entry you posted, the computer crashed… could you elaborate a bit more about the syntax or the way you’re creating those instructions? is that right?
    Thanks! Im trying with Linux Ubuntu 14.04.2 (64 bits)
    Best Regards!

    Like

  3. I got error messages when trying to start Persistance
    and then i also try starting trying ubuntu without install also failed.
    HEre are the ERRORS:


    Also my USB shows the initial space 3G when per your guide first allocation does not matter but my USB was at first 15 G, now it shows as 3G????

    During the Resize and move I allocated the Primary partition 3G and the unallocated as you specified as ( the space you spare) I left almost 12G .

    What is the problem I cannot run my live USB ???

    PS:I edited the grub file with EditNotepad++ and put the menu entry you provided as the first MENU ….
    there is a text before the menu sections in the file….Should I put it before everything???
    As far as I understand it should be put as first not from all but from the MENU entries???
    Correct??/

    Like

    1. I am actually stuck on the third screen after one more attempt.

      I guess the Nouveau error is from Nvidia drivers???

      Like

    2. Hi! I’m having the same error- did you ever figure out what was causing it? I know it’s been a while… sorry :/

      Like

Leave a comment