Using XFCE.
Could someone please explain why the following fails (logged in as root)…
localhost:/home/ion # fdisk /dev/sdc
Welcome to fdisk (util-linux 2.39.3).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): p
Disk /dev/sdc: 465.76 GiB, 500107862016 bytes, 976773168 sectors
Disk model: TOSHIBA MQ01ABD0
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 6468A424-9088-4415-86C9-4683B0A5159F
Device Start End Sectors Size Type
/dev/sdc1 2048 206847 204800 100M EFI System
/dev/sdc2 206848 239615 32768 16M Microsoft reserved
/dev/sdc3 239616 975685296 975445681 465.1G Microsoft basic data
/dev/sdc4 975685632 976771071 1085440 530M Windows recovery environment
Command (m for help): q
localhost:/home/ion # dd if=/dev/null of=/dev/sdc bs=512 status=progress
0+0 records in
0+0 records out
0 bytes copied, 9.503e-05 s, 0.0 kB/s
localhost:/home/ion #
I still remember you made the same mistake some years ago.
/dev/null does point to what is colloquially called “a black hole”. Which means that all that is put into it will vanish (gone, never be seen again, …) and nothing can come out of it. That last means that when a read is done, a EOF (end of file) indication is given. Because there is nothing. No bytes whatsoever.
You probaly want to copy bytes of value x'00' and there is a source for that. It is /dev/zero.
A language barrier? “zero” is not the same as “null”.
Yes thank you that worked. Now I thought /dev/null represented 0 Hex as opposed to zero, 30 Hex and I didn’t quite understand hcvv’s explanation. Is he saying that nulls can’t be written to a drive? I don’t think it matters what character I use to wipe the drive, I’m just curious.
Which is absolutely irrelevant. This is not about some metaphysical concept or definition in a human language. The /dev/null is the device (file) which returns EOF (end of file) for every read. Period. That it happens to coincide with your interpretation of the English word null does not add anything to how this device is defined and implemented in UNIX.
Inferring the functionality of a program from its similarity to some human language words is fallacy. Creating a device /dev/foobar with the same device number will provide the same functionality even though its name does not include null.
Technically, for every megabyte of data swallowed by /dev/null a tiny stream of Hawking radiation is released by /dev/urandom. This can be observed for example with careful use of head --bytes=1 /dev/urandom | xxd -b | cut -d' ' -f2
I guess you left that out for pedagogical purposes.
Data written to the /dev/null and /dev/zero special files is discarded.
Reads from /dev/null always return end of file (i.e., read(2) returns 0), whereas reads from /dev/zero always
return bytes containing zero ('\0' characters).
Personally, when I want to re-initialise an old disk – make it appear to be “empty” – I use the following:
Occasionally, I increase the value of the ‘count’ parameter.
If the disk is so old that it has to be recycled, I open it, dismantle the rotating parts and, physically destroy them and then, I take the electronic bits and pieces to the recycling point …
I haven’t yet decided what I’ll do when an SSD needs to be passed on to the recycling facilities – possibly overheat it with a welding-torch before getting rid of it …