Thank you for reply.bredman wrote:Using swap on an SD card is not recommended for 2 reasons
1. An SD card can only sustain a limited number of writes in its lifetime.
2. Read/write access to an SD card is dreadfully slow.
You can enable swap if you like, it's your choice. Search this forum for the word "swapon".
Thank you for reply.RaTTuS wrote:1st ) free -h
2nd) raspbian uses a small swapfile
3rd) raspbina has the swapiness set to very low
Because, as RaTTuS said, it uses a swapfile, not a partition. "cat /proc/swaps" for details.joe2act wrote:Why Raspbian has two different swap spaces (one swap is 99MB in free -h, and another swap is none in fdisk -l)?
I will be amazed if you can construct a fair benchmark that can even measure a difference. Notice that swapping to a file does not update the file's timestamps, you are not allowed to truncate or write to the file while swapping to it, and you can not swap to a file that is sparse. In other words, the file is sealed off and treated exactly like a (slightly discontiguous) mini-partition.carlosfm wrote:I would also like to know how to disable the swap file on raspbian, as I am using a swap partition.
A swap partition is always much faster than a file,
I don't have proof, it's just a question of principle, but I'm not going to argue.jojopi wrote:I will be amazed if you can construct a fair benchmark that can even measure a difference. Notice that swapping to a file does not update the file's timestamps, you are not allowed to truncate or write to the file while swapping to it, and you can not swap to a file that is sparse. In other words, the file is sealed off and treated exactly like a (slightly discontiguous) mini-partition.carlosfm wrote:I would also like to know how to disable the swap file on raspbian, as I am using a swap partition.
A swap partition is always much faster than a file,
To answer your question, "sudo update-rc.d dphys-swapfile disable" should stop the swapfile being enabled at boot.
Code: Select all
apt-get purge dphys-swapfileAre you serious? You are honestly not going to tell us what the errors said?carlosfm wrote:"sudo update-rc.d dphys-swapfile disable"
This has produced errors and nothing happened.
Thank you for reply.jojopi wrote:Because, as RaTTuS said, it uses a swapfile, not a partition. "cat /proc/swaps" for details.
"fdisk -l" is not a correct method to check whether a system is configured for swap. It cannot see swapfiles, or swap that may be inside any LVM or RAID partitions. Also the type code on partitions is not enforced, so it is possible to be swapping to a partition that appears in fdisk as some other type. Most importantly, even if fdisk does list a swap partition, that does not tell you whether the system is configured to use it...
Code: Select all
pi@raspberrypi ~ $ cat /proc/swaps
Filename Type Size Used Priority
/var/swap file 102396 12 -1
pi@raspberrypi ~ $ free
total used free shared buffers cached
Mem: 188080 176424 11656 0 33992 115532
-/+ buffers/cache: 26900 161180
Swap: 102396 12 102384
Linux raspberrypi 3.1.9+ #168 PREEMPT Sat Jul 14 18:56:31 BST 2012 armv6l GNU/Linux
Code: Select all
pi@raspberrypi ~ $ cat /etc/fstab
proc /proc proc defaults 0 0
/dev/mmcblk0p1 /boot vfat defaults 0 0
/dev/mmcblk0p2 / ext4 defaults,noatime 0 0
# a swapfile is not a swap partition, so no using swapon|off from here on, use dphys-swapfile swap[on|off] for that
Sorry jojopi, when I posted this I had already rebooted and didn't want to execute it again.jojopi wrote:Are you serious? You are honestly not going to tell us what the errors said?carlosfm wrote:"sudo update-rc.d dphys-swapfile disable"
This has produced errors and nothing happened.
A much more elegant solution, no doubt.truehl wrote:Why not simply uninstall the dphys-swapfile package with:After doing this reboot and the swapfile and the piece of SW responsible for the swap has gone!Code: Select all
apt-get purge dphys-swapfile
But of course I did try it, prior to recommending. I can assure you it works when typed correctly on a not-otherwise-broken system. Did the errors look anything like:carlosfm wrote:You can try it, it didn't work but it has made no harm, just a couple of warnings.
Code: Select all
update-rc.d: using dependency based boot sequencing
update-rc.d: error: cannot find a LSB script for you-misspelled-dphys-swapfileCode: Select all
-bash: sudo update-rc.d dphys-swapfile disable all in quotes: command not foundA swap partition is not always much faster than a swap file. It depends on the inode structure and what is in what swap page and how close on disk, or in the flash prefetch some sector is to the file data it relies on. This does of course imply the swap driver has to be optimal or close to to see the benefit of this effect.carlosfm wrote:I don't have proof, it's just a question of principle, but I'm not going to argue.jojopi wrote:I will be amazed if you can construct a fair benchmark that can even measure a difference. Notice that swapping to a file does not update the file's timestamps, you are not allowed to truncate or write to the file while swapping to it, and you can not swap to a file that is sparse. In other words, the file is sealed off and treated exactly like a (slightly discontiguous) mini-partition.carlosfm wrote:I would also like to know how to disable the swap file on raspbian, as I am using a swap partition.
A swap partition is always much faster than a file,
To answer your question, "sudo update-rc.d dphys-swapfile disable" should stop the swapfile being enabled at boot.
A swap file is contained inside a filesystem, while the swap partition is dedicated for this task.
If it was an HDD, it would make much more difference, as I can locate the swap partition at the very beginning of the disk, while a swap file resides somewhere in the filesystem, which we can not exactly control.
Oh, and thanks for your help.
So I put a swapfile on the SD card, Debian Wheezy, at 2x cache size 512 MB entered it into /etc/fstab and turned the Wheezy automatically generated swap file of about 110 MB off. Rebooted and Wheezy automatically put the swap file back again. How do I turn the swap file off other than manual command every time ?A swap partition is not always much faster than a swap file. It depends on the inode structure and what is in what swap page and how close on disk, or in the flash prefetch some sector is to the file data it relies on. This does of course imply the swap driver has to be optimal or close to to see the benefit of this effect.
Thanks! Looked like it did something, freed up some disk space, and its still running.RaTTuS wrote:apt-get purge dphys-swapfile