On 10/10/2023 9:38 PM, bilsch01 wrote:
On 10/10/2023 6:27 PM, bilsch01 wrote:
I have a 8GB thumb drive that used to be a ubuntu installer. In the middle of the space there is some tiny system partition - for some reason. I want to wipe the whole drive and start out new. Windows wont format it. GPARTED won't delete the
partitions. I don't care about what this drive is all about.
Can somebody please tell me a dd copy command line that will zero-fill this drive?
Thanks for your help. Bill S.
Windows wont format the drive because it says it's read only, however DISKPART tells me it's not read only. Can't I just zero fill it and start over?
It's possible Windows has a bit more overhead for disk
management, than Linux. In the sense of this in Windows:
Administrator window
diskpart.exe
list disk
select disk 1 # assumes disk 0 is boot drive, disk 1 is USB stick
detail disk # Dump detail of device at whole-disk level
Sandisk Cruise <=== device model number
Status : Online
...
Current Read-only State : No <=== examine this variable (logical device state)
Read-only : No <=== this might be the write protect switch, if present
attributes disk clear readonly <=== Change the State from Yes to No
detail disk <=== Verify the attempt succeeded
exit
More examples here.
Sites like this, write these articles, as part of their advertising campaign.
https://www.diskpart.com/articles/usb-drive-read-only-7201.html
*******
On Linux, these are the first commands you want to reach for.
I use gdisk first, because it tells me whether I need to use fdisk or not.
sudo gdisk /dev/sdb # This is the new utility. Advantage of this one
# is that it can tell you whether the device is MSDOS
# or GPT. If it is GPT, there is a cleaning procedure.
sudo fdisk /dev/sdb # Assumes sda is boot drive, sdb is USB stick
When you enter gdisk, it has four status lines at the top, for the named device.
GPT is one of the fields there.
If the device is GPT partitioned, it has an MBR plus primary GPT table (near origin)
plus secondary GPT table (near end).
If the device is MSDOS partitioned, it should only have the MBR at sector 0 having data.
Sometimes you have to remove the GPT tables anyway.
Enter the letter "x" as the command, which stands for Expert Mode.
Enter the letter "z" as the command, which zaps GPT info. You can remove the MBR too.
I can't remember if "w" and "q" are needed at this point, or only "q" is enough.
You can re-enter the utility, and double-check whether the command worked. Perhaps pulling the stick out, and plugging it back in, will cause
the machine to re-evaluate the metadata, before you do another sudo gdisk /dev/sdb
*******
Windows will not always be happy at this point.
If you use
sudo fdisk /dev/sdb
you can create an MBR and add one partition.
If you add one partition, make it a portion of the drive, not the whole drive. On a 16GB stick, I would create an 8GB partition, just ONE partition.
While Windows latest, claims to support multiple partitions on USB sticks,
I'm not convinced this is a safe assumption at present.
Doing a "w" and a "q" at this point, writes the new info into sector 0 of the USB stick.
Just because you set the new partition to NTFS 0x07, does not mean it is formatted.
You can format it in GParted if you want. Usually, the Windows utility you use, will "sniff" the fully functional NTFS partition you offer, and... just overwrite it.
Don't take it personally when this happens. It's all part of the ceremonies.
sudo gparted /dev/sdb # gparted is a *different* utility than gdisk
# We are formatting, solely to keep some stupid status subroutine happy.
# Otherwise, this is a waste of time, if the SW worked right.
*******
In general, for cheesy TLC USB sticks, it is NOT advised to do the following. This is a hardware issue, and nothing to do with the Linux we are using
at the moment.
sudo dd if=/dev/zero of=/dev/sdb bs=8192 # This will thoroughly erase a rotating HDD.
# Do not use this on USB flash sticks. The
# TLC ones are quite write sensitive.
Say we had researched the layout of GPT disks, and we knew precisely where the metadata was.
First, we check our understanding of the size syntax.
dd if=/dev/zero bs=1M count=3 | wc -c # Count the characters on stdout, to verify write amount
dd if=/dev/zero bs=1M count=3 | wc -c
3+0 records in
3+0 records out
3145728
3145728 bytes (3.1 MB, 3.0 MiB)... <=== 3*1024*1024
To actually overwrite the first 3MB, we'd do
sudo dd if=/dev/zero of=/dev/sdb bs=1M count=3 # Assumes /dev/sdb is the USB stick
If instead, I do this, the entire USB flash device is erased. Use a bs of at least 16384
or there will be additional (unnecessary) wear on the USB flash. 16384 is a typical page
size on the flash.
sudo dd if=/dev/zero of=/dev/sdb bs=16384 # This writes until device is full
# The status will tell you "no space left on device"
# This is a last resort for TLC USB flash sticks.
# It can be pretty slow.
*******
Windows has a third-party dd utility.
The namespace is different.
In administrator window,
dd.exe --list # This helps you pick names for the target device.
For more details:
http://www.chrysocome.net/dd
http://www.chrysocome.net/downloads/dd-0.6beta3.zip
This Windows utility has its own share of quirks.
Paul
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)