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

Microsoft Windows Server 2012 R2 Standard Evaluation Product Key

Microsoft Windows Server 2012 R2 Standard Evaluation D2N9P-3P6X9-2R39C-7RTCD-MDVJX DBGBW-NPF86-BJVTX-K3WKJ-MTB6V

ManageEngine ServiceDesk Plus - Reset password

Let's reset the default administrator's password to 'admin'

hmailserver: Notes from the field

hmailserver is one of free open source mail servers running on Microsoft Windows operating system.