> 文章列表 > Linux创建交换分区

Linux创建交换分区

Linux创建交换分区

1、分区

fdisk /dev/vdb
Welcome to fdisk (util-linux 2 .32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p):
Using default response p.
Partition number (2-4, default 2):
First sector (4196352-20971519, default 4196352):
Last sector, +sectors or +size{K,M,G,T,P} (4196352-20971519, default 20971519): +567M
Created a new partition 2 of type 'Linux' and of size 567 MiB.
Command (m for help): t
Partition number (1,2, default 2):
Hex code (type L to list all codes): 82
Changed type of partition 'Linux' to 'Linux swap / Solaris' .
Command (m for help): w
The partition table has been altered.
Syncing disks.

2、重新加载分区表

partprobe

3、格式化

mkswap /dev/vdb2

4、永久挂载

vim /etc/fstab

新增如下内容:

/dev/vdb2 swap swap defaults 0 0