1 Simple script to create persistent Live USB drive
2 =================================================
4 Will create a live usb drive with persistence and a mass storage area useable
9 Clone this repository, or download the 'disk_creator.sh' file.
22 The linux kernel must be compiled with support for iso9660 file systems.
24 On debian based distributions most of these will be installed already, just in
25 case here is how to install them:
27 .. code-block:: console
30 $ sudo apt install ntfs-3g util-linux dosfstools bash gawk bc
38 List all currently plugged in block devices, you might see something like this:
40 .. code-block:: console
43 loop0 7:0 0 54.4M 1 loop /snap/core18/1055
44 loop1 7:1 0 4M 1 loop /snap/gnome-calculator/352
45 loop2 7:2 0 1008K 1 loop /snap/gnome-logs/57
46 loop3 7:3 0 140.7M 1 loop /snap/gnome-3-26-1604/90
47 loop4 7:4 0 35.3M 1 loop /snap/gtk-common-themes/1198
48 loop5 7:5 0 14.8M 1 loop /snap/gnome-characters/292
49 loop6 7:6 0 88.4M 1 loop /snap/core/7169
50 loop7 7:7 0 54.4M 1 loop /snap/core18/1049
51 loop8 7:8 0 149.9M 1 loop /snap/gnome-3-28-1804/67
52 loop9 7:9 0 149.9M 1 loop /snap/gnome-3-28-1804/63
53 loop10 7:10 0 3.7M 1 loop /snap/gnome-system-monitor/100
54 loop11 7:11 0 14.8M 1 loop /snap/gnome-characters/296
55 loop12 7:12 0 3.7M 1 loop /snap/gnome-system-monitor/95
56 loop13 7:13 0 2.3M 1 loop /snap/gnome-calculator/260
57 loop14 7:14 0 1008K 1 loop /snap/gnome-logs/61
58 loop15 7:15 0 88.5M 1 loop /snap/core/7270
59 loop16 7:16 0 14.5M 1 loop /snap/gnome-logs/45
60 loop17 7:17 0 4M 1 loop /snap/gnome-calculator/406
61 loop18 7:18 0 42.8M 1 loop /snap/gtk-common-themes/1313
62 loop19 7:19 0 140.7M 1 loop /snap/gnome-3-26-1604/88
64 ├─sda1 8:1 0 128M 0 part
65 └─sda2 8:2 0 7.3T 0 part
66 sdb 8:16 0 9.1T 0 disk
67 └─sdb1 8:17 0 9.1T 0 part
68 ├─mass-swap 253:0 0 128G 0 lvm [SWAP]
69 └─mass-storage 253:1 0 8T 0 lvm /mnt/mass/storage
70 sdc 8:32 0 9.1T 0 disk
71 └─sdc1 8:33 0 9.1T 0 part
72 └─mass-scratch 253:2 0 2T 0 lvm /mnt/mass/scratch
73 nvme0n1 259:0 0 238.5G 0 disk
74 ├─nvme0n1p1 259:1 0 512M 0 part /boot/efi
75 └─nvme0n1p2 259:2 0 238G 0 part /
77 Plug in your usb drive and list all block devices again:
79 .. code-block:: console
85 nvme0n1 259:0 0 238.5G 0 disk
86 ├─nvme0n1p1 259:1 0 512M 0 part /boot/efi
87 └─nvme0n1p2 259:2 0 238G 0 part /
88 sdd 8:48 1 7.5G 0 disk
90 Notice the new device, `sdd`. It may be called differently on your machine, but
91 will likely be named `sdX` where `X` is a letter. The full name of your usb
94 Be absolutely that you have correctly identified the USB device at this point.
95 If you have misidentified it, you will cause irreparable loss of data.
100 Find the installer image for your favourite debian based distribution. You can
101 typically find these things by searching 'get <distribution_name>',
102 'download <distribution_name>' or 'install <distribution_name>' with your
103 favourite search engine. You can also look for tutorials about how to install
104 that distribution. They will likely include instructions about getting the
105 installer image. Download the image and make a note of it's location.
110 Run 'disk_creator.sh' with root privileges:
112 .. code-block:: console
114 $ sudo /path/to/disk_creator.sh /path/to/installer/image.iso /dev/sdX
116 For instance, if your usb device is '/dev/sdd' and your installer image is
117 located at '/home/user/Downloads/ubuntu-18.04-amd64.iso' run:
119 .. code-block:: console
121 $ sudo /path/to/disk_creator.sh \
122 > /home/user/Downloads/ubuntu-18.04-amd64.iso \
125 The disk_creator will now run for some time while it copies things to the usb
126 drive. Once it is done, read through the output it produced. If there are no
127 obvious error messages, it should have completed successfully.
132 The USB drive should now have three partitions. One each of NTFS, ext4 and
133 FAT32. When plugged into a windows machine, one of them should appear as a large
134 empty partition labeled 'usbdata'.
136 You should be able to boot from the USB drive, into whatever installer image you
137 provided. If it does so, test that a test file created on the desktop remains
138 there after a reboot.
140 If all these tests are successful, everything should have worked.
142 If not, read the contents of the 'disk_creator.sh' script and try to understand
143 what it is doing. It is heavily commented.