1 |
I haven't used a swap partition on any of my systems (intel celeron, |
2 |
p3, amd64, intel xeon) for over... what... 10 years? |
3 |
Swapfiles only, and sometimes I don't even mount the swap. Although I |
4 |
have never removed support for any kind of swap from my kernel. |
5 |
|
6 |
|
7 |
dd if=/dev/zero of=/path/to/swapfile bs=1M count=1024 |
8 |
mkswap /path/to/swapfile |
9 |
swapon /path/to/swapfile |
10 |
(btw, I like to put the swap file in /root or /boot, but that's my |
11 |
pref, on space constrained PC, i would put a swapfile on every drive |
12 |
to distribute it). |
13 |
|
14 |
|
15 |
I don't have access to my box to confirm but I think /etc/fstab would |
16 |
be setup the same as normal swap except with the file path instead of |
17 |
the device partition. |
18 |
|
19 |
Except for issue pointed out by Paul about hibernation, dd line above |
20 |
takes care of non-sparsity. As for security, having a swap is less |
21 |
secure than having none: a malicious persion could extract |
22 |
information from programs memory which was swapped (ie, like the |
23 |
decripted information "for your eyes only"). |
24 |
|
25 |
Having no swap at all was a problem on small systems with little RAM |
26 |
when emerging big stuff (boost failed all the time on a pc with |
27 |
256mb). |
28 |
|
29 |
Resizing swap "on-the-fly" with swapfiles: |
30 |
And on HDD-space constrained system, i used to have several |
31 |
swapfiles that I created and deleted in the manner above, that I named |
32 |
swapfile-256, swapfile-512, etc... A smooth "upgrade of swap |
33 |
on-the-fly" was done this way: say I had 256 swapped on, I could swap |
34 |
on a new 512 (768 total at moment, all data still on 256mb file), then |
35 |
swapoff the 256 (takes a bit of time for swap data to move over), |
36 |
delete the 256. Downgrade can be done in the same manner. "swapon |
37 |
-s" (status) will be a good friend of yours now. |
38 |
|
39 |
Good luck! |
40 |
|
41 |
Simon |
42 |
|
43 |
|
44 |
On Wed, May 2, 2012 at 2:53 PM, walt <w41ter@×××××.com> wrote: |
45 |
> I have two machines with 4GB of ram and I've never seen either one use |
46 |
> swapspace (yet) so I'm thinking I could delete my swap partitions and |
47 |
> substitute a much smaller swapfile -- if it's safe. |
48 |
> |
49 |
> Any downside to using a swap file instead of a swap partition, maybe |
50 |
> depending on which filesystem you use, or something? Security holes? |
51 |
> Any horror stories out there? |
52 |
> |
53 |
> |