Skip to main content

CentOS: Create Swap Partition

One of my CentOS 7 Core hosts on CloudCone has only 256MB of memory. Here's my note while enable swap partition for it.

[tuyendq@1 ~]$ free 
              total        used        free      shared  buff/cache   available
Mem:         237244       76768       44640       12780      115836      127416
Swap:             0           0           0
[tuyendq@1 ~]$ 
[tuyendq@1 ~]$ sudo dd if=/dev/zero of=/swap count=2049 bs=1MiB
[sudo] password for tuyendq: 
2049+0 records in
2049+0 records out
2148532224 bytes (2.1 GB) copied, 14.3186 s, 150 MB/s
[tuyendq@1 ~]$ 
[tuyendq@1 ~]$ sudo chmod 600 /swap 
[tuyendq@1 ~]$ which mkswap
/usr/sbin/mkswap
[tuyendq@1 ~]$ sudo mkswap /swap 
Setting up swapspace version 1, size = 2098172 KiB
no label, UUID=0cea54e6-42d4-49c9-8f9b-f30e62582acf
[tuyendq@1 ~]$ 
[tuyendq@1 ~]$ sudo swapon /swap
[tuyendq@1 ~]$ free
              total        used        free      shared  buff/cache   available
Mem:         237244       78120        7140       12780      151984      126116
Swap:       2098172           0     2098172
[tuyendq@1 ~]$ 
[tuyendq@1 ~]$ cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Mon Jul 14 18:58:05 2014
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/vda1 /                       ext4    defaults        1 1
#/dev/vda2 swap                    swap    defaults        0 0
[tuyendq@1 ~]$ 
[tuyendq@1 ~]$ echo "/swap swap swap defaults 0 0" | sudo tee -a /etc/fstab
/swap swap swap defaults 0 0
[tuyendq@1 ~]$ cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Mon Jul 14 18:58:05 2014
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/vda1 /                       ext4    defaults        1 1
#/dev/vda2 swap                    swap    defaults        0 0
/swap swap swap defaults 0 0
[tuyendq@1 ~]$ 

Popular posts from this blog

Fedora Workstation: Install snapd

[tuyen@g73jh ~]$ sudo dnf -y install snapd Last metadata expiration check: 0:20:17 ago on Tue 01 Oct 2019 11:31:30 AM +07. Dependencies resolved. ================================================================================ Package Architecture Version Repository Size ================================================================================ Installing: snapd x86_64 2.41-1.fc30 updates 17 M Installing dependencies: snap-confine x86_64 2.41-1.fc30 updates 2.8 M snapd-glib x86_64 1.49-1.fc30 updates 133 k snapd-selinux noarch 2.41-1.fc30 updates 234 k Installing weak dependencies: gnome-software-snap x86_64 3.32.4-2.fc30 updates 86 k Transaction Summary ================================================================================ Install 5 Packages Total download size...

Apache Airflow: Notes

Apache Airflow is used to programmatically author, schedule and monitor workflows.

Install Microsoft .NET Core SDK

.NET Core Software Development Kit (SDK) is a set of libraries and tools that allow developers to create .NET Core applications and libraries.