LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   swap file and partition reboot issue with free cmd (https://www.linuxquestions.org/questions/linux-newbie-8/swap-file-and-partition-reboot-issue-with-free-cmd-4175574590/)

scriptkiddy 03-11-2016 02:12 AM

swap file and partition reboot issue with free cmd
 
I had a standard CentOS 7 partition layout with /boot, /, /var, and swap (2G) partitions carved out.
So the free cmd showed me that I had 2G total.

As a test, I added roughly 500MB more swap through a swap file:

Code:

# free
# dd if=/dev/zero of=/extra-swap bs=1M count=500
# mkswap /extra-swap
# swapon -a
# free

At this point, the free command returned same amount, roughly 2G. So I added the swap file to my fstab to make it persistent then rebooted:
Code:

# vim /etc/fstab
...
/extra-swap          swap        swap      defaults 0 0
...
# reboot

Upon reboot, the free cmd now showed 2.5G

My question is, why did free not show the swap until reboot?

Ideas and / or better ways to do this?

SK

syg00 03-11-2016 03:28 AM

Code:

swapon /extra-swap

Shadow_7 03-11-2016 03:44 AM

# swapon -s

to list active swaps. Free lists if you have some, but not much else about it. And as above use swapon to add the file/partition in the absence of having it auto-magically happen because of fstab.

TobiSGD 03-11-2016 05:55 AM

swap file and partition reboot issue with free cmd
 
swapon -a scans the fstab file for entries. It will not scan your partition layout.


All times are GMT -5. The time now is 12:57 AM.