Does “gpt remove” command delete files along with partition? Trying to recover a Mac OS partition Vol Type FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF

apple.stackexchange https://apple.stackexchange.com/questions/412214

Question

I have a Macbook Pro with Big Sur on it, and I installed Linux Mint. I then resized the encrypted Mac OS APFS partition in order to grant Linux more space. After that I created another smaller Linux partition out of that new, smaller partition.

But now I've lost my "Macintosh HD" boot option in Boot Camp and can no longer boot into Mac OS, only Linux. And my Mac OS APFS partition now says it has a Startup Volume Type of "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF" (instead of the proper GUID).

My situation is almost identical to this question:

I followed the instructions provided in that answer, but when I got to the step to run the "gpt remove" command (gpt remove -i 2 disk0), I stopped, worried that it might delete my files on that Mac OS APFS partition along with the partition.

Some of the posts I've read with similar solutions (the link above, as well as https://discussions.apple.com/thread/251412540 and OS volume shows as type 'FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFF' after attempting to delete some Linux partitions—cannot log in and How to fix broken GPT, GUID and unmountable, no type volumes?) all seem to suggest that they got their files back, but I just want to confirm that my files won't be deleted when I run the "gpt remove..." command.

Is this the case? Will gpt remove -i 2 disk0 delete my files when it removes that partition, or is it doing something slightly different (ie. removing partition info / header / metadata, etc)?

Hopefully this makes sense. I hope to be able to retain access to file files on that Mac OS APFS partition since it isn't backed up.

Please help!

Was it helpful?

Solution

The man page for the gpt clearly states the gpt remove command does the following.

Partitions are removed by clearing the partition type. No other information is changed.

In other words, the partition type is change to 00000000-0000-0000-0000-000000000000.

Although, a change in a partition type will also cause the 3 CRC32 values to change in 4 places in the GPT.

The “gpt remove” command does not delete files along with partition. In other words, the volume stored in the partition remains unchanged by the the command. Therefore, your files will not be deleted when your run the "gpt remove..." command. Entering gpt remove -i 2 disk0 will not delete your files when it removes that partition. The command does not removing any partition info / header / metadata, etc.

How the GPT Uses CRC32 Values

A 32 bit cyclic redundancy check (CRC32) computation is done by passing data through an algorithm that produces a 32 bit integer. The algorithm is designed to have a high probability of detecting any corruption that may exist in the data. This is accomplished by computing and storing the CRC32 value when the data can be assumed to be free of corruption. Later, if the data is run through the same algorithm and returns the same value, then the data is assumed to be error free.

The algorithm to compute CRC32 values for the GPT is the same as used by the command cksum -o 3. More information on this algorithm can be found in the man page for cksum. The man page can be viewed by entering the command given below.

man cksum

The GUID Partition Table (GPT) scheme consists of a header and table stored at the beginning and end of a drive. Each header contains offsets indicating where the other header resides. Therefore, both headers can not contain exactly the same values. On the other hand, the table stored at the beginning is exactly the same as the table stored at the end. After any desired changes are made to the GPT, new CRC32 values need to be computed for the tables and headers. Since the tables are identical, a new CRC32 value only needs to be computed for one table, however this value is stored in both headers. Since the headers are different, a new CRC32 value needs to be computed and stored for each header. Here, each header has a location to store its own CRC32 value. Therefore, 3 new CRC32 values are computed and used to update 2 places in each header for a total of 4 places.

References

GUID Partition Table
man gpt
man cksum

Licensed under: CC-BY-SA with attribution
Not affiliated with apple.stackexchange
scroll top