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