Get the App
SLTechnology News&Howtos  ›  Database  › 

Modify the size of swap

Shulou Source: shulou.com Published: 2022-06-01 06:13:03 10月04日 Update

1. View swap space usage

[root@oracle] # free-m total used free shared buffers cachedMem: 1862 267 1595 1 19 103 Muhammad + buffers/cache: 144 1718Swap: 2048 0 2048

two。 Create a new swap directory in the / usr directory

[root@joracle usr] # mkdir swap [root@oracle usr] # cd swap

3. Allocate a 2 × 1G space from the hard disk and hang it on the swapfile.

[root@oracle swap] # dd if=/dev/zero of=swapfile bs=1G count=22+0 records in2+0 records out2147483648 bytes (2.1GB) copied, 3.51207 s, 611 MB/s

4. Build swap format on / usr/swap/swapfile

[root@emaswap] # mkswap swapfile

5. Activate swapfile and add to the swap partition.

[root@jumper swap] # swapon swapfile

6. Add swapfile to the / etc/fstab entry and automatically mount it on boot

Root@oracle swap] # vim / etc/fstab## / etc/fstab# Created by anaconda on Mon Jun 27 09:19:50 2016 June # 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#UUID=d83c67dc-f486-49da-aed0-2e8fdf58c743 / ext4 defaults 1 1UUID=9cfb795c-c308-4594-82cb-aff56d8b840c / boot ext4 defaults 1 2UUID=1766229a-57ee-46b1-8bb3-1d508e37e88e swap swap defaults 0 0tmpfs / dev/shm tmpfs defaults 0 0devpts / dev/pts devpts gid=5 Mode=620 0 0sysfs / sys sysfs defaults 0 0proc / proc proc defaults 0 0/usr/swap/swapfile swap swap defaults 0 0

7.reboot restarts the system, swap boot has been changed to 4G

[root@oracle swap] # free-m total used free shared buffers cachedMem: 1862 272 1590 1 20 107 Muhammad + buffers/cache: 1441718Swap: 4095 0 4095

Tags: Directory Space size entry format Activation hard disk system Zhongxin Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Redmi Shulou Tech Info MariaDB Xiaomi