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.
Table of Contents
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
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
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" } ] }
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:
You will then see another menu that you lets you to boot with or without persistence as shown in the following screenshot:
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" } ] }
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:
And finally boot into the OS with persistence support:
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:
17 comments
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.
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.
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.
What command did you run to create the image? Did you check if you are really inside the ventoy directory?
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?
No idea why you get dat file. Probably in newer Ventoy version, the extension has changed. I will check again when I have time.
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
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!
Anyone got fedora workstation live to work with persistence ?
I can’t seem to make it work
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.
Thanks for this guide! A few questions…
1) If for example I’m doing this on one distro (20.04 LTS), will it mean I’ll have 2 copies of the distro on the flash drive? Or is it only one copy that I could choose to either boot in persistent or not persistent mode?
2) Do you have a guide on how to do this through Windows?
3) Can I do this for the same distro I’m booted in?
4) Can I do this through Windows and then add the file on the flash drive?
I only have 1 USB drive to work with. That’s the one with Ventoy and the non persistent Linux. My PC is Windows 10. Can I do the work on Windows and then copy the file on the Ventoy USB drive to get the result in your article?
Thanks again!
Thanks for the comment.
1. It is only one copy. You can choose either boot into persistent or non-persistent.
2. No.
3. I don’t know. I never checked it before.
4. Yes, you can make persistent bootable device on any OS that supports Ventoy.
Sorry for the late reply. Your comment is gone into spam folder unfortunately.
Hey man, my Linux mint live machine just freezed after I ran the “sudo sh CreatePersistentImg.sh” above. I Only have to turn it off and restart the process and see how well that works for me.
What are the consequences of the size of the image file? Is this size the size that will be available for persistance? I have a 128 GB USB pendrive and would like to use as much space as possible for running ZORIN OS on an old MacBook Air from it.
> What are the consequences of the size of the image file?
I don’t think there would be any consequences. The performance might depend on the Read/Write speed of the disk.It is my assumption though. Please test it yourself and share your findings here.
> Is this size the size that will be available for persistence?
Yes. For instance, if you created an image file of size 10 GB with EXT4 filesystem, you can use 10 GB space for persistence.
Many thanks for your answer. Just to clarify from the naive user’s point of view, the selected size will not have consequences from a performance point of view, but it will have very important consequences in practice for the user as this size defines the size of the disk that will be available for the user. I suggest you actually mention this issue (and your crystal clear example of the 10 GB) at the step “The following command will create image file with 2 GB in size”, perhaps just adding ” thus a disk of only 2GB will be available after the persistent installation”.
Thanks.
I suggest you clarify the issue of the future available space at the step “The following command will create image file with 2 GB in size.”