Creating a Swap Partition
Creating a Swap Partition
1. Use fdisk /dev/vda to open your disk in fdisk. (Use gdisk if you are using a disk with a GUID partition table.)
2. Press n to add a new partition. Specify start and stop cylinders and size.
3. Type t to change the partition type. If you are using fdisk, use partition type 82. If you are using gdisk, use partition type 8200.
4. Use mkswap to format the partition as swap space. Use, for instance, mkswap /dev/vda6 if the partition you have just created is /dev/vda6.
5. Type free -m . You see the amount of swap space that is currently allocated.
6. Use swapon to switch on the newly allocated swap space. If, for instance, the swap device you have just created is /dev/vda6, use swapon /dev/vda6 to activate the swap space.
7. Type free -m again. You see that the new swap space has been added to your server.
[root@rhel7 ~]# fdisk -l Disk /dev/sda: 21.5 GB, bytes, sectors
Units = sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disk label type: dos
Disk identifier: 0x0006c7ae Device Boot Start End Blocks Id System
/dev/sda1 * Linux
/dev/sda2 8e Linux LVM Disk /dev/sdb: MB, bytes, sectors
Units = sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disk label type: dos
Disk identifier: 0x0c16d904 Device Boot Start End Blocks Id System
/dev/sdb1 Linux Disk /dev/sdc: MB, bytes, sectors ----/dev/sdc是新添加的磁盘,未分区
Units = sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes Disk /dev/mapper/rhel-root: 18.8 GB, bytes, sectors
Units = sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes Disk /dev/mapper/rhel-swap: MB, bytes, sectors
Units = sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes [root@rhel7 ~]# fdisk /dev/sdc ---在/dev/sdc磁盘上划分出一个100M的Swab分区/dev/sdc1
Welcome to fdisk (util-linux 2.23.). Changes will remain in memory only, until you decide to write them.
Be careful before using the write command. Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x3990990c. Command (m for help): n
Partition type:
p primary ( primary, extended, free)
e extended
Select (default p): p
Partition number (-, default ):
First sector (-, default ):
Using default value
Last sector, +sectors or +size{K,M,G} (-, default ): +100M ---输入大小100M
Partition of type Linux and of size MiB is set Command (m for help): t
Selected partition
Hex code (type L to list all codes): L Empty NEC DOS Minix / old Lin bf Solaris
FAT12 Hidden NTFS Win Linux swap / So c1 DRDOS/sec (FAT-
XENIX root Plan Linux c4 DRDOS/sec (FAT-
XENIX usr 3c PartitionMagic OS/ hidden C: c6 DRDOS/sec (FAT-
FAT16 <32M Venix Linux extended c7 Syrinx
Extended PPC PReP Boot NTFS volume set da Non-FS data
FAT16 SFS NTFS volume set db CP/M / CTOS / .
HPFS/NTFS/exFAT 4d QNX4.x Linux plaintext de Dell Utility
AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt
AIX bootable 4f QNX4.x 3rd part Amoeba e1 DOS access
a OS/ Boot Manag OnTrack DM Amoeba BBT e3 DOS R/O
b W95 FAT32 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor
c W95 FAT32 (LBA) CP/M a0 IBM Thinkpad hi eb BeOS fs
e W95 FAT16 (LBA) OnTrack DM6 Aux a5 FreeBSD ee GPT
f W95 Ext'd (LBA) 54 OnTrackDM6 a6 OpenBSD ef EFI (FAT-12/16/
OPUS EZ-Drive a7 NeXTSTEP f0 Linux/PA-RISC b
Hidden FAT12 Golden Bow a8 Darwin UFS f1 SpeedStor
Compaq diagnost 5c Priam Edisk a9 NetBSD f4 SpeedStor
Hidden FAT16 < SpeedStor ab Darwin boot f2 DOS secondary
Hidden FAT16 GNU HURD or Sys af HFS / HFS+ fb VMware VMFS
Hidden HPFS/NTF Novell Netware b7 BSDI fs fc VMware VMKCORE
AST SmartSleep Novell Netware b8 BSDI swap fd Linux raid auto
1b Hidden W95 FAT3 DiskSecure Mult bb Boot Wizard hid fe LANstep
1c Hidden W95 FAT3 PC/IX be Solaris boot ff BBT
1e Hidden W95 FAT1 Old Minix
Hex code (type L to list all codes):
Changed type of partition 'Linux' to 'Linux swap / Solaris' Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only) Command (m for help): p Disk /dev/sdc: MB, bytes, sectors
Units = sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disk label type: dos
Disk identifier: 0x3990990c Device Boot Start End Blocks Id System
/dev/sdc1 Linux swap / Solaris Command (m for help): w
The partition table has been altered! Calling ioctl() to re-read partition table.
Syncing disks.
[root@rhel7 ~]# fdisk -l Disk /dev/sda: 21.5 GB, bytes, sectors
Units = sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disk label type: dos
Disk identifier: 0x0006c7ae Device Boot Start End Blocks Id System
/dev/sda1 * Linux
/dev/sda2 8e Linux LVM Disk /dev/sdb: MB, bytes, sectors
Units = sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disk label type: dos
Disk identifier: 0x0c16d904 Device Boot Start End Blocks Id System
/dev/sdb1 Linux Disk /dev/sdc: MB, bytes, sectors
Units = sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disk label type: dos
Disk identifier: 0x3990990c Device Boot Start End Blocks Id System
/dev/sdc1 Linux swap / Solaris Disk /dev/mapper/rhel-root: 18.8 GB, bytes, sectors
Units = sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes Disk /dev/mapper/rhel-swap: MB, bytes, sectors
Units = sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes [root@rhel7 ~]# mkswap /dev/sdc1 --格式化/dev/sdc1为swap分区
Setting up swapspace version , size = KiB
no label, UUID=b74fbc00-3f2e-4dea-99da-a17de3f798c3
[root@rhel7 ~]# swapon /dev/sdc1 --激活swap分区
[root@rhel7 ~]# free -m --可以看到swap增加了100M
total used free shared buff/cache available
Mem: 1840 91 1603 8 144 1605
Swap: 2147 0 2147
[root@rhel7 ~]#
Creating a Swap Partition的更多相关文章
- How To Create/Extend Swap Partition In Linux Using LVM
https://www.2daygeek.com/how-to-create-extend-swap-partition-in-linux-using-lvm/ BY RAMYA NUVVULA · ...
- How To Add Swap on Ubuntu 14.04
https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04 How To Add Swap on ...
- How To Add Swap Space on Ubuntu 16.04
Introduction One of the easiest way of increasing the responsiveness of your server and guarding aga ...
- 如何在Linux上使用文件作为内存交换区(Swap Area)
交换区域(Swap Area)有什么作用? 交换分区是操作系统在内存不足(或内存较低)时的一种补充.通俗的说,如果说内存是汽油,内存条就相当于油箱,交换区域则相当于备用油箱. Ubuntu Linux ...
- Linux Swap交换分区介绍总结
Swap交换分区概念 什么是Linux swap space呢?我们先来看看下面两段关于Linux swap space的英文介绍资料: Linux divides its physical RA ...
- 内存使用空间之swap建置[转]
http://www.cnblogs.com/ggjucheng/archive/2012/08/22/2651502.html 内存置换空间(swap)之建置 安装时一定需要的两个 partitio ...
- UNIX / Linux: 2 Ways to Add Swap Space Using dd, mkswap and swapon
UNIX / Linux: 2 Ways to Add Swap Space Using dd, mkswap and swapon by RAMESH NATARAJAN on AUGUST 18, ...
- Adding Swap Files
Adding Swap Files If you do not have free disk space to create a swap partition and you do need to a ...
- Linux学习之CentOS(十六)-----内存置换空间(swap)之建置(转)
内存置换空间(swap)之建置 安装时一定需要的两个 partition 啰! 一个是根目录,另外一个就是 swap(内存置换空间), swap 的功能就是在应付物理内存不足的情况下所造成的内存延伸记 ...
随机推荐
- 【USACO 1.5.3】特殊的质数肋骨
[题目描述]农民约翰的母牛总是生产出最好的肋骨.你能通过农民约翰和美国农业部标记在每根肋骨上的数字认出它们. 农民约翰确定他卖给买方的是真正的质数肋骨,是因为从右边开始切下肋骨,每次还剩下的肋骨上的数 ...
- 配置was7、并部署发布项目!
1:进入服务器,选择WebSphere Application Server,进入server1,右侧进入服务器基础结构,进入java和进程管理,进入进程定义 2:在页面左边菜单中选择java虚拟机, ...
- dede 留言板访问的目录
D:\APMServ5.2.6\www\htdocs\xyhy\templets\plus guestbook.rar 文件 里面 DEDE留言簿的插件:
- Scrapy使用以及Xpath的一些坑, 再入剁手
scrapy爬虫: https:www.scrapy.org 本篇博客依托的项目: https://github.com/viciousstar/BitcointalkSpider/ 一. Scrap ...
- PQJ 1686(栈栈栈)
PQJ 1686(栈栈栈) 用栈解决问题 Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I6 ...
- a标签的 target 使用
<a target="_blank" href="www.baidu.com" onclick="return test()"> ...
- Solr4.8.0源码分析(11)之Lucene的索引文件(4)
Solr4.8.0源码分析(11)之Lucene的索引文件(4) 1. .dvd和.dvm文件 .dvm是存放了DocValue域的元数据,比如DocValue偏移量. .dvd则存放了DocValu ...
- KEIL C51 中嵌入汇编以及C51与A51间的相互调用
如何在 KEIL C51(v6.21) 中调用汇编函数的一个示例 有关c51调用汇编的方法已经有很多帖子讲到,但是一般只讲要点,很少有对整个过程作详细描述,对于初学者是不够的,这里笔者通过一个简单例子 ...
- 开启和关闭wifi的代码段
1.需要申请的权限android.permission.ACCESS_WIFI_STATE android.permission.CHANGE_WIFI_STATE android.permissio ...
- Windows 7 mklink命令详解
mklink是Windows 7下的一个类似于linux下In的命令,其作用是在NTFS文件系统中创建文件或目录的链接(类似于桌面快捷方式).如果加以利用其发挥的作用是非常的大的,不仅可以帮助我们节省 ...