I got a partition that is probably created by dd, and is about 200MB on a 4GB USB stick. I am failing to delete it using GParted (the option is greyed on the right-click menu).
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
Open a terminal
steve@mcr-pc-29334:~$ sudo fdisk /dev/sdb WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): d Selected partition 1 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks. steve@mcr-pc-29334:~$
so sudo fdisk /dev/sdb
then press d
to delete the partition if its the only one there it will auto select otherwise it will prompt for partition number
then press w to write the changes to the disk
Sorry if this answer is too generic, but it applies to situations where partitions just won't delete - by deleting the partition table. You might need this for those NTFS volumes that are locked or corrupted for example, or when MBR, VBR etc are corrupt or locking the filesystem.
This will destroy all* data so backup first. In Ubuntu close GParted and unmount the volume if possible, then type:
sudo dd if=/dev/zero of=/dev/[drive name] bs=512 count=4 status=progress
where: [drive name] including brackets is the name of the drive that is locked, bs=block size in bytes; count=number of blocks to overwrite. I only needed 4 blocks i.e. 2048 bytes in my case, you might need more; status=progress is optional and displays progress of dd.
After I did this, the drive looked unformatted in gparted and I was able to create a partition table and new partitions.
*The remaining data will still be lingering on the drive though so you could write over the entire drive with zeros or /dev/urandom if you need to.
This situation arose for me because I'd been given a usb memory stick which claimed to be 16GB capacity but was actually 4GB and wasted much time backing up files, as it would corrupt anything stored past 4GB. See F3probe https://askubuntu.com/questions/737473/check-real-size-of-usb-thumb-drive