[root@ wei ~]# gdisk /dev/sdb
Command (? for help): n #新建分区
Partition number (2-128,default2): #回车
First sector (34-41943006,default=2099200) or {+-}size{KMGTP}: #回车
Last sector (2099200-41943006,default=41943006) or {+-}size{KMGTP}:+1G #给1G
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter =8300): #回车
Changed type of partition to 'Linux filesystem'
Command (? for help): w #保存
Do you want to proceed? (Y/N): y
[root@ wei ~]# mkswap /dev/sdb2 //格式化
dd创建swap分区
[root@ wei ~]# dd if=/dev/zero of=swap_file bs=1M count=500500+0 records in
500+0 records out
524288000 bytes (524 MB) copied,1.99311 s,263 MB/s
[root@ wei ~]# chmod 0600 swap_file
[root@ wei ~]# mkswap -f swap_file //将文件格式化成swap [root@ wei ~]# swapon /root/swap_file //激活swap分区