1

By mistake one of our admin on a production machine, deleted the swap file from the system. Without swapping it off.

Now we are getting this.

/swapfile3\040(deleted) file 1048568 1048568 -2 /swapfile1\040(deleted) file
1048568 1048568 -3 /apps/swap2 file
899992 899992 -4 /swapfile file
99992 37712 -9 /swapfile4 file
524280 0 -10

We can't reboot the box. Swap off is not working. Please advise. It is running on kernel 2.6 RHEL 5.

tollboy
  • 76
  • 1
  • 8
  • Anything wrong leaving it as is until the next allowed reboot? It's still there and used as swapfile, just no longer accesible as a file. You could try an undelete utility (not sure how this goes on a live filesystem) – Dan Feb 16 '15 at 20:10
  • The file still exists until it is closed so the system should be fine until it is rebooted. Update /etc/fstab to remove it or update the line to point to a newly created swap file meant to replace the deleted one on subsequent boots. – Brian Feb 16 '15 at 22:13

1 Answers1

1

Unfortunately the swapoff system call in Linux does not support disabling a deleted swap file.

It would be possible to add this feature to the kernel, but from a look on the most recent version of the source code, it appears nobody has implemented this feature yet.

Of course if such a feature did get added to the kernel, you would still have to reboot in order to upgrade to a kernel with the support. This could be avoided, if support for disabling a deleted swap file could be added as a kernel module. However the list of exported symbols doesn't include the list of active swap files, so the relevant data structures aren't accessible to a kernel module, so that approach won't work either.

Based on that I'm pretty sure that, unless you still have a link to the swap file somewhere in the file system or it is currently kept open by some process, you are going to have to leave that swap file enabled until next time you reboot. Also notice that you won't be able to unmount that file system or remount it read only. This could potentially get in the way of a clean shutdown.

If you are going to reboot the machine remotely, this means you will have to ask yourself, if attempting a clean shutdown is desirable. There is a risk that an attempted clean shutdown could get stuck which could leave the machine in a state where networking is disabled, so you cannot log in, and shutdown isn't making any progress, so it won't come up on its own either.

If you don't have a plan for what you will do if a clean shutdown gets stuck, you may be better off rebooting the machine without even attempting a clean shutdown.

kasperd
  • 29,894
  • 16
  • 72
  • 122