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 的功能就是在应付物理内存不足的情况下所造成的内存延伸记 ...
随机推荐
- 2.常用快捷键.md
[toc] 1.mian函数补全 在IntelJ中和Eclipse中稍有不同,在Eclipse中,输入main再按Alt+/即可自动补全main函数,但是在IntellJ中则是输入psvm,选中即可 ...
- SOA与EBS集成_Package 调用维护
介绍SOA Suite与EBS集成成,使用PACKAGE调用集成的组合程序的运维方法: 1.打开组合程序,在oracle adapter上右键,选择edit,在配置向导中跳转到第五步,确认组合程序调用 ...
- Apache Commons DbUtils Problem
- Bootstrap_排版_列表
一.基本列表 <h5>普通列表</h5> <ul> <li>列表项目</li> <li>列表项目</li> < ...
- centos 6.5 服务器安装 (LNMP ntfs文件支持 PHP-RPM CHROOT沙盒)
centos 6.5 最小化安装 进入系统 手动开启网卡 #ifconfig eth0 //(默认会自动获得ip) 修改网站配置文件,默认开启 #cd /etc/sysconfig/ne ...
- win10 64bit 安装scrapy-1.1
0.环境说明 win10 64bit,电脑也是64bit的处理器,电脑装有vs2010 64bit,但是为了保险起见,只试验了32位的安装,等有时间了,再试下64位的安装.如无特殊说明,一切操作都是在 ...
- Python的多线程实现
概述 Python虚拟机使用GIL(Global Interpreter Lock,全局解释器锁)来实现互斥线程对共享资源的访问,暂时无法利用多处理器的优势. Python中,thread和threa ...
- Ppthon基础学习之Dict
一.什么是字典? 字典是Python语言中唯一的映射类型. 映射类型对象里哈希值(键,key)和指向的对象(值,value)是一对多的的关系,通常被认为是可变的哈希表. 字典对象是可变的,它是一个容器 ...
- 学c语言做练习之文件
打开两个文件,让程序打印第一个文件的第一行,第二个文件的第一行,第一个文件的第二行,第二个文件的第二行,依此类推,直到打印完行数较多的文件的最后一行. #include<stdio.h> ...
- 一个md5加密的工具类,用的虚拟机的包,不需要额外导包
package com.yun.park.service.utils;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import jav ...