教程来啦https://i4t.com/5448.html
[root@ops ~]# dd if=/dev/zero of=/opt/swapfile bs=1M count=8096 接下来我们给/opt/swapfile格式修改为swap可读写格式
[[email protected] ~]# ls -lh /opt/swapfile -rw-r–r– 1 root root 8.0G May 17 18:02 /opt/swapfile #通过mkswap格式化文件 [[email protected] ~]# mkswap /opt/swapfile Setting up swapspace version 1, size = 8290300 KiB no label, UUID=bdef23e2-0b8f-4bbb-85f7-67487b336525 #后面接上刚刚生成的文件就可以 挂载swap分区
#这步骤实际上和硬盘初始化挂载步骤大部分相同 [[email protected] ~]# swapon /opt/swapfile swapon: /opt/swapfile: insecure permissions 0644, 0600 suggested. [[email protected] ~]# [[email protected] ~]# free -mh total used free shared buff/cache available Mem: 15G 3.1G 2.6G 16M 9.8G 11G Swap: 7.9G 0B 7.9G |