4

How can I create a persistent USB from Command Line Interface on Ubuntu?

Is there any USB creator tool for making an USB persistent ?

cl-netbox
  • 31,163
  • 7
  • 94
  • 131
Ravan
  • 9,379

4 Answers4

2

Adding to @jpf137's answer, there is a way to make an existing live USB persistent.

  1. Make a file in the root of the live USB called casper-rw using dd like this:

    dd if=/dev/zero of=/path/to/casper-rw bs=1M count=512
    
  2. Make a filesystem in casper-rw like this:

    mkfs.ext4 /path/to/casper-rw 
    
  3. Edit boot/grub/grub.cfg on the USB. Look for the line starting with linux.
    Before the -- at the end, add persistent;
    so that the line's ending looks like: persistent --.

Done.

2

Yes there is a USB creator tool for making persistent USB called mkusb that should satisfy your needs.

It has both a GUI version

sudo apt-get install mkusb

and a text only [CLI] version

sudo apt-get install mkusb-nox

I suppose the second one is what you want here.

It works very nicely and I have used it even on the current (as on 18-09-16) Ubuntu 16.04.

You can find the documentation here. If you want to give the GUI version a shot, check out these answers too.

Harsh
  • 898
1

use:

usb-creator-gtk

Look up your .iso and device to use, then choose "stored in reserved extra space" (instead of discarded on shutdown) to make the drive persistent.

1

mkusb-nox works in text mode and creates live-only USB boot drives (not persistent live drives).

mkusb (mkusb-dus) works in graphics mode and text mode and can create both live-only and persistent live USB boot drives.

There is new version of mkusb, with the name dus. It can create persistent live drives, when running in text mode. It has migrated from the testing phase to the stable PPA ppa:mkusb/ppa, when this update was written at mkusb version 12.1.5.


Edit 2023-04-07: mkusb-dus is at version 23.0.1 now and I recommend that you start with this link:

help.ubuntu.com/community/mkusb


See also the following links,

dus - a revamped interface of mkusb and mkusb-nox

Install from the normal (stable) mkusb PPA

Install from the unstable mkusb PPA

sudodus
  • 46,324
  • 5
  • 88
  • 152
  • I could not get mkusb to work on mint and my friend tried to make it work on ubuntu 24.04 with unetbootin . It says persistent when you finish but it really isn't persistent. Create a file on the desktop and reboot. Please verify this really works. I heard that the buntu based iso's no longer support it. – Bhikkhu Subhuti Feb 15 '24 at 11:40
  • @BhikkhuSubhuti, I tested mkusb in and with Ubuntu Desktop Noble (to be released as 24.04 LTS) some time ago, and I could create a persistent live drive with Noble as well as older versions of Ubuntu. Longer ago I have used mkusb to create persistent live drives with Linux Mint. Please tell me which version and flavour you are running (the host computer) and which version and flavour you want to make persistent live, and I can test mkusb, and tell what works. – sudodus Feb 15 '24 at 23:01
  • There are several tools in mkusb, and I think dus-iso2usb and mkusb-plug are most likely to work with new versions of Ubuntu and Mint and with new computers. – sudodus Feb 15 '24 at 23:01
  • I was able to get it to work with 22.04 using rufas. – Bhikkhu Subhuti Mar 22 '24 at 10:18