Home Bootable USB Create Persistent Bootable USB Using Ventoy In Linux

Create Persistent Bootable USB Using Ventoy In Linux

By sk
Published: Last Updated on 19660 Views

We have already discussed how to create multiboot USB drives with Ventoy application. Today, we will see how to create persistent bootable USB using Ventoy in Linux.

Regular vs Persistent bootable USB

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, CloneZilla, Kali Linux, Kaspersky rescue disk, 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 with 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
Create Persistent Bootable USB Using Ventoy In Linux

This command will create a file named "persistence.dat" 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 Feb 8 16:41 boot
-rwxr-xr-x 1 sk sk 2.0K Feb 8 16:41 CreatePersistentImg.sh
-rw-r--r-- 1 root root 734 Feb 22 13:27 log.txt
-rw-r--r-- 1 root root 4.0G Feb 22 14:11 persistence.dat
drwxr-xr-x 3 sk sk 4.0K Feb 8 16:41 plugin
-rw-r--r-- 1 sk sk 1.4K Feb 8 16:41 README
drwxr-xr-x 5 sk sk 4.0K Feb 8 16:41 tool
drwxr-xr-x 2 sk sk 4.0K Feb 8 16:41 ventoy
-rwxr-xr-x 1 sk sk 1.7K Feb 8 16:41 Ventoy2Disk.sh
Check if persistence image file is created
Check if persistence image file is created

Now copy the newly created persistence.dat 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 in my ventoy.json file:

{
    "persistence" : [
        {
            "image": "/ubuntu-20.04-desktop-amd64.iso",
            "backend": "/persistence.dat"
        }
    ]
}
Configure persistence USB bootable support for Ubuntu with ventoy
Configure persistence USB bootable support for Ubuntu with ventoy

Note: Make sure the ISO and persistence.dat 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, press CTRL+O followed by CTRL+X to save the file and close it.

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
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:

Ubuntu 20.04 Bootable USB with persistence support using Ventoy
Ubuntu 20.04 Bootable USB with persistence support using Ventoy

That's it. From now on, you can use this bootable medium as portable OS. You can install applications, save files and configure it as you wish. Nothing will be lost after you reboot.

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 drives as well.

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

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.dat"
        },
        {
            "image": "/ubuntu-18.04.3-desktop-amd64.iso",
            "backend": "/persistence.dat"
        }
    ]
}
Configure multiboot persistent USB with Ventoy
Configure multiboot persistent USB with Ventoy

You can use the same backend image (i.e. persistence.dat) file for multiple ISOs as long as it is supported by the distros.

Again, please make sure you have specified the exact path, filename, commas, and curly brackets. If there are any missing brackets, commas, colon, the persistence support will not work.

Similarly, add menu entries for as many as OSes as you want. Press CTRL+O followed by CTRL+X to save the file and close it.

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

Choose Ubuntu 18.04 from Ventoy boot menu
Choose Ubuntu 18.04 from Ventoy boot menu

And finally boot into the OS with persistence support:

Create multiboot persistent USB using Ventoy
Create multiboot persistent USB using 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:

You May Also Like

10 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
Chuck Pool January 22, 2021 - 5:52 am

I have to add to GAURAB SANTRA – I’ve created the persistence file in my ventoy folder inside my /home location but all I get is a persistence.dat and no .img file. Even with the backend listed persistence.dat I get no persistent file function on the USB. I’m in ubuntu 20.10, I could not create a persistent.img file in my usb when I was using 20.04 as well. I don’t understand what is wrong – I do get the correct permissions, just not an .img file. Any help forthcoming would be great. Thanks

Reply
Attila February 14, 2021 - 4:21 am

Current version of CreatePersistentImg.sh created persistence.dat instead of persistence.img! If you check Ventoy persistence documentation https://www.ventoy.net/en/plugin_persistence.html it always mentions .dat files, not .img! Took several minutes to figure this out. After correcting this in my ventoy.json, it started to work.
Please kindly correct this in this post, otherwise it is quite misleading.
Great post anyway!

Reply
ashittyllama March 10, 2021 - 4:37 am

Anyone got fedora workstation live to work with persistence ?
I can’t seem to make it work

Reply
sk March 10, 2021 - 10:55 am

Ventoy currently allows us to configure persistence support for Ubuntu, MX Linux, Linux Mint, Elementary OS, CloneZilla, Kali Linux, Kaspersky rescue disk, and Zorin OS. Fedora is not yet supported.

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