]> git.friedersdorff.com Git - max/disk_creator.git/blob - README.rst
a1dd7ef0a5494e6af8a09c2435d853f088d8bf19
[max/disk_creator.git] / README.rst
1 Simple script to create persistent Live USB drive
2 =================================================
3
4 Will create a live usb drive with persistence and a mass storage area useable
5 by windows OSs.
6
7 Installation
8 ------------
9 Clone this repository, or download the 'disk_creator.sh' file.
10
11 Dependencies
12 ############
13
14 * bash
15 * sfdisk
16 * losetup
17 * ntfs3g 
18 * dosfstools
19 * awk
20 * bc
21
22 The linux kernel must be compiled with support for iso9660 file systems.
23
24 On debian based distributions most of these will be installed already, just in
25 case here is how to install them:
26
27 .. code-block:: console
28
29    $ sudo apt update
30    $ sudo apt install ntfs-3g util-linux dosfstools bash gawk bc
31
32 Usage
33 -----
34
35 Identify USB device
36 ###################
37
38 List all currently plugged in block devices, you might see something like this:
39
40 .. code-block:: console
41
42    $ lsblk
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
63    sda                8:0    0   7.3T  0 disk
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 /
76
77 Plug in your usb drive and list all block devices again:
78
79 .. code-block:: console
80
81    $ lsblk
82    .
83    .
84    .
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
89
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
92 device is `/dev/sdX`.
93
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.
96
97 Linux install image
98 ###################
99
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.
106
107 Running disk_creator
108 --------------------
109
110 Run 'disk_creator.sh' with root privileges:
111
112 .. code-block:: console
113
114    $ sudo /path/to/disk_creator.sh /path/to/installer/image.iso /dev/sdX
115
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:
118
119 .. code-block:: console
120
121    $ sudo /path/to/disk_creator.sh \
122    > /home/user/Downloads/ubuntu-18.04-amd64.iso \
123    > /dev/sdd
124
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.
128
129 Testing it worked
130 -----------------
131
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'.
135
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.
139
140 If all these tests are successful, everything should have worked.
141
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.