Chinaunix首页 | 论坛 | 博客
  • 博客访问: 320594
  • 博文数量: 88
  • 博客积分: 3020
  • 博客等级: 中校
  • 技术积分: 930
  • 用 户 组: 普通用户
  • 注册时间: 2009-02-13 09:32
文章分类

全部博文(88)

文章存档

2011年(1)

2009年(87)

我的朋友

分类: LINUX

2009-04-24 17:19:52

一、分区方式

1.创建swap分区,例如:
# 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-13054, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-13054, default 13054): +100M
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): w
The partition table has been altered!

2.同步分区表
# partprobe

3.设置交换区
# mkswap /dev/sdb1

4.编辑/etc/fstab文件
添加如下内容:
/dev/sdb1    swap    swap    defaults    0 0

5.启用swap分区
# swapon -a

6.验证swap分区是否启用
# swapon -s
Filename      Type         Size       Used   Priority
/dev/sdb1    partition    104380    0       -2

二、文件方式

1.创建文件
# dd if=/dev/zero of=/swapfile bs=1024 count=100

2.查看文件属性
# ls -lh /swapfile
-rw-r--r-- 1 root root 100K Apr 24 16:54 /swapfile

3.设置swap
# mkswap /swapfile

4.编辑/etc/fstab文件
添加如下内容:
/swapfile    swap    swap    defaults    0 0

5.启用swap
# swapon /swapfile

6.验证swap是否启用
# swapon -s
Filename     Type    Size    Used    Priority
/swapfile     file     92      0         -3
阅读(1026) | 评论(0) | 转发(0) |
0

上一篇:swap分区的知识

下一篇:单网卡配置多IP

给主人留下些什么吧!~~