手动创建和挂载swap 分区
来源:互联网 发布:阿里云有什么用 编辑:程序博客网 时间:2024/06/14 04:57
转载自:http://blog.chinaunix.net/uid-20649888-id-1746267.html
一、使用fdisk 在设备上创建swap分区。
1.创建分区
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (641-1566, default 641):
Using default value 641
Last cylinder or +size or +sizeM or +sizeK (641-890, default 890):
Using default value 890
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (641-1566, default 641):
Using default value 641
Last cylinder or +size or +sizeM or +sizeK (641-890, default 890):
Using default value 890
Command (m for help): p
Disk /dev/sda: 12.8 GB, 12884901888 bytes
255 heads, 63 sectors/track, 1566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
255 heads, 63 sectors/track, 1566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 6 48163+ 83 Linux
/dev/sda2 7 515 4088542+ 83 Linux
/dev/sda3 516 1566 8442157+ 5 Extended
/dev/sda5 891 1015 1004031 83 Linux
/dev/sda6 1016 1566 4425876 83 Linux
/dev/sda7 516 640 1004031 83 Linux
/dev/sda8 641 890 2008093+ 83 Linux
/dev/sda1 * 1 6 48163+ 83 Linux
/dev/sda2 7 515 4088542+ 83 Linux
/dev/sda3 516 1566 8442157+ 5 Extended
/dev/sda5 891 1015 1004031 83 Linux
/dev/sda6 1016 1566 4425876 83 Linux
/dev/sda7 516 640 1004031 83 Linux
/dev/sda8 641 890 2008093+ 83 Linux
2.指定分区类型为linux swap。这里的/dev/sda5就是我们要做swap的分区。
Command (m for help): t
Partition number (1-8): 5
Hex code (type L to list codes): 82
Command (m for help): t
Partition number (1-8): 5
Hex code (type L to list codes): 82
Command (m for help): p
Disk /dev/sda: 12.8 GB, 12884901888 bytes
255 heads, 63 sectors/track, 1566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
255 heads, 63 sectors/track, 1566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 6 48163+ 83 Linux
/dev/sda2 7 515 4088542+ 83 Linux
/dev/sda3 516 1566 8442157+ 5 Extended
/dev/sda5 516 640 1004031 82 Linux swap
/dev/sda6 641 890 2008093+ 83 Linux
/dev/sda7 891 1015 1004031 83 Linux
/dev/sda8 1016 1566 4425876 83 Linux
3.使用mkswap命令设置交换分区
[root@libydwei /]# mkswap /dev/sda5
Setting up swapspace version 1, size = 1028120 kB
/dev/sda1 * 1 6 48163+ 83 Linux
/dev/sda2 7 515 4088542+ 83 Linux
/dev/sda3 516 1566 8442157+ 5 Extended
/dev/sda5 516 640 1004031 82 Linux swap
/dev/sda6 641 890 2008093+ 83 Linux
/dev/sda7 891 1015 1004031 83 Linux
/dev/sda8 1016 1566 4425876 83 Linux
3.使用mkswap命令设置交换分区
[root@libydwei /]# mkswap /dev/sda5
Setting up swapspace version 1, size = 1028120 kB
4.swapon 激活swap分区
[root@libydwei /]# swapon /dev/sda5
5.为了能够在系统启动是自动挂载。我们可以编辑/etc/fstab配置文件。
5.为了能够在系统启动是自动挂载。我们可以编辑/etc/fstab配置文件。
在文件末尾增加:
/dev/sda5 swap swap defaults 0 0
二、使用文件创建swap分区
bs blocksize ,每个块大小为1k.count=2048000。则总大小为2G的文件。
1. dd if=/dev/zero of=/swapfile bs=1k count=2048000
2. mkswap /swapfile
3. swapon /swapfile
4. 修改/etc/fstab使其启动时自动mount:
在/etc/fstab中增加如下语句:
/swapfile swap swap defaults 0 0
0 0
- 手动创建和挂载swap 分区
- 手动创建和挂载swap 分区
- 手动创建和挂载swap 分区
- 手动挂载swap分区
- 手动创建Linux Swap分区
- linux硬盘格式化和创建swap分区
- Linux手动添加swap分区
- centos 手动增加swap分区
- Linux手动添加SWAP分区
- centos 手动增加swap分区
- Linux 创建SWAP分区
- ubuntu创建swap分区
- linux 创建swap分区
- 创建swap分区
- 创建swap分区
- SWAP分区创建脚本
- 通过挂载磁盘解决SWAP分区和磁盘空间不足
- Linux | 手动扩展Swap分区大小
- 《深入浅出通信原理》学习笔记(目录)
- CTF实验吧-WEB专题-1
- 微信第三方授权获取UNIONID和用户信息
- JDE 开发转换日期类型到字符串
- Android番外04_ButterKnife的使用
- 手动创建和挂载swap 分区
- jdbc连接sqlite工具类
- logcat信息一闪而过,或者不停多闪烁的主要原因
- Linux常用命令-搜索
- SQL SERVER日常运维巡检系列之二——数据库
- Signalr简单示例
- 本文用于说明jacob与java2word冲突问题解决方案
- 触屏的左右滑动事件
- 如何设置eclipse默认编码为utf-8和MySql数据库插入乱码