Home Bootable USB Create Persistent Bootable USB Using Ventoy In Linux

Create Persistent Bootable USB Using Ventoy In Linux

By sk
4154 Views

A while ago, we have discussed how to create multiboot USB drives with Ventoy application. Today, we will see how to create persistent bootable USB using Ventoy in Linux. As you may already know, a regular bootable medium allows us to test the Linux distributions without having to install them on the hard drive. When you are on a Live OS, you can do all sort of things, such as installing applications, downloading files, playing media, creating files and folders, customizing it as per your liking and a lot more. However once you reboot the system, all of the said changes will be lost. Because, you are working on a live OS. That's how a live bootable medium works! What if you want to make all changes remain intact even after rebooted the system? This is where persistent bootable USB drives comes in help.

A bootable USB drive with persistent storage support will enable you to install programs, customize the OS and store data permanently. Nothing will be lost after reboot or shutdown. All changes will remain intact and you can use a USB bootable drive as a portable Linux system. Ventoy currently allows us to configure persistence support for Ubuntu, MX Linux, Linux Mint, Elementary OS and Zorin OS.

Create Persistent Bootable USB Using Ventoy In Linux

I assume you already have created a live bootable USB with Ventoy as described in the link attached in the first paragraph.

Open your Terminal and navigate to the folder where you have extracted the Ventoy script.

I have extracted it in a folder named “ventoy” in my $HOME directory. Cd into the Ventoy directory:

$ cd ventoy

This folder will contain the following contents:

boot CreatePersistentImg.sh log.txt tool ventoy Ventoy2Disk.sh

Now, run the "CreatePersistentImg.sh" script to create a backend image file named "persistence.img" with 1 GB in size, with EXT4 filesystem and with label casper-rw.

$ sudo sh CreatePersistentImg.sh

Or,

$ sudo ./CreatePersistentImg.sh

You can also create a specific size image using -s flag like below. The following command will create image file with 2 GB in size.

$ sudo sh CreatePersistentImg.sh -s 2048

Or,

$ sudo ./CreatePersistentImg.sh -s 2048

Here, -s 2048 indicates the size of the image file in MB. You can increase or decrease the size as you wish. You can also choose different filesystem, for example xfs, like below:

$ sudo sh CreatePersistentImg.sh -s 2048 -t xfs

Like I already said, the above commands will create an image called "persistence.img" with label casper-rw. Different distributions use different Labels by default, for example Ubuntu use casper-rw and MX Linux use MX-Persist.

You can use -l flag to set the label:

$ sudo sh CreatePersistentImg.sh -l MX-Persist

For the purpose of this guide, I am going to create an image file of size 4 GB in EXT4 filesystem, with label casper-rw using command:

$ sudo ./CreatePersistentImg.sh -s 4096

Sample output:

4096+0 records in
4096+0 records out
4294967296 bytes (4.3 GB, 4.0 GiB) copied, 55.1246 s, 77.9 MB/s
mke2fs 1.45.5 (07-Jan-2020)
Creating filesystem with 1048576 4k blocks and 262144 inodes
Filesystem UUID: bdd96096-eab5-4806-a206-909d94e96b1e
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done

Create Persistent Bootable USB Using Ventoy In Linux

This command will create a file named "persistence.img" inside ventoy folder.

Verify if the image file is created or not using "ls" command:

$ ls -lh

Sample output:

total 4.1G
drwxr-xr-x 2 sk   sk   4.0K May 30 16:51 boot
-rwxr--r-- 1 sk   sk   1.5K May 30 16:51 CreatePersistentImg.sh
-rw-r--r-- 1 root root  518 Jun  8 15:33 log.txt
-rw-r--r-- 1 root root 4.0G Jun  8 17:12 persistence.img
drwxrwxrwx 2 sk   sk   4.0K Jun  8 15:28 tool
drwxr-xr-x 2 sk   sk   4.0K May 30 16:51 ventoy
-rwxr--r-- 1 sk   sk   1.2K May 30 16:51 Ventoy2Disk.sh

Now copy the newly created persistence.img file to your Ventoy bootable USB drive.

Next create a folder called "ventoy" in your bootable USB drive. And then create "ventoy.json" file inside the ventoy folder.

Open ventoy.json file in any text editor and add the menu entries for your ISOs in the ventoy.json file.

I am going to configure persistence USB bootable support for Ubuntu 20.04 ISO, so I have added the following lines:

{
    "persistence" : [
        {
            "image": "/ubuntu-20.04-desktop-amd64.iso",
            "backend": "/persistence.img"
        }
    ]
}

Configure persistence USB bootable support for Ubuntu with ventoy

Make sure the ISO and persistence.img files are stored in the root of the USB drive. Also make sure the filenames and syntax are correct. And more importantly, the ISO filenames should not contain any spaces or special characters. If you missed a comma or a curly bracket or double quotes, the persistence support will not work.

After adding the above lines, save and close the file.

Now boot your system with the newly created USB bootable drive.

Choose Ubuntu 20.04 ISO for which you have added persistence support from the boot menu:

Ventoy boot menu

You will then see another menu that you lets you to boot with or without persistence as shown in the following screenshot:

Create Persistent Bootable USB Using Ventoy


Related read:


Create multiboot persistent USB with Ventoy

In the above example, I have created only one persistence bootable USB with Ubuntu 20.04 LTS. Ventoy allows you to create multiboot persistent USB as well.

To enable persistent support for multiple ISOs, we need to change the ventoy.json file to match with the exact path of ISO file and persistence.img.

For example, I am going to configure persistence support for Ubuntu 18.04 and Ubuntu 20.04. So, I added the following lines in my ventoy.json file:

{
    "persistence" : [
        {
            "image": "/ubuntu-20.04-desktop-amd64.iso",
            "backend": "/persistence.img"
        },
        {
            "image": "/ubuntu-18.04.3-desktop-amd64.iso",
            "backend": "/persistence.img"
        }
    ]
}

Configure multiboot persistent USB with Ventoy

You can use the same backend image (persistence.img) between multiple ISOs as long as it can be supported by the distros. Again, please make sure you have specified the exact path and filename. If there are any missing brackets, commas, colon, the persistence support will not work.

Save and close the file.

Now we have enabled persistence boot for both Ubuntu 18.04 and Ubuntu 20.04 ISOs. Boot your system with Ventoy and select the OS you want to load:

Ventoy multiboot menu

And finally boot into the OS with persistence support:

Create multiboot persistent USB with Ventoy

Save files in custom location

In our above examples, we have stored the ISOs and persistence.img files in the root of the USB drive. If you have stored the files in a separate directories for the sake of easy navigation, you must mention the exact path in the ventoy.json file.

For instance, I am going to save the ISOs in a directory named "ISO" and persistence.img files in a directory named "persistence". Here is my Ventoy file contents:

{
    "persistence" : [
        {
            "image": "/ISO/ubuntu-20.04-desktop-amd64.iso",
            "backend": "/persistence/persistence.img"
        },
        {
            "image": "/ISO/ubuntu-18.04.3-desktop-amd64.iso",
            "backend": "/persistence/persistence.img"
        }
    ]
}

For more details, refer Ventoy help:

$ sh CreatePersistentImg.sh --help

Hope this helps.

Resource:

Thanks for stopping by!

Help us to help you:

Have a Good day!!

You May Also Like

6 comments

C.S.Cameron June 11, 2020 - 1:15 pm

I have never managed to use the same casper-rw persistence file on different versions of Ubuntu. Home-rw persistence files work on different versions but a casper-rw file first used on 18.04 will do bad things if you try to use it on 20.04.

I have just now tried using the same persistence.img file for Ubuntu 18.04 as for 20.04, as you show above, and they are not compatible. Programs designed for 18.04 will likely not work with 20.04.

Please try installing a few programs into the system you have built above and see what happens.

Reply
sk June 11, 2020 - 1:19 pm

Thanks for the update, Cameron. I think its work for me. I created persistence.img in Ubuntu 20.04 LTS and used the same img file for Ubuntu 18.04 LTS. It worked! I installed an application and created a folder. Everything is intact after rebooting. May be I should do more testing on multiple distros as you suggested.

Reply
Gaurab Santra September 1, 2020 - 10:26 pm

I am trying to make persistence.img file in my ventoy directory as per your instruction. The file creation process is completed . But when I am using ls -1h command it is not displaying any persistence.img file in ventoy directory.

Reply
sk September 1, 2020 - 10:35 pm

What command did you run to create the image? Did you check if you are really inside the ventoy directory?

Reply
Gaurab Santra September 1, 2020 - 11:08 pm

I am trying to make persistence.img file in my ventoy directory as per your instruction. The file created is having an extension of dat inplace of img extension. Every time I am trying I am getting persistent.dat file in place of persistent.img file. Why this is happening?

Reply
sk September 1, 2020 - 11:44 pm

No idea why you get dat file. Probably in newer Ventoy version, the extension has changed. I will check again when I have time.

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More