选择想在哪个分区那个目录下建立分区文件 如下命令则是/home/swap 建一个2G的分区文件
[root@mycentos home]# dd if=/dev/zero of=/home/swap bs=1024 count=2097152
2097152+0 records in2097152+0 records out
2147483648 bytes (2.1 GB) copied, 6.21171 s, 346 MB/s
建完后看看
[root@household home]# dfFilesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 25778848 3858808 20609384 16% /
tmpfs 509984 0 509984 0% /dev/shm
格式化新建的分区
mkswap: /home/swap: warning: don't erase bootbits sectors
on whole disk. Use -f to force.
Setting up swapspace version 1, size = 2097148 KiB
no label, UUID=a5d0f1f5-539b-4851-bba6-dc5c49356a45