• linux增大SWAP分区


    有两种方式:

    第一种:分区

    1、创建一个分区并将分区改为Linux swap / Solaris

    [root@16nn.com ~]# fdisk /dev/sdb

    Command (m for help): n
    Command action
    e   extended
    p   primary partition (1-4)
    p
    Partition number (1-4): 1
    First cylinder (1-652, default 1):
    Using default value 1
    Last cylinder or +size or +sizeM or +sizeK (1-652, default 652): +500M

    Command (m for help): p

    Disk /dev/sdb: 5368 MB, 5368709120 bytes
    255 heads, 63 sectors/track, 652 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes

       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1               1          62      497983+  83  Linux

    Command (m for help): t
    Selected partition 1
    Hex code (type L to list codes): 82
    Changed system type of partition 1 to 82 (Linux swap / Solaris)

    Command (m for help): p

    Disk /dev/sdb: 5368 MB, 5368709120 bytes
    255 heads, 63 sectors/track, 652 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes

       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1               1          62      497983+  82  Linux swap / Solaris

    Command (m for help): w

    2、[root@16nn.com ~]# mkswap /dev/sdb1

    3、[root@16nn.com ~]# swapon -a /dev/sdb1

    4、在/etc/fstab 中加入
    /dev/sdb1        swap        swap        defaults        0 0

    第二种:文件

    1、生成一个500M的文件

    dd if=/dev/zero of=/swapfile bs=10M count=50

    2、mkswap /swapfile

    3、swapon /swapfile

    4、在/etc/fstab 中加入
    /swapfile        swap        swap        defaults        0 0

    相关查看命令:

    free

    swapon -s

    cat /proc/swaps

    关闭命令

    swapoff /swapfile        swapoff /dev/sdb1

  • 相关阅读:
    Maven的作用
    redis持久化的几种方式
    3.持续交付实战用户管理服务
    MySQL 一些概念
    Git学习笔记--定制
    Git学习笔记--标签
    Git学习笔记--分支
    Git学习笔记--远程仓库
    Git学习笔记--版本控制
    Git学习笔记--init、add、commit
  • 原文地址:https://www.cnblogs.com/danghuijian/p/4400417.html
Copyright © 2020-2023  润新知