博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Linux学习记录--内存交换空间的构建
阅读量:4212 次
发布时间:2019-05-26

本文共 2889 字,大约阅读时间需要 9 分钟。

内存交换空间的构建

 

我们知道CPU计算与数据的存储都会使用到内存,使用内存可以大大减少从磁盘读取的时间,但是当物理内存不足时,就需要暂时将用不到的程序和数据挪到内存交换空间(swap)

 

作法:

1.       创建分区(fdisk ,文件)

2.       格式化为swap

3.       启动

4.       查看

 

创建分区

举例

[root@bogon ~]# fdisk /dev/sdaThe number of cylinders for this disk is set to 2610.There is nothing wrong with that, but this is larger than 1024,and could in certain setups cause problems with:1) software that runs at boot time (e.g., old versions of LILO)2) booting and partitioning software from other OSs   (e.g., DOS FDISK, OS/2 FDISK)Command (m for help): pDisk /dev/sda: 21.4 GB, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes   Device Boot      Start         End      Blocks   Id  System/dev/sda1   *           1          13      104391   83  Linux/dev/sda2              14        1288    10241437+  83  Linux/dev/sda3            1289        1925     5116702+  83  Linux/dev/sda4            1926        2610     5502262+   5  Extended/dev/sda5            1926        2052     1020096   82  Linux swap / Solaris/dev/sda6            2053        2115      506016   83  LinuxCommand (m for help): tPartition number (1-6): 6Hex code (type L to list codes): 82Changed system type of partition 6 to 82 (Linux swap / Solaris)Command (m for help): pDisk /dev/sda: 21.4 GB, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes   Device Boot      Start         End      Blocks   Id  System/dev/sda1   *           1          13      104391   83  Linux/dev/sda2              14        1288    10241437+  83  Linux/dev/sda3            1289        1925     5116702+  83  Linux/dev/sda4            1926        2610     5502262+   5  Extended/dev/sda5            1926        2052     1020096   82  Linux swap / Solaris/dev/sda6            2053        2115      506016   82  Linux swap / SolarisCommand (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.The kernel still uses the old table.The new table will be used at the next reboot.Syncing disks.part[root@bogon ~]# partprobe

这里需要在进行设置下system ID

格式化

语法:mkswap设备名称

 

举例

[root@bogon ~]# mkswap /dev/sda6Setting up swapspace version 1, size = 518156 kB

 

启动|关闭

语法:swapon [-s]设备名称

swapoff设备名称

选项与参数:

-s:查看所有swap文件系统

 

举例1:启动swap

[root@bogon ~]# swapon /dev/sda6

 

举例2:查看所有swap

[root@bogon ~]# swapon -sFilename                                Type            Size    Used    Priority/dev/sda5                               partition       1020088 0       -1/dev/sda6                               partition       506008  0       -2

 

查看

语法:free

 

举例

total       used       free     shared    buffers     cachedMem:       2074972    1380996     693976          0     106740    1000288-/+ buffers/cache:     273968    1801004Swap:      1526096          0    1526096

可以看到Swap空间增加1526096

 

转载地址:http://tbumi.baihongyu.com/

你可能感兴趣的文章
SpringMVC 拦截器实现分析
查看>>
初始化(Map,List)容器类的容量会有一定的性能提升
查看>>
StringBuffer与StringBuilder浅析
查看>>
BoneCP数据源记录SQl比hibernate的show sql好用
查看>>
对Cookie的一点认识
查看>>
说一说hibernate的Get和Load
查看>>
如何修改tomcat的server信息增加服务器的安全
查看>>
浅谈tomcat的ThreadLocalLeakPreventionListener实现原理
查看>>
说一下多线程中用到的join
查看>>
扩展hibernate Criteria的Order使其支持sql片段(oracle)
查看>>
spring+mybatis利用interceptor(plugin)实现数据库读写分离
查看>>
NIO[SelectableChannel.register和Selector.select会有锁等待冲突]
查看>>
httpclient3.1的relaseConnection的misunderstand
查看>>
ReentrantLock为啥会出现不公平的场景
查看>>
图解LinkedHashMap的LRU
查看>>
关于select()方法最大轮询数限制的更正
查看>>
话说Connect reset异常
查看>>
Netty笔记:FrameDecoder
查看>>
spring使用注解暴露remoting服务
查看>>
Nio框架需要注意的两个问题(2)
查看>>