实现swap分区

实验:实现swap分区

swap 相当于虚拟内存,交换分区
本实验为增加swap分区大小

#新建一个分区
[root@CentOS6 ~]#fdisk /dev/sdb                添加硬盘sdb

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): n                    #新建分区
Command action
   e   extended
   p   primary partition (1-4)
                        p                #e为逻辑分区,p为主分区
Partition number (1-4): 2                #设定分区编号
First cylinder (6529-26108, default 6529):          #回车
Using default value 6529
Last cylinder, +cylinders or +size{K,M,G} (6529-26108, default 26108): +4G #分区大小为4G
Command (m for help): p

Disk /dev/sdb: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x7972ac2c

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        6528    52436128+  83  Linux
/dev/sdb2            6529        7051     4200997+  83  Linux

Command (m for help): t                    #修改分区信息
Partition number (1-4): 2
Hex code (type L to list codes): 82        #改为swap分区
Changed system type of partition 2 to 82 (Linux swap / Solaris)

Command (m for help): p

Disk /dev/sdb: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x7972ac2c

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        6528    52436128+  83  Linux
/dev/sdb2            6529        7051     4200997+  82  Linux swap / Solaris

Command (m for help): w                      #保存分区信息
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

分区已创建好
swapon /dev/sdb2   
vim /etc/fstab                                     #在其中写入以下信息
UUID=f2350b40-9169-4ef7-a4d7-c389217e192f swap   swap    pri=10          0 0  # 其中pri=10为取代原来的swap的优先级,原swap优先级为-1
swapoff        #禁用swap
swapon -a    #启用swap
cat /proc/swaps
swapon -s
free -h        #可以看到swap 又原来的2G变为了6G
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值