0

I installed Arch recently and well, this is my second time installing it; the first time for a handful of reasons I switched, anyway; everything has been great so far except for one thing; some times my pc freezes; literally, like if it loads a lot of things it freezes and I can't even get into tty or anything because it's totally freezed or really slow. Until now I've tried to keep my cpu usage very low so I can evade having that problem again but some times is unevitable; I don't know why I didn't ask about this yet or what may be causing it; recently I was searching for something on Arch's forums and I saw the output from a command that a user executed; it was cat /proc/meminfo and in the output I saw that he had Swap Total and Swap Free, well, it had it's values and I tried that just to see what I could have there and then I saw that I have 0 on both, Swap Total and Swap Free and hence the random freezes so I thought that I didn't do the step of the swap partition well while I was installing Arch. I may be wrong or but if I'm not; what is the correct approach to do this post installation? Is that possible? Here is the output of cat /proc/meminfo:

MemTotal:        3769188 kB
MemFree:          151988 kB
MemAvailable:    1109796 kB
Buffers:           39236 kB
Cached:          1416284 kB
SwapCached:            0 kB
Active:          2783648 kB
Inactive:         605864 kB
Active(anon):    1955632 kB
Inactive(anon):   327060 kB
Active(file):     828016 kB
Inactive(file):   278804 kB
Unevictable:          36 kB
Mlocked:              36 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:              1684 kB
Writeback:             0 kB
AnonPages:       1762044 kB
Mapped:           570236 kB
Shmem:            348700 kB
Slab:             139376 kB
SReclaimable:     110572 kB
SUnreclaim:        28804 kB
KernelStack:        7136 kB
PageTables:        29152 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     1884592 kB
Committed_AS:    5102868 kB
VmallocTotal:   34359738367 kB
VmallocUsed:           0 kB
VmallocChunk:          0 kB
HardwareCorrupted:     0 kB
AnonHugePages:    303104 kB
ShmemHugePages:        0 kB
ShmemPmdMapped:        0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:       85112 kB
DirectMap2M:     3823616 kB
  • The user-friendly way to check memory usage is to run free -h. Don't worry if the "free" column is nearly zero, Linux is designed to utilize memory as much as possible by caching file data if there is no other demand for memory. – DepressedDaniel Dec 29 '16 at 7:00
1

The Arch wiki gives detailed instructions to add a swap file. In summary, it is:

# fallocate -l 512M /swapfile
# chmod 600 /swapfile
# mkswap /swapfile
# swapon /swapfile

And you should add it to your /etc/fstab as:

/swapfile none swap defaults 0 0
  • Actually you can chmod 000 /swapfile as the kernel does not check permissions for root anyways. – DepressedDaniel Dec 29 '16 at 6:58
  • You are right. I'm not sure why they keep root permissions but the point of the chmod is to remove permission from other users. – Julie Pelletier Dec 29 '16 at 7:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.