Monday, September 12, 2016

Adding swap file

In case we need to increase the size of the swap we can add a file to the file system and use it as a swap


[root@o12c ~]# swapon -s
Filename                                Type            Size    Used    Priority
/dev/dm-1                               partition       4620284 0       -1
[root@o12c ~]#
[root@o12c ~]#
[root@o12c ~]# cat /proc/swaps
Filename                                Type            Size    Used    Priority
/dev/dm-1                               partition       4620284 0       -1
[root@o12c ~]#
[root@o12c ~]# cat /etc/fstab|grep swap
/dev/mapper/vg_o12c-lv_swap swap                    swap    defaults        0 0
[root@o12c ~]# 



[root@o12c ~]#
[root@o12c ~]# dd if=/dev/zero of=/root/swapfile count=1024 bs=4194304
1024+0 records in
1024+0 records out
4294967296 bytes (4.3 GB) copied, 33.7263 s, 127 MB/s
[root@o12c ~]# mkswap -c /root/swapfile
mkswap: /root/swapfile: warning: don't erase bootbits sectors
        on whole disk. Use -f to force.
Setting up swapspace version 1, size = 4194300 KiB
no label, UUID=92497138-d397-412d-b827-f3c73c91047d
[root@o12c ~]# swapon /root/swapfile
[root@o12c ~]# swapon -s
Filename                                Type            Size    Used    Priority
/dev/dm-1                               partition       4620284 0       -1
/root/swapfile                          file            4194300 0       -2
[root@o12c ~]# 

No comments: