文件方式:
1. 生成
生成一个1Gb(bs*count)的文件
[[email protected] ~]# dd if=/dev/zero of=/home/swap bs=1024 count=1024000
2. 标记
强制执行
mkswap -f /home/swap
3. 开启
swapon /home/swap
附:
[[email protected] ~]# dd if=/dev/zero of=/home/swap bs=1024 count=1024000 1024000+0 records in 1024000+0 records out 1048576000 bytes (1.0 GB) copied, 4.21348 s, 249 MB/s [[email protected] ~]# mkswap /home/swap mkswap: /home/swap: warning: don't erase bootbits sectors on whole disk. Use -f to force. Setting up swapspace version 1, size = 1023996 KiB no label, UUID=25e27794-76f4-4a0f-9a6a-9f90692396cf [[email protected] ~]# mkswap -f /home/swap Setting up swapspace version 1, size = 1023996 KiB no label, UUID=9eb85935-9021-4f51-bec2-38928d426aaa [[email protected] ~]# swapon /home/swap [[email protected] ~]#
时间: 2024-09-16 06:14:58