编写脚本 creat_swap.sh 要求:
**执行脚本后系统会自动建立新swap
**这个自动建立的swap分区需要开机自动激活
[root@localhost ~]# vim /bin/create_swap.sh
[root@localhost ~]# chmod +x /bin/create_swap.sh ###加可执行权限
测试:
[root@localhost ~]# create_swap.sh /dev/vdb p +100M
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): Partition number (1-4, default 1): First sector (2048-20971519, default 2048): Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): Partition 1 of type Linux and of size 100 MiB is set
Command (m for help): Selected partition 1
Hex code (type L to list all codes): Changed type of partition 'Linux' to 'Linux swap / Solaris'
Command (m for help): The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.