Skip to content

Instantly share code, notes, and snippets.

@noromanba
Last active June 18, 2019 05:18
Show Gist options
  • Save noromanba/4979138 to your computer and use it in GitHub Desktop.
Save noromanba/4979138 to your computer and use it in GitHub Desktop.
How to make Ubuntu live USB with persistent image

How to make Ubuntu live USB with persistent image

Depends

target distro is ubuntu-ja-remix 32bit, but similar to official distro

Ubuntu Desktop ISO

core of live USB

12.10 or later

UnetBootin

download from official page or use package manager. apt, yum, et al.

Unix like host OS

basis for create live USB. use some tiny CUI/GUI tools for build more better bootable-USB than bootable-CD/DVD

Knoppix

most useful, effort, slim. recommends Japanese CD edition

Ubuntu live

ubuntu-*.iso burned DVD. 'ts too slow

Other OS

prob works

  • Mac OSX
  • Windows
  • pre installed GNU Utils, Cygwin, MinGW, et al.

Partition Editor

GParted, et al.

1. Install components

Download ubuntu-ja-remix

if you needs Japanese, use localized distributon

$ wget http://ftp.jaist.ac.jp/pub/Linux/ubuntu-jp-cdimage/releases/12.10/ubuntu-ja-12.10-desktop-i386.iso
ubuntu-ja-12.10-desktop-i386.iso

if you burn to disc for host OS, this image 800MB over. use DVD-R(-RW, +R, +RW)

(optional) Rename ja-img as same as orig.

not necessary rename

http://releases.ubuntu.com/quantal/ubuntu-12.10-desktop-i386.iso

$ mv ubuntu-ja-12.10-desktop-i386.iso ubuntu-12.10-desktop-i386.iso

I don't rename but UnetBootin create persistent image and running

UnetBootin

download unetbootin-linux-583 or later

if you want to use package manager, like this:

$ sudo apt-get install unetbootin

but package ver legacy possibilities

chmod

to executable

$ chmod 744 unetbootin-linux-583

or

$ chmod +x unetbootin-linux-583

7-zip (if not installed host OS)

UnetBootin needs p7z

$ sudo apt-get install p7zip-full

2. make bootable USB

format USB

add target device path(e.g. /dev/sdc) to option

$ sudo gparted /dev/sdc

simple and speedy scan

gparted steps

!ATTENTION: do not use ext4 format on "step 2"

  1. unmount (if already mounted)
  2. format to fat32(aka vfat)
  3. apply
  4. close diaog
  5. re-mount
  6. exit

if you format USB by ext4, faild to create persistent image and no alert

mount USB

if forgot "mount" by Gparted

  1. unplug USB
  2. plugin USB
  3. run automount and open file manager
  4. done

or

$ sudo mount /dev/sdc1 /media/sdc1

simple mount. mount options as you like

make bootable USB

run UnetBootin

$ ./unetbootin-linux-583

GUI settings

  1. select radio to "ISO"
  2. select "ubuntu-*.iso" file
  3. set persistent size e.g. [2048] MB
  4. push OK
  5. long long long time wait...
  6. done
  7. reboot

done!

Perfomance problem

default env tooooooo heaviness 👎

ubuntu@ubuntu:~$ mount -l | grep "cdrom"
/dev/sdc1 on /cdrom type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=cp437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
ubuntu@ubuntu:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/cow            2.0G  152M  1.8G   8% /
udev            1.5G  4.0K  1.5G   1% /dev
tmpfs           606M  840K  606M   1% /run
/dev/sdc1       3.8G  2.9G  976M  75% /cdrom
/dev/loop0      788M  788M     0 100% /rofs
tmpfs           1.5G   28K  1.5G   1% /tmp
none            5.0M     0  5.0M   0% /run/lock
none            1.5G  268K  1.5G   1% /run/shm
none            100M   36K  100M   1% /run/user
/dev/sdb1       4.6G  4.6G  2.0M 100% /media/ubuntu/KNOPPIX
/dev/sdb2       3.0G  2.5G  454M  85% /media/ubuntu/DATA
ubuntu@ubuntu:~$ cd /cdrom/
ubuntu@ubuntu:/cdrom$ 
ubuntu@ubuntu:/cdrom$ ll -h | grep casper-rw
-rwxr-xr-x 1 root root 2.0G Feb 19 01:35 casper-rw*

casper-rw is persistent image 🐌


Performance Improvement

testing yet

boot from other linux

e.g.

  • Knoppix
  • Ubuntu live DVD

remake casper-rw

  1. backup casper-rw
  2. delete casper-rw
  3. create same size persistent(2048MB)
  4. create filesystem by ext4

use Knoppix like this:

$ cd /media/sdc1/ # sdc1: Ubuntu-USB
$ cp -v casper-rw /media/sdd5/_backup/ # sdd5: HDD for backup
$ rm casper-rw
$ dd if=/dev/zero of=casper-rw bs=1M count=2048
$ mkfs.ext4 -F casper-rw

http://www11.ocn.ne.jp/~ksoft/ubuntu.html (written in Japanese)

resize persistent

near futuer, want to extend 1024MB like this:

$ cd /media/sdc1/
$ e2fsck -fy casper-rw
$ dd if=/dev/zero bs=1M count=1024 >> casper-rw
$ e2fsck -fy casper-rw
$ resize2fs casper-rw

how to extend knoppix-data.img - noromanba - Gist:4702723

ext4-nized casper-rw

remaked log

knoppix@Microknoppix:/media/sdc1$ rm casper-rw
rm: remove regular file `casper-rw'? y
knoppix@Microknoppix:/media/sdc1$ ll -hF
total 22M
-rwxrwxrwx 1 knoppix knoppix 8.3K Oct 19 09:56 SHA256SUMS*
drwxrwxrwx 2 knoppix knoppix 4.0K Feb 18 20:10 casper/
drwxrwxrwx 2 knoppix knoppix 4.0K Feb 18 20:10 install/
drwxrwxrwx 2 knoppix knoppix 4.0K Feb 18 20:10 isolinux/
-r-xr-xr-x 1 knoppix knoppix  32K Feb 18 20:10 ldlinux.sys*
-rwxrwxrwx 1 knoppix knoppix  688 Oct 19 10:35 md5sum.txt*
-rwxrwxrwx 1 knoppix knoppix  60K Feb 18 20:10 menu.c32*
-rwxrwxrwx 1 knoppix knoppix 1.1K Feb 18 20:10 syslinux.cfg*
-rwxrwxrwx 1 knoppix knoppix 1.8K Feb 18 20:10 ubnfilel.txt*
-rwxrwxrwx 1 knoppix knoppix  17M Oct 19 09:56 ubninit*
-rwxrwxrwx 1 knoppix knoppix 5.0M Oct 19 09:55 ubnkern*
-rwxrwxrwx 1 knoppix knoppix   30 Feb 18 20:07 ubnpathl.txt*
knoppix@Microknoppix:/media/sdc1$ time dd if=/dev/zero of=casper-rw bs=1 count=1 seek=2G
1+0 records in
1+0 records out
1 byte (1 B) copied, 5.2102e-05 s, 19.2 kB/s

real    7m54.133s
user    0m0.000s
sys     0m5.470s
knoppix@Microknoppix:/media/sdc1$ ll -hF
total 2.1G
-rwxrwxrwx 1 knoppix knoppix 8.3K Oct 19 09:56 SHA256SUMS*
drwxrwxrwx 2 knoppix knoppix 4.0K Feb 18 20:10 casper/
-rwxrwxrwx 1 knoppix knoppix 2.1G Feb 19 14:47 casper-rw*
drwxrwxrwx 2 knoppix knoppix 4.0K Feb 18 20:10 install/
drwxrwxrwx 2 knoppix knoppix 4.0K Feb 18 20:10 isolinux/
-r-xr-xr-x 1 knoppix knoppix  32K Feb 18 20:10 ldlinux.sys*
-rwxrwxrwx 1 knoppix knoppix  688 Oct 19 10:35 md5sum.txt*
-rwxrwxrwx 1 knoppix knoppix  60K Feb 18 20:10 menu.c32*
-rwxrwxrwx 1 knoppix knoppix 1.1K Feb 18 20:10 syslinux.cfg*
-rwxrwxrwx 1 knoppix knoppix 1.8K Feb 18 20:10 ubnfilel.txt*
-rwxrwxrwx 1 knoppix knoppix  17M Oct 19 09:56 ubninit*
-rwxrwxrwx 1 knoppix knoppix 5.0M Oct 19 09:55 ubnkern*
-rwxrwxrwx 1 knoppix knoppix   30 Feb 18 20:07 ubnpathl.txt*
knoppix@Microknoppix:/media/sdc1$ mkfs.ext4 -F casper-rw
mke2fs 1.42.4 (12-Jun-2012)
warning: Unable to get device geometry for casper-rw
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
131072 inodes, 524288 blocks
26214 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912

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

knoppix@Microknoppix:/media/sdc1$ 

Why dd is slow?

use with seek=SIZE option, but actually, much time was wasted

knoppix@Microknoppix:/media/sdc1$ time dd if=/dev/zero of=casper-rw bs=1 count=1 seek=2G
1+0 records in
1+0 records out
1 byte (1 B) copied, 5.2102e-05 s, 19.2 kB/s

real    7m54.133s
user    0m0.000s
sys     0m5.470s

http://blog.monoweb.info/blog/2013/02/16/large-files/ (written in Japanese)

USB formatted by fat32(vfat) filesystem, prob unsupported "sparse file"

c.f.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment