Partition on HFS+ external drive: “Invalid number of allocation blocks”, file system check exit code 8. Unable to repair, even in recovery mode
-
11-05-2021 - |
Question
As the title says, I'm getting the error "Invalid number of allocation blocks" on a particular HFS+ partition of an external drive. I am unable to repair, even in recovery mode.
Log results when I run Repair on drive:
Checking prerequisites
Checking the partition list
Checking the partition map size
Checking for an EFI system partition
Checking the EFI system partition’s size
Checking the EFI system partition’s file system
Checking the EFI system partition’s folder content
Checking all HFS data partition loader spaces
Volume Time Machine on disk1s4 has 1,048,576 bytes of trailing loader space and it needs 134,217,728 bytes
Problems were found with the partition map which might prevent booting
Operation successful.
Log results when I run Repair on the troubled partition:
Repairing file system.
Checking Journaled HFS Plus volume.
Invalid number of allocation blocks
The volume could not be verified completely.
File system check exit code is 8.
Updating boot support partitions for the volume as required.
File system verify or repair failed.
Operation failed…
The weird thing is that the other partitions on the drive don't have any problems.
I was looking into some solutions and found this guide but I not sure if that tutorial is applicable to my situation. I downloaded wxHexEditor and can use it if need be.
Edit:
Results of sudo gpt -r show disk1
gpt show: disk1: Suspicious MBR at sector 0
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 667388392 2 GPT part - 48465300-0000-11AA-AA11-00306543ECAC
667798032 508383336
1176181368 292707720 4 GPT part - 48465300-0000-11AA-AA11-00306543ECAC
1468889088 2048
1468891136 146485248 3 GPT part - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
1615376384 171884544
1787260928 166260736 5 GPT part - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
1953521664 3471
1953525135 32 Sec GPT table
1953525167 1 Sec GPT header
Screen cap of the partition map. The first section is just a general OS X file storage section. Then a time machine partition, then two bootcamp partitions... (long story on why there's two but I don't use either. They were just backups in case the transfer to the new drive didn't work (I could delete them if I needed to.)
The weird thing is that this is reporting that the first partition is only 342 GB. In reality it is around 690 GB [690=1000-(85+75+150)]. If you look the drive is 1 TB in total and the partition does take up a little over half the drive (the pie chart is accurate but the number is not). I just noticed this. I think it's a new problem since I've been trying to work on this. The 342 number is either how much free space there is or how much is used. I remember that is was about half full. In Paragon I was messing around becuse bootcamp creates a MBR scheme and then GUID within that (if I understand correctly) so that the MBR/NTFS can coexist with the GUID/HFS+ on the same drive. I didn't mean to mess it up though...)
Output of df
:
Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on
/dev/disk0s2 975425848 398002368 576911480 41% 1868271 4293099008 0% /
devfs 385 385 0 100% 666 0 100% /dev
map -hosts 0 0 0 100% 0 0 100% /net
map auto_home 0 0 0 100% 0 0 100% /home
localhost:/LBoQ0M7--2Q2sv3sqi-Zd2 975425848 975425848 0 100% 0 0 100% /Volumes/MobileBackups
/dev/disk1s3 146485240 140371096 6114144 96% 217662 3074418 7% /Volumes/Windows Bootcamp New
/dev/disk1s5 166260728 136275960 29984768 82% 176094 15051298 1% /Volumes/Windows Bootcamp Original (Old)
/dev/disk1s4 292707720 184526648 108181072 64% 859054 4294108225 0% /Volumes/Time Machine
/dev/disk1s2 1175509584 481193080 694316504 41% 1098583 4293868696 0% /Volumes/Macintosh HD
La solution
The GUID partition table of your external disk got hosed somehow and the partition disk1s2 probably has the wrong size: gpt reports a size of ~341 GB but df and Finder suggests that the size is 601 GB. By rewriting the GUID pt this should be solved.
- Open Terminal and enter
diskutil list
andsudo gpt -r show disk1
to get an overview Unmount disk1:
diskutil umountDisk disk1
Delete the MBR:
sudo dd if=/dev/zero of=/dev/disk1 bs=512 count=1 diskutil umountDisk disk1
Destroy the GUID partition table and create a new one (this also creates a fresh pMBR):
sudo gpt destroy disk1 sudo gpt create -f disk1
Rebuild all previous GUID partitions (except the second which will be expanded):
sudo gpt add -i 1 -b 40 -s 409600 -t C12A7328-F81F-11D2-BA4B-00A0C93EC93B disk1 sudo gpt add -i 2 -b 409640 -s 1175509584 -t 48465300-0000-11AA-AA11-00306543ECAC disk1 diskutil umountDisk disk1 sudo gpt add -i 3 -b 1176181368 -s 292707720 -t 48465300-0000-11AA-AA11-00306543ECAC disk1 diskutil umountDisk disk1 sudo gpt add -i 4 -b 1468891136 -s 146485248 -t EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 disk1 diskutil umountDisk disk1 sudo gpt add -i 5 -b 1787260928 -s 166260736 -t EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 disk1
Finally the gpt table should look like this
gpt show: disk1: Suspicious MBR at sector 0 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 1175509584 2 GPT part - 48465300-0000-11AA-AA11-00306543ECAC 1175919224 262144 1176181368 292707720 3 GPT part - 48465300-0000-11AA-AA11-00306543ECAC 1468889088 2048 1468891136 146485248 4 GPT part - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 1615376384 171884544 1787260928 166260736 5 GPT part - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 1953521664 3471 1953525135 32 Sec GPT table 1953525167 1 Sec GPT header
Adding partition 2 and 3 with these values will leave a gap of 262144 blocks between them which is a standard size for OS X (which itself is a hint that the GUID partition was wrong previously).
verify disk1s2 and disk1s3 afterwards with:
diskutil verifyVolume /dev/disk1s2 diskutil verifyVolume /dev/disk1s3
You still have about 171884544 blocks (~88 GB) of unallocated disk space between partition 4 and 5.
If you don't need the backups of the Bootcamp partition you may omit the last two sudo gpt ...
commands. You may then expand your Time Machine volume with Disk Utility to ~400 GB.
If you want to add a partition in the unallocated disk space do the following (the instructions will add a JHFS+ partition/volume):
unmount the disk
diskutil umountDisk disk1
add a new partition with gpt with some free space (2048 blocks) at the beginning and the end. You may also use the standard gap size (262144 blocks) but then you have to use a smaller partition size
... -b 1615638528 -s (171884544 - 2*262144) ...
=... -b 1615638528 -s 171360256 ...
:sudo gpt add -i 6 -b 1615378432 -s 171880448 -t 48465300-0000-11AA-AA11-00306543ECAC disk1
get the disk identifier of the new partition (88 GB)
diskutil list
format the drive:
sudo newfs_hfs -v "New" -J /dev/disk1sX #probably X=6