]> git.friedersdorff.com Git - max/disk_creator.git/blob - README.rst
Clarify mounting/unmounting
[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 * grub with efi support
22
23 The linux kernel must be compiled with support for iso9660 file systems.
24
25 On debian based distributions most of these will be installed already, just in
26 case here is how to install them:
27
28 .. code-block:: console
29
30    $ sudo apt update
31    $ sudo apt install ntfs-3g util-linux dosfstools bash gawk bc grub-efi-amd64-bin
32
33 Usage
34 -----
35
36 Identify USB device
37 ###################
38
39 List all currently plugged in block devices, you might see something like this:
40
41 .. code-block:: console
42
43    $ lsblk
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
64    sda                8:0    0   7.3T  0 disk
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 /
77
78 Plug in your usb drive and list all block devices again:
79
80 .. code-block:: console
81
82    $ lsblk
83    .
84    .
85    .
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
90
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
93 device is `/dev/sdX`.
94
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.
97
98 Once identified, make sure you unmount or eject all partitions on the usb 
99 device.
100
101 Linux install image
102 ###################
103
104 Find the installer image for your favourite debian based distribution.  You can
105 typically find these things by searching 'get <distribution_name>',
106 'download <distribution_name>' or 'install <distribution_name>' with your 
107 favourite search engine.  You can also look for tutorials about how to install
108 that distribution.  They will likely include instructions about getting the 
109 installer image. Download the image and make a note of it's location.
110
111 Running disk_creator
112 --------------------
113
114 Run 'disk_creator.sh' with root privileges:
115
116 .. code-block:: console
117
118    $ sudo /path/to/disk_creator.sh /path/to/installer/image.iso /dev/sdX
119
120 For instance, if your usb device is '/dev/sdd' and your installer image is
121 located at '/home/user/Downloads/ubuntu-18.04-amd64.iso' run:
122
123 .. code-block:: console
124
125    $ sudo /path/to/disk_creator.sh \
126    > /home/user/Downloads/ubuntu-18.04-amd64.iso \
127    > /dev/sdd
128
129 The disk_creator will now run for some time while it copies things to the usb 
130 drive.  Once it is done, read through the output it produced.  If there are no
131 obvious error messages, it should have completed successfully.
132
133 Testing it worked
134 -----------------
135
136 The USB drive should now have three partitions. One each of NTFS, ext4 and
137 FAT32.  When plugged into a windows machine, one of them should appear as a large
138 empty partition labeled 'usbdata'.
139
140 You should be able to boot from the USB drive, into whatever installer image you
141 provided.  If it does so, test that a test file created on the desktop remains 
142 there after a reboot.
143
144 If all these tests are successful, everything should have worked.
145
146 If not, read the contents of the 'disk_creator.sh' script and try to understand
147 what it is doing.  It is heavily commented.