Hypercritical 02月25日
Hyperspace
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

本文介绍了Hyperspace,一款利用APFS(Apple File System)克隆技术来释放Mac磁盘空间的应用程序。该应用通过查找内容相同但并非克隆的文件,将它们转换为共享磁盘数据的克隆文件,从而在不删除任何文件的情况下回收磁盘空间。开发者最初使用Perl脚本实现了这一功能,随后将其开发成Mac应用程序Hyperspace,并已在Mac App Store上架。Hyperspace允许用户免费扫描以了解潜在的磁盘空间节省量,但需要付费才能实际执行空间回收操作。

💡 **APFS克隆技术:** Hyperspace的核心在于利用APFS的copy-on-write克隆特性。当在Finder中复制文件时,APFS不会复制全部文件内容,而是创建一个与原始文件共享数据的“克隆”文件,因此复制速度极快,且不占用额外磁盘空间。

💾 **解决磁盘空间问题:** Hyperspace通过查找磁盘上内容相同但并非APFS克隆的文件,将它们转换成克隆文件,从而合并重复数据,释放被这些重复文件占用的磁盘空间。这对于存储大量相似文件(如照片、文档等)的用户来说,效果显著。

🛠️ **应用开发与风险:** Hyperspace的开发经历了从Perl脚本到SwiftUI应用程序的过程。开发者坦言,由于该应用会修改非自身创建的文件,因此具有较高的风险。尽管如此,开发者认为Hyperspace对用户来说可能非常有用,并已在Mac App Store上发布。

-->

My interest in file systems started when I discovered how type and creator codes1 and resource forks contributed to the fantastic user interface on my original Macintosh in 1984. In the late 1990s, when it looked like Apple might buy Be Inc. to solve its operating system problems, the Be File System was the part I was most excited about. When Apple bought NeXT instead and (eventually) created Mac OS X, I was extremely enthusiastic about the possibility of ZFS becoming the new file system for the Mac. But that didn’t happen either.

Finally, at WWDC 2017, Apple announced Apple File System (APFS) for macOS (after secretly test-converting everyone’s iPhones to APFS and then reverting them back to HFS+ as part of an earlier iOS 10.x update in one of the most audacious technological gambits in history).

APFS wasn’t ZFS, but it was still a huge leap over HFS+. Two of its most important features are point-in-time snapshots and copy-on-write clones. Snapshots allow for more reliable and efficient Time Machine backups. Copy-on-write clones are based on the same underlying architectural features that enable snapshots: a flexible arrangement between directory entries and their corresponding file contents.

Today, most Mac users don’t even notice that using the “Duplicate” command in the Finder to make a copy of a file doesn’t actually copy the file’s contents. Instead, it makes a “clone” file that shares its data with the original file. That’s why duplicating a file in the Finder is nearly instant, no matter how large the file is.

Despite knowing about clone files since the APFS introduction nearly eight years ago, I didn’t give them much thought beyond the tiny thrill of knowing that I wasn’t eating any more disk space when I duplicated a large file in the Finder. But late last year, as my Mac’s disk slowly filled, I started to muse about how I might be able to get some disk space back.

If I could find files that had the same content but were not clones of each other, I could convert them into clones that all shared a single instance of the data on disk. I took an afternoon to whip up a Perl script (that called out to a command-line tool written in C and another written in Swift) to run against my disk to see how much space I might be able to save by doing this. It turned out to be a lot: dozens of gigabytes.

At this point, there was no turning back. I had to make this into an app. There are plenty of Mac apps that will save disk space by finding duplicate files and then deleting the duplicates. Using APFS clones, my app could reclaim disk space without removing any files! As a digital pack rat, this appealed to me immensely.

By the end of that week, I’d written a barebones Mac app to do the same thing my Perl script was doing. In the months that followed, I polished and tested the app, and christened it Hyperspace. I’m happy to announce that Hyperspace is now available on the Mac App Store.

Hyperspace is a free to download, and it’s free to scan to see how much space you might save. To actually reclaim any of that space, you will have to pay for the app.

Like all my apps, Hyperspace is a bit difficult to explain. I’ve attempted to do so, at length, in the Hyperspace documentation. I hope it makes enough sense to enough people that it will be a useful addition to the Mac ecosystem.

For my fellow developers who might be curious, this is my second Mac app that uses SwiftUI and my first that uses the SwiftUI life cycle. It’s also my second app to use Swift 6 and my first to do so since very early in its development. I found it much easier to use Swift 6 from (nearly) the start than to convert an existing, released app to Swift 6. Even so, there are still many rough edges to Swift 6, and I look forward to things being smoothed out a bit in the coming years.

In a recent episode of ATP, I described the then-unnamed Hyperspace as “An Incredibly Dangerous App.” Like the process of converting from HFS+ to APFS, Hyperspace modifies files that it did not create and does not own. It is, by far, the riskiest app I’ve created. (Reclaiming disk space ain’t like dusting crops…) But I also think it might be the most useful to the largest number of people. I hope you like it.


  1. Please note that type and creator codes are not stored in the resource fork.

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

Hyperspace APFS 磁盘空间 克隆技术 macOS
相关文章