PDA

View Full Version : gpart utility: Can't access USB Hard Drive



ktas
09-07-2005, 02:17 AM
I have an external hard drive that plugs into my USB port. Knoppix assigns the device /dev/uba1 to it. When I try to scan the drive using the command "gpart /dev/uba1", I receive the message "*** Fatal error: ioctl(HDIO_GETGEO) failed: Inappropriate ioctl for device."

I accidentally deleted the primary NTFS partition on this drive and I'm trying to re-create it. Can gpart help me with this? What do I need to do?

Harry Kuhman
09-07-2005, 02:26 AM
.... Knoppix assigns the device /dev/uba1 to it. When I try to scan the drive using the command "gpart /dev/uba1", I receive the message "*** Fatal error.....
I havn't used gpart much and never on a usb device, but shouldn't you be scanning uba, the hard drive, and not uba1, the partition that does not exist?

ktas
09-07-2005, 02:37 AM
Well, I'm new to this, but perhaps you're right. If that's all it is, I'll be embarassed, but appreciative! I'll try that. :-)

rwcitek
09-07-2005, 08:48 PM
Well, I'm new to this, but perhaps you're right. If that's all it is, I'll be embarassed, but appreciative! I'll try that. :-)
Yup. You want the device where the partition table is stored, i.e. /dev/uba. According to the man page, yes, gpart should be able to recover the partition table even if the filesystem is NTFS. I'm curious to know how you deleted the partition and how well gpart worked to recover it. So, please let us know how it goes.

As safety net, you may want to image the entire device before you let gpart work on it. You can image the device with dd. How big is the USB device? Do you have enough space on another device to store the image?

Regards,
- Robert
http://www.cwelug.org

ktas
09-07-2005, 08:59 PM
Well, I did try using "/dev/uba" and received the same error msg. The error seems to be saying that the routine HDIO_GETGEO that the program is using is not valid for USB. The device is a 200 GB Maxtor external drive. But, at this point, I can't even perform a sucessful scan of the drive.

rwcitek
09-07-2005, 09:10 PM
Well, I did try using "/dev/uba" and received the same error msg. The error seems to be saying that the routine HDIO_GETGEO that the program is using is not valid for USB. The device is a 200 GB Maxtor external drive. But, at this point, I can't even perform a sucessful scan of the drive.
What is a "successful scan"? Are you able to read the first 512 bytes of the drive with dd? For example:

dd if=/dev/uba of=/tmp/mbr.img bs=512 count=1
BTW, if you know the NTFS partition took up the entire drive you can simply "repartition" with fdisk. Again, you may want to make an image of the drive first.

Regards,
- Robert
http://www.cwelug.org

ktas
09-07-2005, 09:20 PM
What is a "successful scan"? Are you able to read the first 512 bytes of the drive with dd? For example:

dd if=/dev/uba of=/tmp/mbr.img bs=512 count=1
BTW, if you know the NTFS partition took up the entire drive you can simply "repartition" with fdisk. Again, you may want to make an image of the drive first.

Regards,
- Robert
http://www.cwelug.org

No, I was referring to the "gpart" utility which refuses even to scan the drive. I know there was only a single NTFS partition. Repartitioning with fdisk won't lose data?

rwcitek
09-07-2005, 09:31 PM
No, I was referring to the "gpart" utility which refuses even to scan the drive. I know there was only a single NTFS partition. Repartitioning with fdisk won't lose data?
Uh, you've got a backup image, right? In that case, no, you won't lose any data. Partitioning, especially when there's only one partition involved, only modifies the first 512 bytes of data. Destroying the partition table is kind of like ripping out the table of contents from a book. The chapters are still there, you just don't know how many there are or where they are or how big they are. But if you know there was only one partition and it took the entire drive and it was NTFS, then you can recreate the partition table.

However, if you do not create a backup image first, yes, whatever you do will immediately destroy all hopes of getting any meaningful data off the drive. That rule is called "Murphy's Law" and it holds true whenever there's really important data involved. ;)

Regards,
- Robert
http://www.cwelug.org

ktas
09-07-2005, 09:36 PM
No, I was referring to the "gpart" utility which refuses even to scan the drive. I know there was only a single NTFS partition. Repartitioning with fdisk won't lose data?
Uh, you've got a backup image, right? In that case, no, you won't lose any data. Partitioning, especially when there's only one partition involved, only modifies the first 512 bytes of data. Destroying the partition table is kind of like ripping out the table of contents from a book. The chapters are still there, you just don't know how many there are or where they are or how big they are. But if you know there was only one partition and it took the entire drive and it was NTFS, then you can recreate the partition table.

However, if you do not create a backup image first, yes, whatever you do will immediately destroy all hopes of getting any meaningful data off the drive. That rule is called "Murphy's Law" and it holds true whenever there's really important data involved. ;)

Regards,
- Robert
http://www.cwelug.org Okay. Thanks so much for the help. :)

Markus
09-07-2005, 09:43 PM
You can also see if testdisk sees the partition, but like rwcitek said, the easiest way is to just fdisk a new partition AFTER taking a backup image of the disk.

ktas
09-07-2005, 09:47 PM
You can also see if testdisk sees the partition, but like rwcitek said, the easiest way is to just fdisk a new partition AFTER taking a backup image of the disk.

Got it! Thanks. :wink:

rwcitek
09-07-2005, 11:54 PM
Got it! Thanks. :wink:
"Got it!" as in "I understand" or as in "I was able to get to my data on the drive"?

Inquiring minds want to know.

Regards,
- Robert
http://www.cwelug.org

ktas
09-08-2005, 12:01 AM
Got it! Thanks. :wink:
"Got it!" as in "I understand" or as in "I was able to get to my data on the drive"?

Inquiring minds want to know.

Regards,
- Robert
http://www.cwelug.org

As in "I understand". Sorry about that. :oops:
It's probably going to be a while before I can actually sit down and try some of this out.