Skip to content

Commit d6b38d7

Browse files
committed
Add support for virtual block devices
Fixes #46 Fixes #27 Fixes #25 Closes #49 Closes #50
1 parent ec5fd9a commit d6b38d7

File tree

3 files changed

+253
-114
lines changed

3 files changed

+253
-114
lines changed

README.md

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ If you have conducted testing and would like to update this table to benefit fut
103103
* `xxd`
104104
* *One* of the following: `blockdev`, `ioreg`
105105
* *One* of the following: `blockdev`, `diskutil`
106+
* *One* of the following: `lsblk`, `diskutil`
106107
* *One* of the following: `umount`, `diskutil`
107108
* *One* of the following: `mkudffs`, `newfs_udf`
108109

@@ -167,9 +168,9 @@ Usage: ./format-udf.sh [-b BLOCK_SIZE] [-f] [-p PARTITION_TYPE] [-w WIPE_METHOD
167168
Note: 'zero' and 'scrub' methods will take a long time.
168169
169170
device
170-
Device to format. Should be of the form:
171-
* sdx (Linux, where 'x' is a letter) or
172-
* diskN (macOS, where 'N' is a number)
171+
Device to format. Examples:
172+
* /dev/sdx (Linux, where 'x' is a letter) or
173+
* /dev/diskN (macOS, where 'N' is a number)
173174
174175
label
175176
Label to apply to formatted device.
@@ -181,14 +182,15 @@ Example: ./format-udf.sh sdg "My UDF External Drive"
181182
### Example usage
182183
On Ubuntu:
183184
```
184-
user@computer:~$ ./format-udf.sh sdg "My UDF External Drive"
185+
user@computer:~$ ./format-udf.sh /dev/sdg "My UDF External Drive"
185186
[+] Validating arguments...
186187
[+] Testing dependencies...
187-
[+] Looking for drive info tool... using /sbin/blockdev
188+
[+] Looking for drive detail tool... using /sbin/blockdev
188189
[+] Looking for drive listing tool... using /sbin/blockdev
190+
[+] Looking for drive info tool... using /bin/lsblk
189191
[+] Looking for drive summary tool... using /sbin/blkid
190192
[+] Looking for unmount tool... using /bin/umount
191-
[+] Looking for UDF tool... using /usr/bin/mkudffs
193+
[+] Looking for UDF tool... using /usr/sbin/mkudffs
192194
[+] Detecting logical block size...
193195
[sudo] password for user:
194196
[*] Detected logical block size of 512
@@ -199,42 +201,50 @@ user@computer:~$ ./format-udf.sh sdg "My UDF External Drive"
199201
[+] Validating file system block size...
200202
[*] Using file system block size of 512
201203
[+] Detecting total size...
202-
[*] Detected total size of 31040995328
204+
[*] Detected total size of 8019509248
203205
[+] Validating detected total size...
204206
[+] Gathering drive information...
205-
/dev/sdg: UUID="41A4EE1A20286d61" LABEL="Old Drive" TYPE="udf" PTTYPE="dos"
207+
/dev/sdg: LABEL="Old Drive" UUID="4843-D1BD" TYPE="vfat"
206208
207209
RO RA SSZ BSZ StartSec Size Device
208-
rw 256 512 4096 0 31040995328 /dev/sdg
209-
rw 256 512 512 0 31040995328 /dev/sdg1
210+
rw 256 512 512 0 8019509248 /dev/sdg
210211
The above-listed device (and partitions, if any) will be completely erased.
211212
Type 'yes' if this is what you intend: yes
212213
[+] Unmounting device...
213214
umount: /dev/sdg: not mounted
214215
[+] Zeroing out first chunk of device...
215216
4096+0 records in
216217
4096+0 records out
217-
2097152 bytes (2.1 MB, 2.0 MiB) copied, 0.240331 s, 8.7 MB/s
218+
2097152 bytes (2.1 MB, 2.0 MiB) copied, 0.450716 s, 4.7 MB/s
218219
[+] Formatting /dev/sdg ...
219-
start=0, blocks=64, type=RESERVED
220-
start=64, blocks=12, type=VRS
221-
start=76, blocks=180, type=USPACE
222-
start=256, blocks=1, type=ANCHOR
223-
start=257, blocks=16, type=PVDS
224-
start=273, blocks=1, type=LVID
225-
start=274, blocks=60626413, type=PSPACE
226-
start=60626687, blocks=1, type=ANCHOR
227-
start=60626688, blocks=239, type=USPACE
228-
start=60626927, blocks=16, type=RVDS
229-
start=60626943, blocks=1, type=ANCHOR
220+
filename=/dev/sdg
221+
label=My UDF External Drive
222+
uuid=5e4924cc17b50769
223+
blocksize=512
224+
blocks=15663104
225+
udfrev=2.01
226+
start=0, blocks=64, type=ERASE
227+
start=64, blocks=13, type=VRS
228+
start=77, blocks=19, type=ERASE
229+
start=96, blocks=16, type=MVDS
230+
start=112, blocks=16, type=ERASE
231+
start=128, blocks=16, type=LVID
232+
start=144, blocks=112, type=ERASE
233+
start=256, blocks=1, type=ANCHOR
234+
start=257, blocks=15662590, type=PSPACE
235+
start=15662847, blocks=1, type=ANCHOR
236+
start=15662848, blocks=96, type=ERASE
237+
start=15662944, blocks=16, type=RVDS
238+
start=15662960, blocks=143, type=ERASE
239+
start=15663103, blocks=1, type=ANCHOR
230240
[+] Writing fake MBR...
231241
16+0 records in
232242
16+0 records out
233-
16 bytes copied, 0.0219986 s, 0.7 kB/s
243+
16 bytes copied, 0.0037039 s, 4.3 kB/s
234244
2+0 records in
235245
2+0 records out
236-
2 bytes copied, 0.000358472 s, 5.6 kB/s
237-
[+] Successfully formatted /dev/sdg: UUID="59467176LinuxUDF" LABEL="My UDF External Drive" TYPE="udf" PTTYPE="dos"
246+
2 bytes copied, 3.7193e-05 s, 53.8 kB/s
247+
[+] Successfully formatted /dev/sdg: UUID="5e4924cc17b50769" LABEL="My UDF External Drive" TYPE="udf" PTTYPE="dos"
238248
Please disconnect/reconnect your drive now.
239249
```
240250

0 commit comments

Comments
 (0)