29 C
Jaipur
Saturday, May 8, 2021

Create Persistent Bootable USB Using Ventoy In Linux

Must read

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

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

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.


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

Source link

- Advertisement -

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement -

Latest article