RHCSA-添加一个swap分区

[root@server0 ~]# fdisk /dev/vdb                  ////进入/dev/vdb磁盘

Command (m for help): n               ////创建分区

Partition type:

   p   primary (1 primary, 1 extended, 2 free)

   l   logical (numbered from 5)

Select (default p): l            ////选择l

Adding logical partition 6

First sector (2258944-20971519, default 2258944):

Using default value 2258944

Last sector, +sectors or +size{K,M,G} (2258944-20971519, default 20971519): +756M           ////配置分区大小756M

Partition 6 of type Linux and of size 756 MiB is set

 

Command (m for help): t               ////修改分区类型

Partition number (1,2,5,6, default 6): 6

Hex code (type L to list all codes): 82                ////82为linux swap类型

Changed type of partition 'Linux' to 'Linux swap / Solaris'

 

Command (m for help): w                    ////保存退出

 [root@server0 ~]# partprobe /dev/vdb              ////确认磁盘

[root@server0 ~]# mkswap /dev/vdb6               ////使用swap文件格式分区

Setting up swapspace version 1, size = 774140 KiB

no label, UUID=1ca89662-5f8a-4632-833b-7166669190b2

[root@server0 ~]# swapon /dev/vdb6                ////启动分区,可以使用-p设置优先级

 [root@server0 ~]# vim /etc/fstab                      ////挂载,设置开机自启

/dev/vdb6          swap      swap          defaults       0  0       ////挂载配置,如下图,若有配置优先级则需在defaults加,pir=值

在vim界面使用r ! blkid可以显示所有分区 和uuid,可以使用分区名或uuid进行挂载

RHCSA-添加一个swap分区_第1张图片

 

 [root@server0 ~]# mount -a            ////检查挂载结果

[root@server0 ~]# free              ////查询swap分区

             total       used       free     shared    buffers     cached

Mem:       1885320     981876     903444      17144       2032     465844

-/+ buffers/cache:     514000    1371320

Swap:       774140          0     774140

你可能感兴趣的:(计算机,服务器)