Меню Закрыть

После обновления до OS X Yosemite не доступен раздел с Windows

OS X Yosemite

У меня дома стоит iMac. Отличная машина, всё здорово, однако с OS X (изначально стоял Lion) я так и не подружился. Поэтому через неделю после покупки я поставил через BootCamp второй раздел с Windows 7 и успешно работаю именно с ней. Вместе с тем, я регулярно обновляю обе системы — и Windows, и OS X.

И вот неделю назад решил я обновиться до самой последней супер-пупер системы OS X Yosemite. Обновление прошло успешно, НО!

Такой подлянки я не ожидал. Windows больше не грузился — Missing Operating System.

Как оказалось, в процессе обновления макось побила раздел BootCamp, а именно, изменились сектора раздела, и , как следствие, слетела таблица NTFS.

Путь восстановления был не то чтобы труден, но долог.

Не торопитесь обновляться до OS X Yosemite если у вас стоит второй системой Windows!

Итак, для восстановления требуется:

  1. Проверить таблицу разделов
  2.  Проверить заголовки раздела NTFS
  3. Найти «правильные» позиции секторов начала и окончания раздела
  4. Внести изменения в таблицу GPT
  5. Прописать заново гибридный MBR
  6. Исправить загрузочную запись Windows

Поехали.

Посмотрим список дисков и выберем нужный нам (как правило disk0, в моей случае, так как еще стоит SSD — disk)

sudo diskutil list

diskutil cs list

sudo gpt -vv -r show /dev/disk1

sudo fdisk /dev/disk0

Сначала посмотрим заголовок раздела:

Sudo dd if=/dev/rdisk1s4 count=1 2>/dev/null | hexdump -C

00000000 eb 52 90 4e 54 46 53 20 20 20 20 00 02 08 00 00 |.R.NTFS    .....|
00000010 00 00 00 00 00 f8 00 00 3f 00 ff 00 00 d0 f2 22 |........?......"|
00000020 00 00 00 00 80 00 80 00 ff ef b5 17 00 00 00 00 |................|
00000030 00 00 0c 00 00 00 00 00 02 00 00 00 00 00 00 00 |................|
00000040 f6 00 00 00 01 00 00 00 0d d7 7d 28 ff 7d 28 5e |..........}(.}(^|
00000050 24 50 c4 2b fa 33 c0 8e d0 bc 00 7c fb 68 c0 07 |$P.+.3.....|.h..|
00000060 1f 1e 68 66 00 cb 88 16 0e 00 66 81 3e 03 00 4e |..hf......f.>..N|
00000070 54 46 53 75 15 b4 41 bb aa 55 cd 13 72 0c 81 fb |TFSu..A..U..r...|
00000080 55 aa 75 06 f7 c1 01 00 75 03 e9 dd 00 1e 83 ec |U.u.....u.......|
00000090 18 68 1a 00 b4 48 8a 16 0e 00 8b f4 16 1f cd 13 |.h...H..........|
000000a0 9f 83 c4 18 9e 58 1f 72 e1 3b 06 0b 00 75 db a3 |.....X.r.;...u..|
000000b0 0f 00 c1 2e 0f 00 04 1e 5a 33 db b9 00 20 2b c8 |........Z3... +.|
000000c0 66 ff 06 11 00 03 16 0f 00 8e c2 ff 06 16 00 e8 |f...............|
000000d0 4b 00 2b c8 77 ef b8 00 bb cd 1a 66 23 c0 75 2d |K.+.w......f#.u-|
000000e0 66 81 fb 54 43 50 41 75 24 81 f9 02 01 72 1e 16 |f..TCPAu$....r..|
000000f0 68 07 bb 16 68 70 0e 16 68 09 00 66 53 66 53 66 |h...hp..h..fSfSf|
00000100 55 16 16 16 68 b8 01 66 61 0e 07 cd 1a 33 c0 bf |U...h..fa....3..|
00000110 28 10 b9 d8 0f fc f3 aa e9 5f 01 90 90 66 60 1e |(........_...f`.|
00000120 06 66 a1 11 00 66 03 06 1c 00 1e 66 68 00 00 00 |.f...f.....fh...|
00000130 00 66 50 06 53 68 01 00 68 10 00 b4 42 8a 16 0e |.fP.Sh..h...B...|
00000140 00 16 1f 8b f4 cd 13 66 59 5b 5a 66 59 66 59 1f |.......fY[ZfYfY.|
00000150 0f 82 16 00 66 ff 06 11 00 03 16 0f 00 8e c2 ff |....f...........|
00000160 0e 16 00 75 bc 07 1f 66 61 c3 a0 f8 01 e8 09 00 |...u...fa.......|
00000170 a0 fb 01 e8 03 00 f4 eb fd b4 01 8b f0 ac 3c 00 |..............<.|
00000180 74 09 b4 0e bb 07 00 cd 10 eb f2 c3 0d 0a 41 20 |t.............A |
00000190 64 69 73 6b 20 72 65 61 64 20 65 72 72 6f 72 20 |disk read error |
000001a0 6f 63 63 75 72 72 65 64 00 0d 0a 42 4f 4f 54 4d |occurred...BOOTM|
000001b0 47 52 20 69 73 20 6d 69 73 73 69 6e 67 00 0d 0a |GR is missing...|
000001c0 42 4f 4f 54 4d 47 52 20 69 73 20 63 6f 6d 70 72 |BOOTMGR is compr|
000001d0 65 73 73 65 64 00 0d 0a 50 72 65 73 73 20 43 74 |essed...Press Ct|
000001e0 72 6c 2b 41 6c 74 2b 44 65 6c 20 74 6f 20 72 65 |rl+Alt+Del to re|
000001f0 73 74 61 72 74 0d 0a 00 8c a9 be d6 00 00 55 aa |start.........U.|
00000200

Если раздел начинается с .R.NTFS значит скорее всего всё закончится хорошо 🙂 Если нет — потеряется скорее всего еще и предыдущий раздел на диске.

Затем посмотрим таблицу разделов, пусть и не правильную:
sudo gpt -vv -r show /dev/disk1

#1425153851 Disk /dev/rdisk1 - 1000 GB / 931 GiB - 1953525168 sectors (RO)

1 : start=       40, size=   409600, Id=00, P
2 : start=   409640, size=584658448, Id=00, P
3 : start=585068088, size= 1269536, Id=00, P
4 : start=586338304, size=295399424, Id=00, P

Number Start (sector)   End (sector) Size       Code Name

   1             40         409639   200.0 MiB   EF00 EFI system partition
   2         409640       585068087   278.8 GiB   AF00 Customer
   3       585068088       586337623   619.9 MiB   AB00 Recovery HD
   4       586338304       881737727   140.9 GiB   0700 WINDOWS

Наш раздел Windows есть, но с некорректным размером. У меня был больше 200 Gb.

Далее нам понадобится программа TestDisk, она позволит найти правильные сектора раздела. Скачать.

Запускаем:

sudo ./testdisk /dev/rdisk1

Скриншот 2015-03-04 01.42.56Скриншот 2015-03-04 01.43.07Скриншот 2015-03-04 01.42.13Скриншот 2015-03-04 01.43.17Скриншот 2015-03-04 01.43.33Скриншот 2015-03-04 01.43.42

Сканирование выполняется долго, у меня диск на 1Tb шел 20 часов.

Зато в итоге мы видим все правильные разделы NTFS. Нужно выбрать ближайший по начальному сектору предыдущего раздела (2) и приблизительно совпадающий по размеру. Нажав клавишу «P», можно посмотреть содержимое диска. Если в выбранной записи раздела присутствует папка System Volume Information, скорее всего это как раз тот раздел то нам нужен. Запишем значения его начального сектора и размера.

TestDisk 7.0-WIP, Data Recovery Utility, January 2015

Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org
Disk /dev/rdisk1 - 1000 GB / 931 GiB - 1953525168 sectors (RO)

     Partition               Start       End   Size in sectors

>P EFI System                   40     409639     409600 [EFI]
D Mac HFS                   409640 585068087 584658448
D MS Data               137919681 1505105088 1367185408
D Mac HFS               140592925 1461510965 1320918041
D MS Data               188538881 586338304 397799424
D Mac HFS               585068088 586337623   1269536
D MS Data               586338304 984137727 397799424
D MS Data               586338304 1334859775 748521472
D MS Data               586338304 1425430527 839092224
D MS Data               586338304 1499174911 912836608
P Mac HFS               1533447453 1619224590   85777138
P Mac HFS               1837919620 1942777219 104857600
P Mac HFS               1952255592 1953525127   1269536

В моём случае это
D MS Data               586338304 1334859775 748521472

Он начинается почти сразу с небольшим положительным смещением за диском восстановления OS X (как мы видели в таблице разделов, предыдущий диск 3 заканчивается на секторе 586337623) и похож по размеру (208 Gb)

Посмотрим что у нас с таблицей GPT:

iMac-Ivan:testdisk-7.0-WIP kvasnikov$ sudo gpt -vv show /dev/disk1
gpt show: /dev/disk1: mediasize=1000204886016; sectorsize=512; blocks=1953525168
gpt show: /dev/disk1: Suspicious MBR at sector 0
gpt show: /dev/disk1: Pri GPT at sector 1
gpt show: /dev/disk1: Sec GPT at sector 1953525167
       start        size  index  contents
           0           1         MBR
           1           1         Pri GPT header
           2          32         Pri GPT table
          34           6         
          40      409600      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
      409640   584658448      2  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
   585068088     1269536      3  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
   586337624         680         
   586338304   295399423      4  GPT part - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
   881737727  1071787408         
  1953525135          32         Sec GPT table
  1953525167           1         Sec GPT header

Далее начинаем шаманить. Нам нужно удалить некорректный раздел и вписать правильные значения, полученные с помощью TestDisk’a.

Для этого потребуется программа gdisk. Скачать.

iMac-Ivan:testdisk-7.0-WIP kvasnikov$ sudo gdisk /dev/rdisk1

GPT fdisk (gdisk) version 0.8.10

Warning: Devices opened with shared lock will not have their
partition table automatically reloaded!
Partition table scan:

MBR: hybrid
BSD: not present
APM: not present
GPT: present

Found valid GPT with hybrid MBR; using GPT.

Command (? for help): P

Disk /dev/rdisk1: 1953525168 sectors, 931.5 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 00002EDC-7E62-0000-6162-00005A2B0000
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 1953525134
Partitions will be aligned on 8-sector boundaries
Total free space is 1071788094 sectors (511.1 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name

1              40          409639   200.0 MiB   EF00  EFI system partition
2          409640       585068087   278.8 GiB   AF00  Customer
3       585068088       586337623   619.9 MiB   AB00  Recovery HD
4       586338304       881737726   140.9 GiB   0700  Microsoft basic data

Command (? for help): D

Partition number (1-4): 4

Command (? for help): N

Partition number (4-128, default 4): 4

First sector (34-1953525134, default = 586337624) or {+-}size{KMGTP}: 586338304

Last sector (586338304-1953525134, default = 1953525134) or {+-}size{KMGTP}: +397799424

Current type is 'Apple HFS/HFS+'
Hex code or GUID (L to show codes, Enter = AF00): 0700

Changed type of partition to 'Microsoft basic data'

Command (? for help): P

Disk /dev/rdisk1: 1953525168 sectors, 931.5 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 00002EDC-7E62-0000-6162-00005A2B0000
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 1953525134
Partitions will be aligned on 8-sector boundaries
Total free space is 969388093 sectors (462.2 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name

1              40          409639   200.0 MiB   EF00  EFI system partition
2          409640       585068087   278.8 GiB   AF00  Customer
3       585068088       586337623   619.9 MiB   AB00  Recovery HD
4       586338304       984137727   189.7 GiB   0700  Microsoft basic data

Command (? for help): W

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING

PARTITIONS!!

Do you want to proceed? (Y/N): Y

OK; writing new GUID partition table (GPT) to /dev/rdisk1.
Warning: Devices opened with shared lock will not have their
partition table automatically reloaded!
Warning: The kernel may continue to use old or deleted partitions.
You should reboot or remove the drive.
The operation has completed successfully.

Теперь необходимо восстановить гибридный MBR:

iMac-Ivan:testdisk-7.0-WIP kvasnikov$ sudo gdisk /dev/rdisk1
GPT fdisk (gdisk) version 0.8.10

Warning: Devices opened with shared lock will not have their
partition table automatically reloaded!
Partition table scan:
  MBR: hybrid
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with hybrid MBR; using GPT.

Command (? for help): P
Disk /dev/rdisk1: 1953525168 sectors, 931.5 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 00002EDC-7E62-0000-6162-00005A2B0000
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 1953525134
Partitions will be aligned on 8-sector boundaries
Total free space is 969388093 sectors (462.2 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              40          409639   200.0 MiB   EF00  EFI system partition
   2          409640       585068087   278.8 GiB   AF00  Customer
   3       585068088       586337623   619.9 MiB   AB00  Recovery HD
   4       586338304       984137727   189.7 GiB   0700  Microsoft basic data

Command (? for help): R    

Recovery/transformation command (? for help): H

WARNING! Hybrid MBRs are flaky and dangerous! If you decide not to use one,
just hit the Enter key at the below prompt and your MBR partition table will
be untouched.

Type from one to three GPT partition numbers, separated by spaces, to be
added to the hybrid MBR, in sequence: 2 3 4
Place EFI GPT (0xEE) partition first in MBR (good for GRUB)? (Y/N): Y

Creating entry for GPT partition #2 (MBR partition #2)
Enter an MBR hex code (default AF): 
Set the bootable flag? (Y/N): N

Creating entry for GPT partition #3 (MBR partition #3)
Enter an MBR hex code (default AB): 
Set the bootable flag? (Y/N): N

Creating entry for GPT partition #4 (MBR partition #4)
Enter an MBR hex code (default 07): 
Set the bootable flag? (Y/N): Y

Recovery/transformation command (? for help): W

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/rdisk1.
Warning: Devices opened with shared lock will not have their
partition table automatically reloaded!
Warning: The kernel may continue to use old or deleted partitions.
You should reboot or remove the drive.
The operation has completed successfully.

Перезагружается. Теперь диск с Windows должен снова стать доступен в OS X.

Ну и осталось только загрузиться с загрузочного диска Windows и выполнить восстановление загрузочной записи:

c:
bootrec /fixmbr
bootrec /fix boot
Operation completed succesfully.

или bootrec.exe /rebuildBCD

Почитать об этом подробно можно в статье Microsoft

Всем успехов!

1 комментарий

  1. nervasystem

    Спасибо за статью, но таки работать на маке под виндой это абсолютное извращение 🙂

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *