You are not logged in.

#1 2010-06-24 23:16:29

yawns
Member
Registered: 2010-05-31
Posts: 68

[solved] Can't format (or I destroyed) a disk

I have a USB hard disk that had three NTFS partitions on it. The drive was working fine before I started messing with it. I would turn it on, it would auto-mount, and I could read/write to/from it.

I'm trying to format the disk, but it's not cooperating. Initially I attempted to use gparted (sudo gparted /dev/sdg), but it hung on, "scanning all devices." I read that gparted sometimes hangs on NTFS partitions. Since I didn't want them anyway, I deleted them all using fdisk:

sudo fdisk /dev/sdg

Then did d, 1, d, 2, d, 3, w. fdisk said, "Partition table has been altered!" or whatever it says when it's doing its thing. Except it sat there for about 10 minutes and never finished/exited. I couldn't get it to exit (ctrl-c, esc, q...) and had to close the terminal.

After that, sudo fdisk -l /dev/sdg showed no partitions. So it seemed like fdisk had been successful despite hanging. However, gparted still couldn't get past scanning, and (oddly?) sudo fdisk -l /dev/sdg1 still showed an ntfs partition taking up the entire disk. That was strange to me because there were three NTFS partitions on the disk previously. Shouldn't sdg1 be a partition, and not have partitions? Particularly when sdg showed no partitions at all? As far as I know, there were no extended partitions on here.

Anyway, I did sudo fdisk -l /dev/sdg1 and deleted the NTFS partition. Again, fdisk hung after, "Altering table!" and I had to close the terminal. But again the changes did seem to take effect. Now if i fdisk -l on either sdg or sdg1, it prints an empty partition table. Gparted still can't read the disk. I can create partitions using fdisk on either sdg or sdg1, but the drive won't mount. (No errors, I just turn it off and back on, and nothing happens.) Every time I write a change to the disk, fdisk hangs and I need to close the terminal.

I feel like the problem is the partition table(?) on sdg1. Shouldn't the result of fdisk -l on sdg1 be, "No partition table found?" Is there anything I can do to just, like, reset the whole disk so I can get it open in gparted? Or did I kill it when I exited fdisk?

Last edited by yawns (2010-06-25 21:33:50)

Offline

#2 2010-06-24 23:23:18

tavianator
Member
From: Waterloo, ON, Canada
Registered: 2007-08-21
Posts: 858
Website

Re: [solved] Can't format (or I destroyed) a disk

/dev/sdg1 is the first partition of the device; that it exists at all means that the kernel wasn't informed that the partition table changed.  This is likely the step at which fdisk hung.  You can try to do this manually with the partprobe command.  If that hangs, I'm not sure what else to do except for unplugging and replugging the disk, and failing in that, rebooting.  Also, check dmesg for anything interesting.

EDIT: Also, weird stuff will happen if any of those partitions were mounted before you started messing with the partition table, so make sure to unmount everything relating to that disk.

Last edited by tavianator (2010-06-24 23:24:25)

Offline

#3 2010-06-25 00:03:49

yawns
Member
Registered: 2010-05-31
Posts: 68

Re: [solved] Can't format (or I destroyed) a disk

Hi, thanks for the reply. The disk wasn't mounted when I was messing with it. I tried doing partprobe and got, "Error: Partition(s) 1 on /dev/sdg have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use.  As a result, the old partition(s) will remain in use.  You should reboot now before making further changes." I'm not sure why it thinks they're in use. There's nothing in my dmesg log. IN nay case, I can't reboot at the moment, so I'll have to try later.

Offline

#4 2010-06-25 15:53:18

tavianator
Member
From: Waterloo, ON, Canada
Registered: 2007-08-21
Posts: 858
Website

Re: [solved] Can't format (or I destroyed) a disk

It's possible that fdisk or gparted is still running, possibly in a hung state (D state), which indicates a kernel bug, hardware problem, or random intermittent failure.  Check ps aux to see if those processes are still running.

Offline

Board footer

Powered by FluxBB