I cannot remove my swapfile
rm: /System/Volumes/VM/swapfile0: error 1 Operation not permitted
rm: /System/Volumes/VM/swapfile0: error 1 Operation not permitted
You cannot delete it.
If you were to successfully delete it while the system is running, your system would most likely panic, or worse start corrupting your file system.
On reboot the old swapfile is removed and a new started.
It is essential to the macOS virtual memory operation.
You cannot delete it.
If you were to successfully delete it while the system is running, your system would most likely panic, or worse start corrupting your file system.
On reboot the old swapfile is removed and a new started.
It is essential to the macOS virtual memory operation.
mbailetti wrote:
ok. thanks for your answer.
anyway I think that when my Mac is running there will be only one copy of this kind of file in the folder VM,
not swapfile0,swapfile1,swapfile2 and so on...
right ?
macOS creates the swapfile to a size, then creates another till it gets too big, then another, etc…
When you reboot, macOS will delete the previous swapfiles and start all over again.
If you have lots of swapfiles, then you are running 1 or more concurrent apps that need lots more RAM memory than is installed in your Mac.
If you have the free disk space, then ignore it.
If you are running out of free disk space, then find something else to delete, because messing with the swapfiles is dangerous for the health of your system.
VikingOSX wrote:
The macOS swap file is on a read-only System volume where you have no privileges to add, change, or remove content. Since all UNIX operating systems use swapfiles, and macOS is among them, removing a swap file (if you could) would likely crash the System as some things are locked in the Swap file that are frequently accessed by the operating system.
No. Swapfiles need to be writable. They cannot be on a readonly volume.
But macOS can protected users and utilities that should know better, from attempting to delete the writable swapfiles.
The macOS swap file is on a read-only System volume where you have no privileges to add, change, or remove content. Since all UNIX operating systems use swapfiles, and macOS is among them, removing a swap file (if you could) would likely crash the System as some things are locked in the Swap file that are frequently accessed by the operating system.
mbailetti wrote:
ok. thanks for your answer.
anyway I think that when my Mac is running there will be only one copy of this kind of file in the folder VM,
not swapfile0,swapfile1,swapfile2 and so on...
right ?
Uninstall ONYX. The MacOS is very capable of managing memory without the use of third party apps.
/System/Volumes/VM is mounted read/write
mount | grep VM
/dev/disk3s6 on /System/Volumes/VM (apfs, local, noexec, journaled, noatime, nobrowse)
It is its own read/write volume.
vs the macOS boot volume which is mounted read-only
mount | grep read-only
/dev/disk3s1s1 on / (apfs, sealed, local, read-only, journaled)
/System/Volumes/VM is a volume carved out of the APFS container "Apple_APFS Container disk3". This is very similar to the concept used by the DIGITAL Equipment Corporation UNIX AdvFS file system (which was one of the file systems I've worked on, and APFS very much reminds me of AdvFS). In this case APFS has a common pool of storage (the container) and mounted volumes are created and populated using storage from the container. Every mountable volume in the container shares the same free space, which is why if you look at the Available space for several of the volumes in the container, they will all have the same amount of free space:
Filesystem 1024-blocks Used Available Capacity Mounted on
/dev/disk3s1s1 1948455240 8938372 1143202848 1% /
devfs 346 346 0 100% /dev
/dev/disk3s6 1948455240 20 1143202848 1% /System/Volumes/VM
/dev/disk3s2 1948455240 4928756 1143202848 1% /System/Volumes/Preboot
/dev/disk3s4 1948455240 34628 1143202848 1% /System/Volumes/Update
/dev/disk1s2 512000 6164 492152 2% /System/Volumes/xarts
/dev/disk1s1 512000 6228 492152 2% /System/Volumes/iSCPreboot
/dev/disk1s3 512000 2596 492152 1% /System/Volumes/Hardware
/dev/disk3s5 1948455240 790281924 1143202848 41% /System/Volumes/Data
In this example, the following volumes all have 1,948,455,240 Kilobytes of free space (about 1.8 terabytes):
While technically the kernel can do whatever it wants, it is much easier to just use existing VFS (abstracted Virtual File System) APIs to page data into and out of memory, and those VFS APIs pass through to the APFS file system drivers and pay attention to how a volume is mounted. So read-only is really read-only.
mbailetti wrote:
hi,
i was trying to delete this file as offered by the application "ONYX"
All Volumes share space within the same Container at no penalty.
MacBook-Pro ~ % diskutil list internal
/dev/disk0 (internal, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *1.0 TB disk0
1: EFI EFI 314.6 MB disk0s1
2: Apple_APFS Container disk1 1.0 TB disk0s2
/dev/disk1 (synthesized):
#: TYPE NAME SIZE IDENTIFIER
0: APFS Container Scheme - +1.0 TB disk1
Physical Store disk0s2
1: APFS Volume Macintosh HD 9.9 GB disk1s1
2: APFS Snapshot com.apple.os.update-... 9.9 GB disk1s1s1
3: APFS Volume Macintosh HD - Data 445.7 GB disk1s2
4: APFS Volume Preboot 2.1 GB disk1s3
5: APFS Volume Recovery 1.2 GB disk1s4
6: APFS Volume VM 2.1 GB disk1s5
MacBook-Pro ~ %
I would not use Onyx.
A read-only volume in general from a user perspective, but the operating system has elevated privileges that allow it to write into it as the dynamic pager requires.
mbailetti wrote:
rm: /System/Volumes/VM/swapfile0: error 1 Operation not permitted
Please provide some details as to what it is you are trying to do and why? A swap file is dynamic and grows/shrinks as necessary.
Correction. Free space example above is 1,143,202,848 kilobytes or around 1.064 terabytes (using power of 2 based kilobytes and terabytes 🤪 )
And when I said I worked on DIGITAL UNIX AdvFS, I mean I was one of the software developers that helped write and maintain the AdvFS file system (my day job is developing and maintaining Unix based file systems).
hi,
i was trying to delete this file as offered by the application "ONYX"
ok. thanks for your answer.
anyway I think that when my Mac is running there will be only one copy of this kind of file in the folder VM,
not swapfile0,swapfile1,swapfile2 and so on...
right ?
There is rarely any good reason to remove the swapfile even with a utility like Onyx.
For what reason(s) are you using Onyx and specifically why do you want to remove the swapfile?
I cannot remove my swapfile