November 3, 201213 yr Here is a quick and dirty plugin that I wrap to enable/disable the swap file I have on my cache drive. Perhaps some of you guys will find it usually, but most importantly, perhaps we can improve upon it. It's pretty static right now... It creates (if the file doesn't already exists) a 16GB swap file on /mnt/cache, sets permissions, then mounts it. On shutdown, it automatically disables it. Comments and criticisms certainly appreciated. swapfile.plg.zip
November 4, 201213 yr This is great! I had posted this link some time ago into a lime-technology forum. http://lime-technology.com/forum/index.php?topic=1595.msg190521#msg190521 How can I incorporate a swap disk (like my swap USB stick) into your plg file?
November 4, 201213 yr Author If you know what device his the swap partition, you would just swap the commands out to point to the correct device. If you'd like to make it dynamic, you would just grep your device out of the 'cat /proc/partitions' command you listed. You could use something like this in the swap_start piece (note that this hasn't been tested) if [ -d /dev/sdg ]; then # USB Swap drive is ready mkswap -f /dev/sdg swapon /dev/sdg fi in swap_stop, try something like this if [ -d /dev/sdg ]; then # USB drive exists swapoff /dev/sdg fi This assumes that your sdg drive is always that USB stick. It doesn't check to make sure that it is, so it could be dangerous. I am about to go on the road for a few hours, but when i get some back, I'll take a few minutes to see if we can make the script a bit more dynamic.
November 4, 201213 yr I made the changes, but without the code: mkswap -f /dev/sdg Note: My USB drive has changed since my last post to /dev/sde. You are right about this command being a dangerous/unforgiving command if you are not correct about the drive, you will have destroyed the drive on witch it is assigned. The swapon and swapoff will just error out if the drive is not swap drive. now the dynamic part: if the script could check for where a swap drive/partition or file is and then assign the swapon/swapoff, that would be great.
November 19, 201213 yr Here is a quick and dirty plugin that I wrap to enable/disable the swap file I have on my cache drive. Perhaps some of you guys will find it usually, but most importantly, perhaps we can improve upon it. It's pretty static right now... It creates (if the file doesn't already exists) a 16GB swap file on /mnt/cache, sets permissions, then mounts it. On shutdown, it automatically disables it. Comments and criticisms certainly appreciated. Pardon my somewhat linux noobness. If I understand the code correctly swap_stop() removes the swap file /mnt/cache/.swap Since swap_start() creates the swap file only if it doesn't already exist, would it be OK to not remove it and so save the time it takes to create it during boot?
November 19, 201213 yr Pardon my somewhat linux noobness. If I understand the code correctly swap_stop() removes the swap file /mnt/cache/.swap Since swap_start() creates the swap file only if it doesn't already exist, would it be OK to not remove it and so save the time it takes to create it during boot? Following up my own question with more questions: Does the swap file need to be zero-filled just prior to swapon and so it does need to be recreated during boot? If using a swap partition instead of a file does the OS zero the partition on boot? Am I needlessly trying to save a few seconds here? I seem to remember the swap I used under 4.7 from unMenu as takiing a lot of time to create during boot but maybe not.
November 22, 201213 yr I did some modifications to the original plugin by "cofin" because it didn't work "out of the box". Used Joe L's unmenu swafile plugin as reference - Thank you Joe. Main changes - added: mkswap command chmod command logger commands to log in syslog Note that I changed the size to 2G instead of 16G - that is what I need and don't want to waste time each reboot to create the larger file. I would also like to echo trurl's question: Does the swap file need to be recreated (zeros) each time it is turned on "swapon"? swapfile.zip
November 23, 201213 yr Please forgive my ignorance, but what is the benefit of this plugin? What is swap file used for?
December 2, 201213 yr it adds memory to your system thru the use of a temp memory storage file - windows does the same... Myk
December 2, 201213 yr according to the how-to i just found, they created the file, assign ownership/permissions and then added a line to the fstab file for automount the swap file upon bootup - and this was not creating the file at every bootup I edited the rc.swap to not delete the swap file as is it written, if the swap file exists it will use it, otherwise it will created it and then use it Myk
December 2, 201213 yr according to the how-to i just found, they created the file, assign ownership/permissions and then added a line to the fstab file for automount the swap file upon bootup - and this was not creating the file at every bootup I edited the rc.swap to not delete the swap file as is it written, if the swap file exists it will use it, otherwise it will created it and then use it Myk Can you post this link to the how-to? That is one of the question posted above by trurl and myself... Do we need to recreate the swap file each boot?
December 2, 201213 yr no you dont, been been playing with this for the last hour and I commented out the rm command on the stop, have been stopping/starting/rebooting and everything is working just fine here is the link I based my reasoning off of and my testing.... http://www.cyberciti.biz/faq/linux-add-a-swap-file-howto/ Myk
January 29, 201313 yr Hi guys, It's been a couple of months since MyKroFt posted his proposed changes. So what's the verdict? Does it work totally fine for everyone so far? Thanks
February 8, 201313 yr New swap file plugin with WEBUI posted: http://lime-technology.com/forum/index.php?topic=25816.0
Archived
This topic is now archived and is closed to further replies.