hello world, meet gpt-surgeon

gpt-surgeon has a new home on Launchpad! Look for it at https://launchpad.net/gpt-surgeon. Downloads compliant with the Launchpad release scheme (GPG-signed tarball) available here: https://launchpad.net/gpt-surgeon/+download

I’ve decided to go with GPLv2 as the licensing scheme, no copyright assignment required, to keep this simple utility open and available to the public with a minimum of hassle and a maximum of fresh code.

gpt-surgeon will still be available here on Bat Country for a time, but fresh development and new versions will be on the Launchpad site. This version will be frozen as soon as the Launchpad version is available.

Tagged , , , , , , ,

10 thoughts on “hello world, meet gpt-surgeon

  1. […] update: gpt-surgeon is opening up! Thanks to all who submitted usage reports, suggestions, failure data, and proposed patches. I hope […]

  2. Jeremy says:

    Might be a day or two more. The automatic import process for SVN is … insufficiently automatic. Gonna dump the head revision and drop that into a new BZR branch on Launchpad – hey, it’s only one file.

  3. Ryan says:

    I’m about to test this out on a disk that just came up with this problem out of nowhere yesterday.

    I hope it works! Thanks for taking the time to make it.

  4. Tom says:

    I had this exact same problem come up today… from one of your earlier posts I saw it may be caused by assigning the mac drive/partition a new drive letter or in my case I removed the drive letter to keep it from showing up in Windows. Unfortunately now my Mac partition is no longer capable of being booted and I get the invalid BS_jmpBoot error when running disk repair. I hope to use your tool to fix this issue. Any suggestions are appreciated :)

    The strange thing is I had removed Mac partitions in the past without this problem coming up.

  5. Tom says:

    By the way, is there any way of running your tool from Windows?

    • Jeremy says:

      Not directly: accessing the raw disk from Python is much harder under Windows than Mac OS X or Linux. However, there’s a way around that: use the Chrysocome Windows port of dd to copy out the first few blocks of the disk to a file, edit them using gpt-surgeon on the file instead of the disk, and then copy them back. The first block on the disk is the protective MBR, the second is the actual GPT, and then every four partitions on the disk comprise another block, so you’ll need to copy 3 blocks, or more if you have a lot of partitions. It might go something like this (I can’t test this on my current system because I don’t have a Mac, so proceed with caution):

      Install Chrysocome dd and Python 2.7
      Open a command window as administrator
      Show your Windows disk devices:
      dd –list
      Copy the first 3 512-byte blocks of the whole disk (Partition0) to a file gpt.dd:
      dd if=\\?\Device\Harddisk5\Partition0 of=gpt.dd count=3
      Use gpt-surgeon to see if the partitions look right:
      python gpt-surgeon.py list gpt.dd
      Fix the partition table in the file, assuming your Mac partition is partition 2:
      python gpt-surgeon.py repair gpt.dd 2
      Copy the fixed partition table back (note if and of arguments to dd are swapped now):
      dd if=gpt.dd of=\\?\Device\Harddisk5\Partition0 count=3
      Reboot, see if it worked. Good luck.

      • Tom says:

        Thanks for the help… however, I used the SystemRescueCD and Test Disk on it to fix the problem. What a relief to see it working again :)

  6. Cas Smith says:

    Is there a way to change from dos fat 16 to HFS?

    0: FDisk_partition_scheme *1.0 TB disk1
    1: DOS_FAT_16 1.0 TB disk1s1

    I tried to copy jpegs from a windows machine to my external and now I can’t access anything from my external. My wife is going to kill me!

    • Cas Smith says:

      This is the error I get when I try and run the script.

      Traceback (most recent call last):
      File “./gpt_surgeon2.py”, line 216, in
      File “./gpt_surgeon2.py”, line 202, in main
      File “./gpt_surgeon2.py”, line 140, in listGPT
      _, gpt = readMBRAndGPT(diskDevice)
      File “./gpt_surgeon2.py”, line 134, in readMBRAndGPT
      gpt = EFIPartitionTable(disk)
      File “./gpt_surgeon2.py”, line 50, in __init__
      assert sig == efiSignature

      • Jeremy says:

        Cas: I’m not sure what happened here, but it looks like your entire GPT is trashed, since the partition table signature is invalid and FAT16 partitions can’t be that big. gpt_surgeon can’t fix this – it’s designed to repair a valid GPT.

Comments are closed.

%d bloggers like this: