|
本帖最后由 jiawang 于 2025-2-24 15:44 编辑
1.创建要作为swap分区的文件:增加32GB大小的交换分区,则命令写法如下,其中的count等于想要的块的数量(bs*count=文件大小)。
[root@ home]# dd if=/dev/zero of=/home/swapfile bs=1M count=32768
记录了32768+0 的读入
记录了32768+0 的写出
34359738368字节(34 GB,32 GiB)已复制,23.478 s,1.5 GB/s
[root@ home]# ll
总用量 33554440
drwxr-xr-x. 13 oracle oinstall 4096 2月 18 17:08 oracle
drwxrwx--- 4 oracle oinstall 98 2月 18 22:01 oraInventory
-rw-r--r-- 1 root root 34359738368 2月 24 14:20 swapfile
drwx------. 14 oracle oinstall 4096 2月 18 14:34 ychcqmu
设置正确的权限:
[root@ home]# chmod 600 /home/swapfile
2.格式化为交换分区文件:
[root@ home]# mkswap /home/swapfile
正在设置交换空间版本 1,大小 = 32 GiB (34359734272 个字节)
无标签,UUID=cd562ca5-b3f9-4139-a3d8-e461a4c7740d
3.启用交换分区文件:
[root@ home]# swapon /home/swapfile
4.使系统开机时自启用,在文件/etc/fstab中添加一行:
/home/swapfile swap swap defaults 0 0
[root@ home ~]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Tue Feb 18 06:23:00 2025
#
# 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.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
/dev/mapper/ol_sjck-root / xfs defaults 0 0
UUID=f0e594e5-bd5c-4b55-8772-cdc93962597d /boot xfs defaults 0 0
UUID=7416-8BBA /boot/efi vfat umask=0077,shortname=winnt 0 2
/dev/mapper/ol_sjck-home /home xfs defaults 0 0
/home/swapfile swap swap defaults 0 0
[root@ home]# free -h
total used free shared buff/cache available
Mem: 125Gi 41Gi 33Gi 37Gi 89Gi 84Gi
Swap: 31Gi 0B 31Gi
|
|