I was told in response to my question that the kernel uses files without the help of the filesystem - once a file is located the kernel just uses its location on the disk.
The example was an empty mountpoint (directory) where a file is located which the kernel uses as swap. After some time an external HDD gets mounted into this mountpoint. On this external HDD there is also a swapfile in the root directory. So, both files have the same path /mountpoint/swapfile
.
My question is how to swapoff /file
the first file. To be clear again: swapoff /mountpoint/swapfile
will not work since this is the second file (after mount) which is not used by the kernel at that moment. At least I would suspect this.
I want to swapoff
a file that is not visible in my filesystem.
(Yes, there are probably other solutions but I am curious about this.)