I'm not quite sure whether a swap file on an NTFS partition is the best solution for you. You may be better off creating an actual swap partition on your hard drive and use that. You could use a tool such as gparted
to resize your NTFS partition, reducing it by the size you want your swap file to be, say, 2 GB. Then you could allocate a 2 GB swap partition on the newly freed space on your hard drive.
(Of course that assumes you have at least 2 GB of free space on your NTFS partition. But that's just the same space a swap file would consume as well.)
The reason I'm saying that a swap file on your NTFS partition may not be the right solution is because it may impact performance significantly, for two reasons:
Your NTFS partition is not fresh, it's been used for a long time, and your 2 GB swap file will likely be fragmented. Hence, reading and writing to that swap file may be much slower since it is not a contiguous memory region (as opposed to a swap partition). See this excellent answer on Server Fault for some more information.
On top of that, the NTFS drivers are rather slow, as mentioned in the Arch Linux forums in the thread that you linked to yourself.
If you are nevertheless determined to create a swap file on your NTFS partition, that's easy. All you have to do is this:
Ensure your NTFS partition is mounted somewhere. For the sake of example, let's assume the mountpoint for your NTFS partition is /media/windows
.
Create a swap file with 2 GB on your NTFS partition like so:
dd if=/dev/zero of=/media/windows/swapfile.img bs=1M count=2048
mkswap /media/windows/swapfile.img
- Enable the swap with
swapon /media/windows/swapfile.img
That's it really. Those are exactly the instructions from that Arch Linux thread, I merely changed the size of the swap file to 2 GB.
The whole rest of the Arch Linux thread only deals with the issue that the OP wants to have his swap file enabled automatically at boot, so that they don't have to run that swapon
command every time after rebooting the system. For that to work, you have to somehow make sure that the NTFS partition is mounted before the swap is enabled, since the swap file is on the NTFS partition, and that can get a bit messy, which is why someone there suggests creating a systemd
service to enable the swap after the NTFS partition is mounted.
But if you only want to test how a swap file on your NTFS partition solves the problems with your game, you don't need to worry about that right now. You can just go ahead with the above steps. It simply means that, every time you reboot your system, you have to re-run steps (1) and (3) above, i.e., make sure your NTFS partition is mounted (hint: put it in your /etc/fstab
and have it mounted at boot time) and run that swapon
command. Note that you only have to perform step (2) once: Once the swap file is created, you don't need to create it anew. Unless you want to change its size.
Then, if that works for you and you're really happy with the results and you can play your game and one day you're annoyed that you have to run that swapon
command every time you reboot your system, then you can worry about writing a systemd
service to run that swapon
command every time automatically at boot. And then, if you have trouble with that, you're welcome to ask another specific question about that problem here. Or perhaps, by then you will like Ubuntu so much that you decide to get rid of Windows 7 and install Ubuntu for good. ;)
Best Answer
You have 2 files probably because you created 2 files.
You can have a swap partition(recommended) or a swap file, or a combination of swap partitions and swap files.
Here you can get some more info: