Centos7创建swap
程序员文章站
2022-06-03 08:26:11
...
阿里云的ecs服务器默认时没有swap的,有的程序依赖swap
创建交换分区
[[email protected] opt]# dd if=/dev/zero of=/opt/swapfile bs=1024 count=1024000 #1024*1024000=1G
1024000+0 records in
1024000+0 records out
1048576000 bytes (1.0 GB) copied, 8.65484 s, 121 MB/s
[[email protected] opt]# mkswap /opt/swapfile
Setting up swapspace version 1, size = 1023996 KiB
no label, UUID=6e5464a3-49c9-40ad-b557-ac8d9f578289
[[email protected] opt]# swapon /opt/swapfile
swapon: /opt/swapfile: insecure permissions 0644, 0600 suggested.
[[email protected] ~]# tail -1 /etc/fstab
/opt/swapfile swap swap defaults 0 0
[[email protected] ~]# mount -a
###
在设置开机自动挂载时,使用了
UUID=6e5464a3-49c9-40ad-b557-ac8d9f578289 swap swap defaults 0 0
的参数,结果/var/log/message抛出了ERROR,没搞明白
[[email protected] ~]# cat /var/log/message
Dec 10 11:25:05 www systemd: Dependency failed for /dev/disk/by-uuid/8ff0bbda-22f9-40dc-b2f0-a455f1e65bfd.
Dec 10 11:25:05 www systemd: Dependency failed for Swap.
Dec 10 11:25:05 www systemd: Job swap.target/start failed with result 'dependency'.
Dec 10 11:25:05 www systemd: Job dev-disk-by\x2duuid-8ff0bbda\x2d22f9\x2d40dc\x2db2f0\x2da455f1e65bfd.swap/start failed with result 'dependency'.
Dec 10 11:25:05 www systemd: Job dev-disk-by\x2duuid-8ff0bbda\x2d22f9\x2d40dc\x2db2f0\x2da455f1e65bfd.device/start failed with result 'timeout'.