linux增大SWAP分区

有两种方式:
第一种:分区
1、创建一个分区并将分区改为Linux swap / Solaris
[[email protected] ~]# fdisk /dev/sdb
Command (m for help): n
Command action
e   extended
p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-652, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-652, default 652): +500M
Command (m for help): p
Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1          62      497983+  83  Linux
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 82
Changed system type of partition 1 to 82 (Linux swap / Solaris)
Command (m for help): p
Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1          62      497983+  82  Linux swap / Solaris
Command (m for help): w
2、[[email protected] ~]# mkswap /dev/sdb1
3、[[email protected] ~]# swapon -a /dev/sdb1
4、在/etc/fstab 中加入
/dev/sdb1        swap        swap        defaults        0 0
第二种:文件
1、生成一个500M的文件
dd if=/dev/zero of=/swapfile bs=10M count=50
2、mkswap /swapfile
3、swapon /swapfile
4、在/etc/fstab 中加入
/swapfile        swap        swap        defaults        0 0
相关查看命令:
free
swapon -s
cat /proc/swaps
关闭命令
swapoff /swapfile        swapoff /dev/sdb1

猜你喜欢

转载自nzhzds.iteye.com/blog/1634986