Daddy Clanger (imc) wrote,
Daddy Clanger

GNU parted 0 – imc 1 (Windows minus 100)

There was once this dual boot computer with 1 Boot Magic partition, 4 Windows partitions and 8 Linux partitions. I seem to remember it started life as one of a batch of ten machines I was asked to install Linux on, and the user whined so much that we eventually agreed to shift everything along and install Windows, which for some reason was rather more tricky than normal as GNU parted didn't want to play ball (in retrospect, probably because of the extended attributes used for SELinux). Then at some point the entire system had been disk-to-disk copied into a brand new machine. I mention this because it goes some way to explain the slightly strange state of the disk.

Anyway, the user noticed that less than 80GB of a 160GB disk was being used, and asked for some free space to be made available, which was fair enough. M'colleague tried to do it with Partition Magic, but for some reason failed and called me. It turned out he had managed to extend the "extended" partition (the one that contains all partitions except the first three), so it was a trivial matter with fdisk. (If I'd had to extend it myself it might have been a difficult matter, since GNU parted wouldn't even start up and I didn't fancy having to re-enter all the logical partitions after deleting and recreating the extended partition.)

I called m'colleague back to format the new 80GB partition as NTFS under Windows. I have a good excuse for not doing any sysadmin under Windows: I don't know the administrative password. This he did with no problem. Then, looking at the little drive-map diagram on the Windows disk manager, he noticed that there was about 10GB of unallocated space in the middle of the disk. So he told Windows to format it, and it put up some uninformative message of the form "an error occurred". Then, *poof* — as if by magic, all except five partitions disappeared from the drive map. (In retrospect, it was never going to be possible to have another disk partition since the disk was up to fifteen already, and that's the most you can have.)

As luck would have it, parted would now start up, but it confirmed there were indeed only five partitions on the disk. Parted has a "rescue" command which looks for a lost partition given an approximate start and end point, so I tried it. It said it was going to take an hour, so I went for lunch. When I came back an hour later, it hadn't found anything. I tried to rescue a different partition, and it said it would take another hour.

While it was doing that, I wrote a quick-and-dirty script (at the bash prompt) to print out the first few bytes of the second head of each cylinder on the disk. By the time parted finished searching and had failed to find anything, I had written down the starting cylinder of every original partition on the disk (plus a couple of false positives in the unallocated area of the disk). A bit of laborious data-entry into "fdisk -u", and the disk was back to the way it started.

But I shouldn't have had to do it by hand. A tool like parted could have done what I did in seconds instead of in the hour I took.

  • Post a new comment


    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.