summaryrefslogtreecommitdiff
path: root/vimwiki/MountMacOSXDrive.md
blob: add9025afc139b736445c0882dfadbc78093aed8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Sometimes you may not be able to mount a HFS partition on linux
and you get the following error:

`mount: /mnt: wrong fs type, bad option, bad superblock on /dev/sda2, missing codepage or helper program, or other error.`

This is because the the partition is wrapped in a CoreStorage Volume. This can be verfied from the output of fdisk -l. 
In the case of this Macbook we get:

`Disk /dev/sda: 1.8 TiB, 2000398934016 bytes, 3907029168 sectors`
__Disk model: ST2000LX001-1RG1__
`Units: sectors of 1 * 512 = 512 bytes`
`Sector size (logical/physical): 512 bytes / 4096 bytes`
`I/O size (minimum/optimal): 4096 bytes / 4096 bytes`
`Disklabel type: gpt`
`Disk identifier: 26B36326-E491-4674-9795-D970A4935EAF`
``
__Device          Start        End   Sectors   Size Type__
`/dev/sda1          40     409639    409600   200M EFI System`
__/dev/sda2      409640  391021447 390611808 186.3G Apple Core storage__
`/dev/sda3   391021448  392290991   1269544 619.9M Apple boot`
`/dev/sda4   392290992  802347007 410056016 195.5G Apple HFS/HFS+`
`/dev/sda5   802347008  803586047   1239040   605M Linux filesystem`
`/dev/sda6   803586048  979429375 175843328  83.9G Linux filesystem`
``
`     ---   `

Normally HFS+ uses 2 volume headers each 1024 bytes in from the beginning and end of the volume. With 
CoreStorage wrapping however this is no longer the case, so you have to manually  specify the HFS volume 
size to fix this. To do this use the `testdisk` utility:

1. `$testdisk /dev/sda ` and select ok for the drive.
2. Select `EFI GPT` for the drive.
3. Press `Analyse` and then `Quick Search`. The output produced will be smaller than the volume given by fdisk

`TestDisk 7.0, Data Recovery Utility, April 2015`
`Christophe GRENIER <grenier@cgsecurity.org>`
`http://www.cgsecurity.org`
``
`Disk /dev/sda - 2000 GB / 1863 GiB - CHS 243201 255 63`
`     Partition               Start        End    Size in sectors`
`>P EFI System                    40     409639     409600 [EFI]`
__ P Mac HFS                   409640  390296359  389886720__
` P Mac HFS                391021448  392290991    1269544`
` P Mac HFS                392290992  802347007  410056016`
``

So now multiply the size by the sector size (389886720*512) =199622000640. This is the offset needed.

4. So can now press q several times to quit the program.
5. The disk can now be mounted as follows:
    `$ sudo mount /dev/sda2 -t hfsplus -o ro,sizelimit=199622000640 /mnt`