@@ -115,7 +115,14 @@ format-udf is a self-contained script. Simply copy format-udf.sh to a directory
115
115
116
116
# Usage
117
117
```
118
+ Bash script to format a block device (hard drive or Flash drive) in UDF.
119
+ The output is a drive that can be used for reading/writing across multiple
120
+ operating system families: Windows, macOS, and Linux.
121
+ This script should be capable of running in macOS or in Linux.
122
+
118
123
Usage: ./format-udf.sh [-b BLOCK_SIZE] [-f] [-p PARTITION_TYPE] [-w WIPE_METHOD] device label
124
+ ./format-udf.sh -v
125
+ ./format-udf.sh -h
119
126
120
127
-b BLOCK_SIZE
121
128
Block size to be used during format operation.
@@ -127,14 +134,20 @@ Usage: ./format-udf.sh [-b BLOCK_SIZE] [-f] [-p PARTITION_TYPE] [-w WIPE_METHOD
127
134
Forces non-interactive mode. Useful for scripting.
128
135
Please use with caution, as no user confirmation is given.
129
136
137
+ -h
138
+ Display help information and exit.
139
+
130
140
-p PARTITION_TYPE
131
141
Partition type to set during format operation.
132
142
Currently supported types include: mbr, none
133
143
mbr - Master boot record (default)
134
144
none - Do not modify partitions
135
145
If absent, defaults to 'mbr'.
136
146
See also:
137
- https://github.com/JElchison/format-udf#a-fake-partition-table-to-fake-out-windows
147
+ https://github.com/JElchison/format-udf#why
148
+
149
+ -v
150
+ Display version information and exit.
138
151
139
152
-w WIPE_METHOD
140
153
Wipe method to be used before format operation.
@@ -156,100 +169,111 @@ Usage: ./format-udf.sh [-b BLOCK_SIZE] [-f] [-p PARTITION_TYPE] [-w WIPE_METHOD
156
169
label
157
170
Label to apply to formatted device.
158
171
159
- Example: ./format-udf.sh sdg "My External Drive"
172
+ Example: ./format-udf.sh sdg "My UDF External Drive"
160
173
```
161
174
162
175
163
176
### Example usage
164
177
On Ubuntu:
165
178
```
166
179
user@computer:~$ ./format-udf.sh sdg "My UDF External Drive"
180
+ [+] Validating arguments...
167
181
[+] Testing dependencies...
182
+ [+] Looking for drive info tool... using /sbin/blockdev
168
183
[+] Looking for drive listing tool... using /sbin/blockdev
184
+ [+] Looking for drive summary tool... using /sbin/blkid
169
185
[+] Looking for unmount tool... using /bin/umount
170
186
[+] Looking for UDF tool... using /usr/bin/mkudffs
171
- [+] Parsing options...
172
- [+] Validating arguments...
173
- [+] Gathering drive information...
187
+ [+] Detecting logical block size...
174
188
[sudo] password for user:
175
- /dev/sdg: LABEL="Old Drive" TYPE="udf"
176
- HTS721010G9SA00
189
+ [*] Detected logical block size of 512
190
+ [+] Validating detected logical block size...
191
+ [+] Detecting physical block size...
192
+ [*] Detected physical block size of 512
193
+ [+] Validating detected physical block size...
194
+ [+] Validating file system block size...
195
+ [*] Using file system block size of 512
196
+ [+] Detecting total size...
197
+ [*] Detected total size of 31040995328
198
+ [+] Validating detected total size...
199
+ [+] Gathering drive information...
200
+ /dev/sdg: UUID="41A4EE1A20286d61" LABEL="Old Drive" TYPE="udf" PTTYPE="dos"
201
+
177
202
RO RA SSZ BSZ StartSec Size Device
178
- rw 256 512 4096 0 100030242816 /dev/sdg
203
+ rw 256 512 4096 0 31040995328 /dev/sdg
204
+ rw 256 512 512 0 31040995328 /dev/sdg1
179
205
The above-listed device (and partitions, if any) will be completely erased.
180
206
Type 'yes' if this is what you intend: yes
181
- [+] Detecting total size...
182
- [*] Using total size of 100030242816
183
- [+] Validating detected total size...
184
- [+] Detecting physical block size...
185
- [*] Using block size of 512
186
- [+] Validating detected block size...
187
207
[+] Unmounting device...
188
208
umount: /dev/sdg: not mounted
189
209
[+] Zeroing out first chunk of device...
190
210
4096+0 records in
191
211
4096+0 records out
192
- 2097152 bytes (2.1 MB) copied, 0.531167 s, 3.9 MB/s
212
+ 2097152 bytes (2.1 MB, 2.0 MiB ) copied, 0.240331 s, 8.7 MB/s
193
213
[+] Formatting /dev/sdg ...
194
214
start=0, blocks=64, type=RESERVED
195
215
start=64, blocks=12, type=VRS
196
216
start=76, blocks=180, type=USPACE
197
217
start=256, blocks=1, type=ANCHOR
198
218
start=257, blocks=16, type=PVDS
199
219
start=273, blocks=1, type=LVID
200
- start=274, blocks=195371037 , type=PSPACE
201
- start=195371311 , blocks=1, type=ANCHOR
202
- start=195371312 , blocks=239, type=USPACE
203
- start=195371551 , blocks=16, type=RVDS
204
- start=195371567 , blocks=1, type=ANCHOR
220
+ start=274, blocks=60626413 , type=PSPACE
221
+ start=60626687 , blocks=1, type=ANCHOR
222
+ start=60626688 , blocks=239, type=USPACE
223
+ start=60626927 , blocks=16, type=RVDS
224
+ start=60626943 , blocks=1, type=ANCHOR
205
225
[+] Writing fake MBR...
206
226
16+0 records in
207
227
16+0 records out
208
- 16 bytes (16 B) copied, 0.00259109 s, 6.2 kB/s
228
+ 16 bytes copied, 0.0219986 s, 0.7 kB/s
209
229
2+0 records in
210
230
2+0 records out
211
- 2 bytes (2 B) copied, 0.000108835 s, 18.4 kB/s
212
- [+] Successfully formatted /dev/sdg: LABEL="My UDF External Drive" TYPE="udf"
231
+ 2 bytes copied, 0.000358472 s, 5.6 kB/s
232
+ [+] Successfully formatted /dev/sdg: UUID="59467176LinuxUDF" LABEL="My UDF External Drive" TYPE="udf" PTTYPE="dos"
213
233
Please disconnect/reconnect your drive now.
214
234
```
215
235
216
236
On macOS:
217
237
```
218
238
computer:~ user$ ./format-udf.sh disk2 "My UDF External Drive"
239
+ [+] Validating arguments...
219
240
[+] Testing dependencies...
241
+ [+] Looking for drive info tool... using /usr/sbin/ioreg
220
242
[+] Looking for drive listing tool... using /usr/sbin/diskutil
243
+ [+] Looking for drive summary tool... using (none)
221
244
[+] Looking for unmount tool... using /usr/sbin/diskutil
222
245
[+] Looking for UDF tool... using /sbin/newfs_udf
223
- [+] Parsing options...
224
- [+] Validating arguments...
246
+ [+] Detecting logical block size...
247
+ [*] Detected logical block size of 512
248
+ [+] Validating detected logical block size...
249
+ [+] Detecting physical block size...
250
+ [+] Validating file system block size...
251
+ [*] Using file system block size of 512
252
+ [+] Detecting total size...
253
+ [*] Detected total size of 31040995328
254
+ [+] Validating detected total size...
225
255
[+] Gathering drive information...
226
- /dev/disk2
256
+ /dev/disk2 (external, physical):
227
257
#: TYPE NAME SIZE IDENTIFIER
228
- 0: Old Drive *100 .0 GB disk2
258
+ 0: Old Drive *31 .0 GB disk2
229
259
The above-listed device (and partitions, if any) will be completely erased.
230
260
Type 'yes' if this is what you intend: yes
231
- [+] Detecting total size...
232
- [*] Using total size of 100030242816
233
- [+] Validating detected total size...
234
- [+] Detecting physical block size...
235
- [*] Using block size of 512
236
- [+] Validating detected block size...
237
261
[+] Unmounting device...
238
262
Password:
239
263
Unmount of all volumes on disk2 was successful
240
264
[+] Zeroing out first chunk of device...
241
265
4096+0 records in
242
266
4096+0 records out
243
- 2097152 bytes transferred in 0.592766 secs (3537908 bytes/sec)
267
+ 2097152 bytes transferred in 2.971664 secs (705716 bytes/sec)
244
268
[+] Formatting /dev/disk2 ...
245
- write to block device: /dev/disk2 last written block address: 195371567
269
+ write to block device: /dev/disk2 last written block address: 60626943
246
270
[+] Writing fake MBR...
247
271
16+0 records in
248
272
16+0 records out
249
- 16 bytes transferred in 0.044496 secs (360 bytes/sec)
273
+ 16 bytes transferred in 0.034208 secs (468 bytes/sec)
250
274
2+0 records in
251
275
2+0 records out
252
- 2 bytes transferred in 0.000602 secs (3322 bytes/sec)
276
+ 2 bytes transferred in 0.002100 secs (952 bytes/sec)
253
277
[+] Successfully formatted
254
278
Please disconnect/reconnect your drive now.
255
279
```
0 commit comments