使用实体分区创建SWAP

来源:互联网 发布:软件著作权资助 编辑:程序博客网 时间:2024/06/08 13:34
  1. 先进行分区的行为

[root@study ~]# gdisk /dev/vda

Command (? for help): n

Partition number (6-128, default 6):

First sector (34-83886046, default = 69220352) or {+-}size{KMGTP}:

Last sector (69220352-83886046, default = 83886046) or {+-}size{KMGTP}: +512M

Current type is 'Linux filesystem'

Hex code or GUID (L to show codes, Enter = 8300): 8200

Changed type of partition to 'Linux swap'

Command (? for help): p

Number Start (sector) End (sector) Size Code Name

6 69220352 70268927 512.0 MiB 8200 Linux swap # 重点就是产生这东西!

Command (? for help): w

Do you want to proceed? (Y/N): y

[root@study ~]# partprobe

[root@study ~]# lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

vda 252:0 0 40G 0 disk

.....(中间省略).....

`-vda6 252:6 0 512M 0 part

 

  1. 开始创建 swap 格式

[root@study ~]# mkswap /dev/vda6

Setting up swapspace version 1, size = 524284 KiB

no label, UUID=6b17e4ab-9bf9-43d6-88a0-73ab47855f9d

[root@study ~]# blkid /dev/vda6

/dev/vda6: UUID="6b17e4ab-9bf9-43d6-88a0-73ab47855f9d" TYPE="swap"

# 确定格式化成功!且使用 blkid 确实可以抓到这个设备!

 

  1. 开始观察与载入看看

     

[root@study ~]# free

total used free shared buff/cache available

Mem: 1275140 227244 330124 7804 717772 875536 # 实体内存

Swap: 1048572 101340 947232 # swap 相关

# 我有 1275140K 的实体内存,使用 227244K 剩余 330124K ,使用掉的内存有

# 717772K 用在缓冲/高速缓存的用途中。至于 swap 已经有 1048572K 啰!这样会看了吧?!

[root@study ~]# swapon /dev/vda6

[root@study ~]# free

total used free shared buff/cache available

Mem: 1275140 227940 329256 7804 717944 874752

Swap: 1572856 101260 1471596 <==有看到增加了没?

[root@study ~]# swapon -s

Filename Type Size Used Priority

/dev/dm-1 partition 1048572 101260 -1

/dev/vda6 partition 524284 0 -2

# 上面列出目前使用的 swap 设备有哪些的意思!

[root@study ~]# nano /etc/fstab

UUID="6b17e4ab-9bf9-43d6-88a0-73ab47855f9d" swap swap defaults 0 0

# 当然要写入配置文件,只不过不是文件系统,所以没有挂载点!第二个字段写入 swap 即可。

0 0
原创粉丝点击