Adding swap space on linux system

CentOS 6 添加 Swap 分区:原理、避坑与生产级实操 Swap 是 Linux 内存管理的核心机制,本质是内核在物理内存紧张时用于暂存匿名页的磁盘缓冲区,而非简单的‘虚拟内存扩展’。其工作原理依赖于 page reclaim 策略、swappiness 权重计算及 swap header 元数据结构,在 CentOS 6(内核 2.6.32)中表现尤为特殊:swappiness=0 并不禁止 swap,而仅改变页回收倾向;文件型 swap 因 ext4 双重寻址引发 I/O 飙升;外挂硬盘因设备名漂移和 UUID 缺失导致启动失败。技术价值在于防止 OOM 崩 阅读详情

2.2. Adding Swap Space

Sometimes it is necessary to add more swap space after installation. Forexample, you may upgrade the amount of RAM in your system from 64 MB to128 MB, but there is only 128 MB of swap space. It might be advantageousto increase the amount of swap space to 256 MB if you performmemory-intense operations or run applications that require a largeamount of memory.

You have two options: add a swap partition or add a swap file. It isrecommended that you add a swap partition, but that can be difficult ifyou do not have any free space available.

To add a swap partition (assuming /dev/hdb2 is theswap partition you want to add):

  1. The hard drive can not be in use (partitions can not be mounted, and swap space can not be enabled). The partition table should not be modified while in use because the kernel may not properly recognize the changes. Data could be overwitten by writing to the wrong partition because the partition table and partitions mounted do not match. The easiest way to achieve this is to boot your system in rescue mode. Refer to Chapter 11 Basic System Recovery for instructions on booting into rescue mode. When prompted to mount the file system, select Skip.

    Alternately, if the drive does not contain any partitions in use, you can unmount them and turn off all the swap space on the hard drive with the swapoff command.

  2. Create the swap partition using parted:

    • At a shell prompt as root, type the command parted /dev/hdb, where /dev/hdb is the device name for the hard drive with free space.

    • At the (parted) prompt, type print to view the existing partitions and the amount of free space. The start and end values are in megabytes. Determine how much free space is on the hard drive and how much you want to allocate for a new swap partition.

    • At the (parted) prompt, typemkpartfs part-typelinux-swap startend, wherepart-type is one of primary,extended, or logical, start is thestarting point of the partition, andend is the end point of thepartition.

      WarningWarning
       

      Changes take place immediately; be careful when you type.

    • Exit parted by typing quit.

  3. Now that you have created the swap partition, use the command mkswap to setup the swap partition. At a shell prompt as root, type the following:

    mkswap /dev/hdb2
  4. To enable the swap partition immediately, type the following command:

    swapon /dev/hdb2
  5. To enable it at boot time, edit /etc/fstab to include:

    /dev/hdb2               swap                    swap    defaults        0 0

    The next time the system boots, it enables the new swap partition.

  6. After adding the new swap partition and enabling it, verify it is enabled by viewing the output of the command cat /proc/swaps or free.

To add a swap file:

  1. Determine the size of the new swap file in megabytes and multiple by 1024 to determine the block size. For example, the block size of a 64 MB swap file is 65536.

  2. At a shell prompt as root, type the following command with count being equal to the desired block size:

    dd if=/dev/zero of=/swapfile bs=1024 count=65536
  3. Setup the swap file with the command:

    mkswap /swapfile
  4. To enable the swap file immediately but not automatically at boot time:

    swapon /swapfile
  5. To enable it at boot time, edit /etc/fstab to include:

    /swapfile               swap                    swap    defaults        0 0

    The next time the system boots, it enables the new swap file.

  6. After adding the new swap file and enabling it, verify it is enabled by viewing the output of the command cat /proc/swaps or free.

Debian 8 Swap 配置实战:swapfile 方案与内核兼容性避坑指南 Swap 是 Linux 内存管理的关键机制,本质是为内核提供可控的页回收出口,支撑 OOM 防御与内存超分容错。其原理依赖内核版本、文件系统特性及 init 系统调度时机,在老旧发行版中尤为敏感。Debian 8(Jessie)基于 Linux 3.16 内核与 SysV init,存在 swapfile 格式签名兼容性、fstab 解析陷阱、启动时序依赖等独特约束。相比 Swap 分区,swapfile 因在线创建、规避分区调整风险、适配 checkroot.sh 启动阶段等优势,成为该环境更可靠的选择 阅读详情

相关推荐

hostapd.conf配置文档

##### hostapd configuration file ############################################## # Empty lines and lines starting with # are ignored # AP netdevice name (without 'ap' postfix, i.e., wlan0 uses wl

X_Nazgul的专栏 3万+

linux adding swap on,ubuntu14.04 adding swap on /dev/mapper 停住不动

现象:启动停止在如下输出不动:[ 12.868465] Adding 8384508k swap on /dev/mapper/database179--vg-swap_1. Priority:-1 extents:1 across:8384508k FS原因是显卡不支持高分辨率显示,解决方法:ssh远程登录,编辑/etc/default/grub,GRUB_CMDLINE_LINUX_DE...

weixin_28007513的博客 269

Qemu 文件系统支持swap ubuntu16.04

1.在ubuntu 制作一个64M的amge $dd if=/dev/zero of=swap.img bs=512 count=131072 2.通过mtd卡方式加载swap.img 到qemu qemu-system-aarch64 -machine virt -cpu cortex-a57 -machine type=virt -nographic -m 2048 -smp 2 -ke

IT民工老巢 551

linux adding swap on,求助;linux板卡运行报错

该楼层疑似违规已被系统折叠隐藏此楼查看此楼Adding 65532k swap on ./swapfile01. Priority:-2 extents:1 across:65532k SSirq 482: nobody cared (try booting with the "irqpoll" option)CPU: 0 PID: 2593 Comm: genload Not tainted...

weixin_34639033的博客 878

Ubuntu零基础入门到精通【3.5讲】:双系统安装 Ubuntu 与 Windows:从分区原理到系统引导,一次讲透!

🏆 本文收录于 《滚雪球学 Ubuntu》 专栏。 本专栏面向有一定计算机基础,但尚未系统学习 Linux / Ubuntu 的读者,采用“滚雪球式学习法”:先装好、再会用、再理解、再优化、再实战,带你从第一次进入 Ubuntu 桌面 / 终端开始,逐步掌握 Ubuntu 的日常使用、命令操作、软件安装、系统配置、开发环境搭建与服务器部署能力。

**My Coding Family** 1350

PCIe-2.2.7 Memory, I/O, and Configuration Request Rules in No-Flit Mode/Flit Mode & MSI/MSI-X

分层Requester ID管理RC层:管理总线号分配和重配置设备层:捕获并应用分配的Bus/Device NumberSwitch层:保持Transaction ID不变,使用正确ID生成自己的请求。

weixin_44700185的博客 104

ubuntu14.04 adding swap on /dev/mapper 停住不动

启动停止在类似输出: adding swap on /dev/mapper

plunger2011的专栏 4751

【信息科学与工程学】【产品体系】第二十篇 CDN网络 04

国内 CDN 厂商在多租户隔离场景下实现 μ_c 求解与 LRU 淘汰的结合,公开资料中并未确认任何一家直接部署了 AdaptSize 原版的完整组合。最接近的公开生产级方案是腾讯 CDN 的LACA,通过异常租户检测 + 局部 MRC + DP 搜索实现轻量多租户缓存分配,但其不直接求解 μ_c,而是通过调整租户配额 K_t 间接控制。外层(LACA 式):异常租户检测 → 局部 MRC → DP 搜索租户配额 K_t中层(AdaptSize 式)

weixin_49199313的博客 161

Linux硬盘分区管理与软 RAID 阵列搭建

本文详解 Linux 硬盘分区与软 RAID 存储运维。对比 MBR、GPT 分区方案,演示 fdisk、gdisk、parted 等工具分区、格式化、fstab 持久挂载操作,附带磁盘空间不足故障排查案例。介绍软硬 RAID 区别与各级 RAID 特性,使用 mdadm 实操 RAID0/1/5 阵列创建、热备添加、销毁,全程附带 CentOS 实操命令,适合运维人员实操学习。

2601_95728499的博客 187

告别手动抓信号!Synopsys AXI VIP的Port Monitor实战:5分钟搞定与Scoreboard的TLM连接

本文详细介绍了Synopsys AXI VIP的Port Monitor功能,帮助验证工程师快速实现与Scoreboard的TLM连接,5分钟内完成自动数据收集。通过实战指南和常见问题排查,提升验证效率,告别手动抓信号的繁琐流程。

weixin_30565327的博客 311

三甲医院网络架构与安全建设实战

华为OceanStor] [华为OceanStor][PACS存储双活] [HIS数据库同步]患者隐私 数据脱敏 天清Web防火墙动态脱敏策略。主数据中心 --[OTV专线]-- 备数据中心。实现医疗业务网/卫生专网/互联网三网隔离。核心业务配置(华为CE6865)自动备份配置(每天02:00)安全事件响应(30分钟SLA)漏洞扫描(每周日00:00)实现医疗物联网统一接入管控。五、等保2.0合规关键配置。堡垒机登录(双因素认证)四、医疗物联网安全方案。

有小小的远大抱负 1919

OS17.【Linux】进程基础知识(1)

介绍Linux进程的基本概念和管理方法。主要内容包括:1.进程的浅层定义 - 正在运行的程序;2.查看进程的多种方法(ps、top、/proc目录);3.进程管理实践(查看、终止进程);4.进程控制块(PCB)的组成和作用;5.Linux内核中task_struct结构体的详细解析。文章通过代码示例和命令演示,帮助读者理解进程标识符(PID)、工作目录、程序计数器等核心概念,并深入分析了操作系统如何通过PCB组织和管理进程。最后提供了Linux内核源代码中task_struct的完整定义,为后续学

zhangcoder的博客 记录学习轨迹~ 1055

别自己写CDC了!聊聊Xilinx AXI4-Stream Clock Converter IP里的寄存器管道模式到底有多省资源

本文探讨了Xilinx AXI4-Stream Clock Converter IP核的寄存器管道模式在FPGA设计中的高效资源利用。通过对比手工CDC实现,详细解析了IP核的精简化同步架构和时序收敛优势,并提供了实战案例和优化策略,帮助工程师快速实现时钟域转换,显著提升设计效率和性能。

weixin_33738555的博客 449

CPU 缓存 | 原理、映射、一致性

……

u013669912的博客 419

Yolov5自学笔记之一--从入门到入狱,功能强大不要乱用(实现yolov5的基本功能使用流程及训练自己的数据集)

零基础自学yolov5,学会简单使用和训练自己的数据集,在自己工作中使用

qq_41597915的博客 1万+

S32K144 UDSdoCAN 升级刷写实现笔记

本篇旨在描述如何开发“车规级”的软件升级程序,通过在S32K144平台上实现基于UDSdoCAN的刷写升级功能,带你一步步建立安全升级的“工程思维”,在这里既能收获经验还能获得工程源码、测试脚本,助你起飞,避坑提速!

汽车电子软件领域知识分享 819

Java Thread Pools — Deep Dive

Java线程池核心原理摘要 线程池作用:解决线程创建开销大、资源耗尽问题,通过复用固定线程、控制并发量、任务队列解耦任务提交与执行。Java提供Executor框架(Java 5+)实现。 核心类层次: Executor → ExecutorService → ThreadPoolExecutor(核心)/ScheduledThreadPoolExecutor(定时) ForkJoinPool:工作窃取,支持并行流和CompletableFuture ThreadPoolExecutor关键参数: core

quwenqian的专栏 391

ACS运动控制器编程语言

ACS运动控制器采用SPiiPlusLanguage(SPL)作为核心编程语言,该语言基于C语法设计,内置丰富的运动控制指令,支持点位运动、插补等复杂控制。控制器提供专用开发工具SPiiPlusManager和ACSStudio,支持图形化编程与调试。同时兼容TCP/IP、EtherCAT等多种扩展接口,便于与上位机或PLC集成。使用时需注意实时性优先级、轴参数匹配等关键事项。官方文档和示例程序为开发者提供了完善的学习资源。

StevenChen的博客 640

Kubernetes

habor,master,node1,node2都要做“1.安装docker” 1.安装docker 2.在harbor上生成key 3.编辑harbor配置文件 4.启动并验证 2.构建部署kubernetes所需主机 主机名 ip 配置 角色 harbor.timinglee.org 172.25.254.254 cpu1、mem 1G harbor仓库 master-node 172.25.254.100 cpu4、mem>4G master,k8s集群控制节点 node1 1

2301_81717288的博客 541

【vsomeip3 教程】SOME/IP 协议详解:基于 AUTOSAR AP 的实现指南

SOME/IP协议在AUTOSAR AP中的实现与应用指南 本文详细介绍了SOME/IP协议在AUTOSAR AP环境下的实现要点。作为一种面向服务的车载以太网中间件协议,SOME/IP支持多种通信模式和服务发现机制。文章系统阐述了协议的网络层要求、消息格式、序列化规范、传输层实现以及错误处理机制,重点分析了TCP/UDP传输特性、Service Discovery时间参数和SOME/IP-TP分段传输等核心技术。同时提供了性能优化、配置建议和兼容性考虑等最佳实践,帮助开发者在满足AUTOSAR规范的前提下

探索C++编程的奥秘,分享深入的技术见解和实践,旨在激发读者创造力与解决问题的思维。 617

大数据Alluxio面试题及参考答案

Alluxio 在大数据生态里的定位是作为数据编排层,能在不同计算框架和存储系统之间起到桥梁的作用。它的核心功能在于加速数据访问,让大数据应用能够更高效地使用数据。Alluxio 把数据存储和数据处理分离开来,使计算框架可以在不考虑底层存储细节的情况下访问数据,这样就提高了系统的灵活性和可扩展性。Alluxio 和 HDFS 既存在关联又有区别。从关联方面来看,HDFS 是一种广泛使用的分布式文件系统,很多大数据应用都将其作为主要的数据存储系统。Alluxio 可以和 HDFS 集成,把 HDFS 当作底层

大模型大数据攻城狮的专栏 875

ubuntu14.04 server adding swap on /dev/sda6 卡住

参考: https://blog.csdn.net/plunger2011/article/details/40380835。 原因是显卡不支持高分辨率显示,解决方法: ssh远程登录,编辑/etc/default/grub, GRUB_CMDLINE_LINUX_DEFAULT=”” 改为 GRUB_CMDLINE_LINUX_DEFAULT=”nomodeset” 退出 执...

混沌的博客 541

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

arm平台swap分区

swap有两种: 1.使用分区做为SWAP 2.使用文件做为SWAP 使用分区做为SWAP比较好,速度比文件的快,也不容易产生磁盘碎片所有应该尽量使用分区作为SWAP. 先说说使用文件做为SWAP吧: 一、因为做为SWAP的文件,必须是连续的,所以需要使用dd命令创建: [root@NEWLFS ~]#dd if=/dev/zero of=swapfile bs=1024 count=

崔建忠的专栏 1822

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

Adding Swap Files

 Adding Swap Files   If you do not have free disk space to create a swap partition and you do need to add swap space urgently, you can use a swap file as well. From a performance perspective, it does...

weixin_34005042的博客 156

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

上一篇: Binding MySql DataSources in Jboss EAP 7.0
下一篇: AOP技术基础
saturnyeung
博客等级 码龄15年 0粉丝 1原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值