📜 ⬆️ ⬇️

“Black Holes” Revealed at macOS High Sierra



You live in your life, you do not scratch your turnip, you can’t blow it. And then suddenly you need to move from the dilapidated iPhone 6 to the brand new iPhone X. And since your whole life for the past seven years is stored in photo and old video smartphone, you really do not want to lose this good. And now you back up your farm through iTunes on a Mac, try to move to a new “balalaika” and suddenly it turns out that there is no longer any place to backup your phone on your computer’s hard drive. You start frantically clearing the Augean stables of the disk space, but the result is “mute”. Moreover, deleting the “left files” and clearing the recycle bin does not lead to anything. Such a thriller recently broke out with Parallels Vice President Nikolai Dobrovolsky. Under the cut a detective story about the discovery of a “black hole” in macOS High Sierra, the search for truth and a happy ending that the main characters of the movie “Titanic” could envy.

Further in colors and pictures from the words of the protagonist, a narration will follow about the ailment and methods of miraculous healing.
')


In search of a "black hole"


Having decided to backup the contents of my new iPhone X via iTunes, I simultaneously needed 70GB of free disk space on my computer. Without thinking, I deleted most of the unnecessary files. Films, pictures and other masterpieces of modern art. I removed it long and painfully. As a result, instead of the required 70 gigs, more than 100GB was cleared. I clean the basket. And what was my surprise when, during subsequent attempts to dig it out, the system showed me a figure of three fingers. "There is no place, boy, blow into the garden, smoke bamboo." All subsequent attempts to free up additional disk space and save nothing. On the one hand there is more than enough space, but on the other hand, it is not there. Miracles. "See the gopher?" Not? And he is! ". Classic.

Bypassed all fans of Apple, climbed the Russian and overseas forums. At the first stage, no one added clarity. What-only versions were not. From the exotic: “These are the wrong bees, they make the wrong honey” to “Wait, it will disappear by itself”. As time went. The sore did not disappear. At the end of the week, it was possible to read at one of the American forums that the APFS (Apple Files System), which materialized recently on macOS High Sierra and the implementation of Time Machine snapshots on it, was to blame. Today, this is installed on all new laptops by default. Also, with updates you can roll it.

So, this very “clever ingot” when interacting with Time Machine works to put it mildly a little differently. What happened before? It used to be a very simple scheme. There are some extra files on the Mac, you delete them, they go to the trash. You clean the trash, files are completely deleted, keep free space.

Now, with Time Machine turned on and backed up to an external disk or Time Capsule on macOS High Sierra and APFS, it starts to sound strange. In addition to the fact that Time Machine starts backing up data and leaves it on an external disk, it also makes some local backups (Local Snapshots) on the hard disk in which the recent change history is stored. So that you could theoretically search for the future in the wilds of Time Machine, even if you don’t have this external disk with backups. Those. it not only saves information to an external disk, but also reserves space somewhere and tries to show you what you had in the recent past. Therefore, there is a situation in which a “black hole” forms on the hard disk of your computer. Thus, somewhere in the depths of your computer, additional disk space is reserved. Moreover, its volume and location in their right mind and sober memory cannot be determined. Remove and clean this farm in a simple way, you are also unlikely to succeed.

Perhaps my situation will seem atypical. I have a Time Machine backed up on an external drive. I also have macOS High Sierra and APFS. But, as they say, you can't throw the words out of the song.

So the method of "scientific sticking" revealed that there are certain commands that allow you to manage these very mystical Local Snapshots in macOS High Sierra. By the way, despite the fact that they write everywhere that if you have ten percent of free space, APFS deletes them by itself, in fact, while you do not clean them with pens, nothing will happen. They are theoretically once removed, but no predictions and systematics were found in this charitable process.

There is a reasonable question, and why would you dear friend found Local Snapshots not immediately removed? And the garden does not fence? It's simple. It is impossible to get to them, because they live in a certain reserved area, where no one has direct access. "Black Hole", not otherwise. Through the Finder you can not get there. This kind of hidden area, which even DaisyDisk shows as a system area. She does not know how to get there, but she knows that she exists.

"Sleight of hand and no fraud" (c).


I propose to proceed to a session of magic with its subsequent exposure. As they say it is better to see once than hear a hundred times.

So, you have a computer with a 128GB hard drive. Under the hood macOS High Sierra c APFS.


In order to recreate the situation of lack of disk space, take a Disk Image and create three large files of 30 GB each.






As we see our files took up more than 103GB. Full box. Next we run Time Machine.



At this stage, we understand that for the next backup we need to free up disk space. We delete unnecessary files. In this case, remove one of the three disk images on 30GB.



Feel free to remove unnecessary, because we also need free space. Then clean the basket without regrets.



And here you theoretically freed up 30GB of free space. Let's fill it with a new image of the disk of the appropriate volume.



And, lo and behold! There is no place.



And in the "Documents" and "Basket" no mention of the "ghost file" is not.



Launch DaisyDisk and see that “Hidden Space” (“Black Hole”) has formed on our hard disk. The size of this beauty is similar in volume to the files that we deleted earlier. I repeat, to understand that there somehow it is problematic to remove it without dancing with tambourines.




And here Russian savvy comes to your aid, a few mantras to a computer mother, and here is such a nice script:

tmutil listlocalsnapshotdates / | while read line;
do
tmutil deletelocalsnapshots $ line
done

It shows the list of Local Snapshots and deletes them, which can also be done directly by hands at the Terminal:



For the purity of the experiment, we create a new disk image on 30GB. We understand that everything is spiky!





The End!

ZY Write if you have similar problems or even stranger squiggles. It will be interesting to discuss them in the comments.

Source: https://habr.com/ru/post/351128/


All Articles