9

I found a file of size 1 GB in /vm/swapfile0, that has not been accessed in a long time, according to last access date value in ls -l.

My assumption is, that this file is left over from an older macOS version. The last access was probably before I upgraded to 10.12. Can I safely remove it?

I also found some files of size 1 GB in /private/var/vm. These have recent access times; both sleepimage and swapfile1 today and swapfile0 two weeks in the past. I think these are in active use.

One side question though: sleepimage has a size of 1 GB, although I have 4 GB RAM installed. How is that possible? Other threads on the topic of sleepimage suggested that the size would match that of the RAM installed in my Mac.

2
  • 2
    See this question here at AskDifferent for more info about these types of files, especially the sleepimage file.
    – IconDaemon
    Jun 4 '18 at 19:16
  • 2
    This is unused, /vm was used during some upgrade or install. Some people report that after a supplemental update it disappeared. If you're running on the latest macOS version, it's safe to delete.
    – mspasov
    Jun 5 '18 at 0:38
10

Boot up in Recovery mode and use the Terminal to remove the swapfile0 file. That is fully safe to do.

5
  • This is a great answer. The downsides I mention are not even close to the level of “unsafe” so a clear answer seems best to me here. +1
    – bmike
    Jun 5 '18 at 1:40
  • @bmike, "downsides I mention are not even close to the level of unsafe" meaning?
    – Pacerier
    Apr 23 '20 at 18:43
  • @Pacerier My answer questions whether it’s safe to remove this. Since the OP didn’t specify how they intend to prune - there are some concerns I have to effectiveness and safety of removing a system file from under a running system. If they rm - it’s pointless, since the file doesn’t actually get deleted until the file is closed. And they have to assume macOS won’t attempt to close the file in some cases.
    – bmike
    Apr 23 '20 at 20:52
  • /vm/swapfile0 doesn't show up for me in my terminal when in opening in recovery mode for some reason - in fact there's no /vm dir at all. Is there a way to find it in recovery mode, or make it possible to see?
    – RyanQuey
    Dec 23 '21 at 5:28
  • You’re probably on a recent macOS version - then you haven’t got the problem in this question, and thus you do not need to do anything.
    – jksoegaard
    Dec 23 '21 at 6:29
5

The system reserves that file and cleans excess on restart. I'd leave it alone whether it's safe or not to prune (or attempt to prune). The system compresses memory and needs to have this space to offload any memory that's paged out so there's not a need for 1:1 RAM to swap allocation.

There are many other files you will want to focus on if you feel storage is growing out of check or you want to free up space on a boot drive. Deleting a file that will just be recreated, likely less contiguously than when you had more space available isn’t a sustainable clean up activity. Consider moving photos, music and movies to external storage or deleting apps if you have no large user files you can clean or move.

2
  • Could you give me a hint on what other files I should focus? Jun 6 '18 at 13:31
  • Sure @user1785730 - If you open up the storage tab of about this mac and go through the cleanup / link to the top 3 buckets of storage that might help with advice. Also, I use Daisy Disk to get a second opinion about what files are stored where. Apple puts some stuff in System that I like to know is really photo caches, etc...
    – bmike
    Jun 6 '18 at 18:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .