1. 通过新增分区扩展swap:
1.01 查看swap大小
[root@rhel6-server pub]# free -m
total used free shared buffers cached
Mem: 487 422 65 0 21 109
-/+ buffers/cache: 291 196
Swap: 499 0 499
1.02 查看当前swap使用了哪些设备
[root@rhel6-server pub]# swapon -s
Filename Type Size Used Priority
/dev/sda5 partition 511992 608 -1
1.03 创建一个新的分区用来扩充swap
[root@rhel6-server pub]# fdisk -cu /dev/sda
Command (m for help): p
Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders, total 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000cb393
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 411647 204800 83 Linux
/dev/sda2 411648 41371647 20480000 83 Linux
/dev/sda3 41371648 45467647 2048000 83 Linux
/dev/sda4 45467648 209715199 82123776 5 Extended
/dev/sda5 45469696 46493695 512000 82 Linux swap / Solaris
Command (m for help): n
First sector (46495744-209715199, default 46495744):
Using default value 46495744
Last sector, +sectors or +size{K,M,G} (46495744-209715199, default 209715199): +100M
Command (m for help): p
Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders, total 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000cb393
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 411647 204800 83 Linux
/dev/sda2 411648 41371647 20480000 83 Linux
/dev/sda3 41371648 45467647 2048000 83 Linux
/dev/sda4 45467648 209715199 82123776 5 Extended
/dev/sda5 45469696 46493695 512000 82 Linux swap / Solaris
/dev/sda6 46495744 46700543 102400 83 Linux
Command (m for help): t
Partition number (1-6): 6
Hex code (type L to list codes): 82
Changed system type of partition 6 to 82 (Linux swap / Solaris)
Command (m for help): p
Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders, total 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000cb393
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 411647 204800 83 Linux
/dev/sda2 411648 41371647 20480000 83 Linux
/dev/sda3 41371648 45467647 2048000 83 Linux
/dev/sda4 45467648 209715199 82123776 5 Extended
/dev/sda5 45469696 46493695 512000 82 Linux swap / Solaris
/dev/sda6 46495744 46700543 102400 82 Linux swap / Solaris
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
1.04 激活分区
[root@rhel6-server pub]# partx -a /dev/sda
BLKPG: Device or resource busy
error adding partition 1
BLKPG: Device or resource busy
error adding partition 2
BLKPG: Device or resource busy
error adding partition 3
BLKPG: Device or resource busy
error adding partition 4
BLKPG: Device or resource busy
error adding partition 5
[root@rhel6-server pub]# cat /proc/partitions
major minor #blocks name
8 0 104857600 sda
8 1 204800 sda1
8 2 20480000 sda2
8 3 2048000 sda3
8 4 1 sda4
8 5 512000 sda5
8 6 102400 sda6
1.05 格式化成swap分区
[root@rhel6-server pub]# mkswap /dev/sda6
Setting up swapspace version 1, size = 102396 KiB
no label, UUID=46bdaf51-2f2a-4a98-a0b7-fd023f54195a
1.06 启用swap分区
[root@rhel6-server pub]# swapon /dev/sda6
1.07 验证swap容量是否扩展
[root@rhel6-server pub]# free -m
total used free shared buffers cached
Mem: 487 426 60 0 22 111
-/+ buffers/cache: 292 195
Swap: 599 0 599
1.08 验证扩展的swap设备
[root@rhel6-server pub]# swapon -s
Filename Type Size Used Priority
/dev/sda5 partition 511992 596 -1
/dev/sda6 partition 102392 0 -2
1.09 调整swap设备的优先级(数值越大越优先,可以通过man swapon搜pri验证),swap优先级只能在挂载时指定
[root@rhel6-server pub]# swapon -p 1 /dev/sda6
swapon: /dev/sda6: swapon failed: Device or resource busy
[root@rhel6-server pub]# swapoff /dev/sda6
[root@rhel6-server pub]# swapon -p 1 /dev/sda6
[root@rhel6-server pub]# swapon -s
Filename Type Size Used Priority
/dev/sda5 partition 511992 596 -1
/dev/sda6 partition 102392 0 1
1.10 添加到fstab实现启动自动挂载[root@rhel6-server pub]# vim /etc/fstab
/dev/sda6 swap swap defaults,pri=1 0 0
[root@rhel6-server pub]# swapoff /dev/sda6
[root@rhel6-server pub]# swapon -s
Filename Type Size Used Priority
/dev/sda5 partition 511992 584 -1
[root@rhel6-server pub]# swapon -a
[root@rhel6-server pub]# swapon -s
Filename Type Size Used Priority
/dev/sda5 partition 511992 584 -1
/dev/sda6 partition 102392 0 1
2. 通过文件扩展swap
与通过分区扩展swap相比,不用创建分区,以文件代之
dd if=/dev/zero of=/swap.img bs=1M count=100
mkswap /swap.img
其他步骤完全与分区扩swap一致。
分享到:
相关推荐
修改swap分区大小方法,如果安装完linux后感觉swap分区不够用,可以尝试此方法。
用于faceswap源码所需要的全套安装包,包含已经配置好的python,设置环境变量既可以用
centos7配置swap交换内存空间 centos7配置swap交换内存空间 centos7配置swap交换内存空间
Linux修改Swap大小.
在Linux下安装Oracle 11g的时候,发现系统的swap分区太小了,为了不重新装系统,在此提供两种增加swap分区大小的方法。
Linux之如何在系统使用过程中配置SWAP分区
swap logisim emmm 电路
在Linux系统中,swap交换分区的作用类似于Windows系统中“虚拟内存”,当有程序被调入内存后,但是该程序又不是常被CPU所取用时,那么这些不常被使用的程序将会被放到硬盘的swap交换分区当中,而将速度较快的内存空间释放...
用于查看LINUX下进程占用SWAP大小
swap电路:当输入c=0时,输出x等于输入a,输出y等于输入b。当输入c=1时,则交换两输出,即输出y等于输入a
增大swap分区.txt增大swap分区.txt增大swap分区.txt增大swap分区.txt增大swap分区.txt增大swap分区.txt增大swap分区.txt增大swap分区.txt增大swap分区.txt
查看swap,增大swap.减小swap。卸载,格式化,挂载,开机自启
如果你的硬盘空间已经全部分配给其他分区,也没有多余的预算新添购硬盘,可以利用swap文件的方式增加虚拟的swap空间,不过执行性能会较实际的swap分区差。
Swap的调整对Linux服务器,特别是Web服务器的性能至关重要。通过调整Swap,有时可以越过系统性能瓶颈,节省系统升级费用。Swap空间的作用可简单描述为:当系统的物理内存不够用的时候,就需要将物理内存 中的一部分...
faceswap完整项目!
openwrt swap启用脚本
SWAP 使用logisim实现swap功能
windows下浏览ext、swap分区
本版本适用于CPU换脸:只需安装Anaconda3-2023.03-Windows-x86_64、解压faceswap-master,再用Anaconda配置faceswap-master即可完成部署 Anaconda3是CMD命令行工具,用于使用Anaconda命令部署和启动faceswap-master...
使用python完成的faceswap程序,使用单张图片完成对人脸的三维建模