DANGER, WILL ROBINSON! DANGER!
Your partitioning data is suspicious, and might indicate an extremely dangerous configuration. I can't be sure of that, but if my suspicions are correct, you could easily trash the whole disk the next time you try to make any changes to the partition table -- or maybe even just in normal use.
To figure out what's going on, you need to look at the disk using my gdisk
utility. You can use it in any OS. Simply launch it on the disk, like this:
$ sudo gdisk /dev/sda
GPT fdisk (gdisk) version 1.0.0
Partition table scan:
MBR: hybrid
BSD: not present
APM: not present
GPT: present
Found valid GPT with hybrid MBR; using GPT.
Command (? for help): q
If the MBR:
line reads hybrid
, as in the example, then your disk is in an extremely dangerous state and it's imperative that you fix it immediately. If the MBR:
line reads MBR only
, then you simply have some leftover naming issues from a conversion of the disk from GPT to MBR, and nothing is really wrong. In this second case, you can ignore the rest of this answer; but if MBR:
reads hybrid
, read on....
The rest of this answer assumes that you've got a hybrid MBR with extended and logical partitions on the MBR side. This configuration is dangerous because, to the best of my knowledge, no partitioning tool supports it. Worse, logical partitions require extra data structures (called Extended Boot Records, or EBRs) that fall outside of the space allocated for the partitions they describe (but inside the extended partition), and tools that do work with hybrid MBRs don't have any way to track these partitions. This inconsistency is a recipe for disaster, since the EBRs might be moved (perhaps to inside some GPT partition that's not in the hybrid MBR) if you try to partition using MBR-only tools, and if you use GPT tools (like OS X's Disk Utility or gdisk
), you'll probably end up losing your logical partition definitions entirely.
Backing up a bit, hybrid MBRs are useful on Macs because Windows sees them as ordinary MBR disks but OS X sees them as ordinary GPT disks. This enables OS X (which boots using EFI from GPT disks) and Windows (which, on a Mac, boots in BIOS/CSM/legacy mode from MBR disks) to coexist. The biggest problem with this setup is if you use the standard Windows tools to repartition the disk; the Windows tools will adjust the MBR data structures but ignore the GPT data structures. The GPT data structures, though, are the primary ones; the MBR data structures are intended to simply mirror some of what's in the GPT for the benefit of Windows. My suspicion is that you made this mistake and created logical partitions on a hybrid MBR disk.
There are two possible solutions, depending on what else is on the disk, besides your Windows installation:
Solution 1: Windows Only
If Windows is the only OS on the disk, then the solution is (relatively) easy:
- Use an MBR-only partitioning tool to delete the type-0xEE partition from the MBR. Relatively old versions of Linux's
fdisk
are good for this task, but new versions understand GPT and so will show the GPT side, not the MBR side, of the disk. Ubuntu through at least version 14.04 ships with the old fdisk
, so you can use an Ubuntu 14.04 live image for this task. (I don't recall offhand when other distributions made the switch.)
- Launch FixParts (
fixparts
, part of the gdisk
package in most Linux distributions) on the disk. It should note the presence of leftover GPT data and ask if it should be deleted. Let it do so, then quit.
This procedure should remove the GPT data, leaving the disk as MBR-only. The computer should continue to boot into Windows, but there's always a chance that something will go wrong and you'll have to re-install your Windows boot loader, or even restore all the data if something goes badly wrong, so be prepared with Windows recovery tools and a backup.
If everything goes right, you can then install Debian in BIOS/CSM/legacy mode. When you boot the Debian installer, be sure that the /sys/firmware/efi
directory is not present. If it is, fiddle with your boot-time options to get it to boot in BIOS/CSM/legacy mode. When you install Debian in this way, it will treat the Mac like an ordinary BIOS-based PC and everything should then be fine.
Solution 2: Windows Plus OS X or Linux
If the disk currently holds OS X and/or some other Linux in addition to Windows, you'll have to consolidate your two (likely contradictory) partition tables into one consistent one. This is much harder and riskier than the preceding solution. To do it, you must:
- Figure out which partitions are valid, in both GPT and MBR.
- Windows uses MBR, so identify your Windows partitions using MBR-only tools such as the default Windows partitioning tools or older versions of Linux's
fdisk
.
- OS X and Linux both use GPT on hybrid MBR disks, so if you have OS X or Linux partitions on the disk, identify them using GPT-aware tools, such as
gdisk
or parted
.
- In all cases, record the start sector and end sector of your valid partitions. Unfortunately, a lot of tools don't provide data that's sector-precise. In Linux,
fdisk
, gdisk
, and parted
all do, although for fdisk
you must ensure you don't use "CHS mode", and for parted
, you must type unit s
to set sector mode.
- Create a consistent set of GPT partitions. This may require deleting one or more partitions for MBR partitions that no longer exist and replacing them with the valid MBR partitions you identified in the previous step. Note that if your valid MBR partitions overlap valid GPT partitions, you're already in dire trouble. In this case, you should back up everything and start from scratch, or at least triage the disk to decide which partitions to delete and restore later.
- Use
gdisk
, gptsync
, or some other tool that can create hybrid MBRs to create a fresh hybrid MBR that uses nothing but primary partitions to map the Windows partitions.
This procedure might render Windows unbootable, so you should be prepared with a Windows recovery disk. Installing Debian on your disk with a hybrid MBR might also wipe the hybrid MBR and/or render Windows unbootable, so you should be prepared to restore your hybrid MBR and/or run Windows recovery tools.
In principle, you should be able to install Debian in either BIOS/CSM/legacy or EFI boot modes. I prefer the latter for various reasons, but it's hard to get some distributions to install in this way on Macs. (I don't know offhand how the Debian installer works for this.)