WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Manually Format Swap  (Read 1215 times)

Offline cute curtis

  • WikiUser
  • *
  • Posts: 7
  • Welcome In Da Club
Manually Format Swap
« on: May 06, 2019, 07:18:33 PM »
Hi, how can I manually format my swap partition? Also I want to know if I'm really using it? Thanks

Offline jazzbiker

  • Full Member
  • ***
  • Posts: 123
Re: Manually Format Swap
« Reply #1 on: May 06, 2019, 10:32:30 PM »
Hi, how can I manually format my swap partition? Also I want to know if I'm really using it? Thanks
Hi, @cute curtis!
To get info on your memory usage you can do
Code: [Select]
cat /proc/meminfo
If you are using any X server, you can call:
System Tools > Control Panel > System Stats > mem
from application menu.

Do you mean "format my swap" clearing your data for security purposes?

Offline jazzbiker

  • Full Member
  • ***
  • Posts: 123
Re: Manually Format Swap
« Reply #2 on: May 06, 2019, 10:43:09 PM »
There is "noswap" boot code, if you have enough memory for your tasks this will be the simplest solution.

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 11023
Re: Manually Format Swap
« Reply #3 on: May 06, 2019, 11:38:35 PM »
See:

https://linux.die.net/man/8/mkswap

mkswap and swapon are in the util-linux extension

Offline Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 6841
Re: Manually Format Swap
« Reply #4 on: May 07, 2019, 05:24:39 AM »
Hi cute curtis
... Also I want to know if I'm really using it? ...
To get a list of swap devices, their sizes, and how much of each device is in use:
Code: [Select]
tc@box:~$ cat /proc/swaps
Filename                                Type            Size    Used    Priority
/dev/sda2                               partition       1047548 181584  -1
tc@box:~$

Offline cute curtis

  • WikiUser
  • *
  • Posts: 7
  • Welcome In Da Club
Re: Manually Format Swap
« Reply #5 on: May 09, 2019, 07:46:25 PM »
Hi, thanks for immediate reply, I wonder why my swap cached is 0KB am I really utilizing this?

Code: [Select]
tc@box:~$ cat /proc/meminfo
MemTotal:        1021812 kB
MemFree:          916932 kB
MemAvailable:     860180 kB
Buffers:           10264 kB
Cached:            41620 kB
SwapCached:            0 kB
Active:            44140 kB
Inactive:          19484 kB
Active(anon):      25308 kB
Inactive(anon):     2592 kB
Active(file):      18832 kB
Inactive(file):    16892 kB
Unevictable:           0 kB
Mlocked:               0 kB
HighTotal:        138056 kB
HighFree:          73844 kB
LowTotal:         883756 kB
LowFree:          843088 kB
SwapTotal:        757860 kB
SwapFree:         757860 kB
Dirty:                32 kB
Writeback:             0 kB
AnonPages:         11800 kB
Mapped:             7196 kB
Shmem:             16164 kB
Slab:              18120 kB
SReclaimable:       4608 kB
SUnreclaim:        13512 kB
KernelStack:         952 kB
PageTables:          208 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     1268764 kB
Committed_AS:      32768 kB
VmallocTotal:     122880 kB
VmallocUsed:           0 kB
VmallocChunk:          0 kB
Percpu:              376 kB
AnonHugePages:      4096 kB
ShmemHugePages:        0 kB
ShmemPmdMapped:        0 kB
DirectMap4k:       12280 kB
DirectMap4M:      888832 kB


tc@box:~$ fdisk -l
Disk /dev/sda: 149 GB, 160041885696 bytes, 312581808 sectors
19457 cylinders, 255 heads, 63 sectors/track
Units: sectors of 1 * 512 = 512 bytes

Device  Boot StartCHS    EndCHS        StartLBA     EndLBA    Sectors  Size Id T  ype
/dev/sda1 *  63,188,62   1023,254,63    1024000  312580095  311556096  148G 83 L  inux
/dev/sda2    0,32,33     63,188,61         2048    1023999    1021952  499M 82 L  inux swap

Partition table entries are not in disk order
tc@box:~$ mkswap
BusyBox v1.29.3 (2018-12-19 15:29:37 UTC) multi-call binary.

Usage: mkswap [-L LBL] BLOCKDEV [KBYTES]

Prepare BLOCKDEV to be used as swap partition

        -L LBL  Label
tc@box:~$ lsmod
Module                  Size  Used by    Tainted: P 
ath9k                  61440  0
mac80211              237568  1 ath9k
ath9k_common           12288  1 ath9k
ath9k_hw              368640  2 ath9k,ath9k_common
ath                    24576  3 ath9k,ath9k_common,ath9k_hw
wl                   6033408  0
cpufreq_userspace      12288  0
cpufreq_conservative    12288  0
cpufreq_powersave      12288  0
cfg80211              167936  5 ath9k,mac80211,ath9k_common,ath,wl
sony_laptop            32768  0
sdhci_pci              24576  0
squashfs               28672 39
zstd_decompress        53248  1 squashfs
xxhash                 16384  1 zstd_decompress
cqhci                  16384  1 sdhci_pci
sdhci                  32768  1 sdhci_pci
mmc_core               65536  3 sdhci_pci,cqhci,sdhci
r592                   16384  0
memstick               12288  1 r592
pcspkr                 12288  0
video                  28672  1 sony_laptop
backlight              12288  2 sony_laptop,video
battery                16384  0
loop                   20480 78
ac                     12288  0
atl1c                  28672  0
lpc_ich                20480  0
acpi_cpufreq           12288  1
tc@box:~$

What is the full procedure of formatting an already partitioned swap partition using mkswap and swapon

Offline Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 6841
Re: Manually Format Swap
« Reply #6 on: May 09, 2019, 07:59:10 PM »
Hi cute curtis
According to this:
Code: [Select]
tc@box:~$ fdisk -l
Disk /dev/sda: 149 GB, 160041885696 bytes, 312581808 sectors
19457 cylinders, 255 heads, 63 sectors/track
Units: sectors of 1 * 512 = 512 bytes

Device  Boot StartCHS    EndCHS        StartLBA     EndLBA    Sectors  Size Id T  ype
/dev/sda1 *  63,188,62   1023,254,63    1024000  312580095  311556096  148G 83 L  inux
/dev/sda2    0,32,33     63,188,61         2048    1023999    1021952  499M 82 L  inux swap

Partition table entries are not in disk order
You have already have a swap partition at  /dev/sda2.  When you boot, Tinycore will enable any swap devices found.

If you execute:
Code: [Select]
cat /proc/swapsit will list your swap devices, their size, and how much if any of that space the system is currently using.

Offline cute curtis

  • WikiUser
  • *
  • Posts: 7
  • Welcome In Da Club
Re: Manually Format Swap
« Reply #7 on: May 11, 2019, 07:28:54 AM »
Yes I formatted it to 500MB with G-Parted, but the swap cached is 0KB so I'm wondering if the OS is utilizing my swap partition. I would also like to know how to invoke the mkswap and swap on on command line, are these two the only command needed?

Offline Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 6841
Re: Manually Format Swap
« Reply #8 on: May 11, 2019, 07:55:48 AM »
Hi cute curtis
Yes I formatted it to 500MB with G-Parted, ...
That's what I do for swap, create a swap partition with gparted.

Quote
... but the swap cached is 0KB so I'm wondering if the OS is utilizing my swap partition. ...
The OS won't utilize any swap space until it needs to free up RAM to make room for something else. The fact that swap space
is not being used is a good thing. It means you have sufficient RAM.