国产chinesehdxxxx野外,国产av无码专区亚洲av琪琪,播放男人添女人下边视频,成人国产精品一区二区免费看,chinese丰满人妻videos

6.6 添加交換分區(qū)

2022-05-30 14:17 更新

SWAP(交換)分區(qū)是一種通過在硬盤中預(yù)先劃分一定的空間,然后將把內(nèi)存中暫時(shí)不常用的數(shù)據(jù)臨時(shí)存放到硬盤中,以便騰出物理內(nèi)存空間讓更活躍的程序服務(wù)來使用的技術(shù),其設(shè)計(jì)目的是為了解決真實(shí)物理內(nèi)存不足的問題。但由于交換分區(qū)畢竟是通過硬盤設(shè)備讀寫數(shù)據(jù)的,速度肯定要比物理內(nèi)存慢,所以只有當(dāng)真實(shí)的物理內(nèi)存耗盡后才會(huì)調(diào)用交換分區(qū)的資源。

交換分區(qū)的創(chuàng)建過程與前文講到的掛載并使用存儲(chǔ)設(shè)備的過程非常相似。在對(duì)/dev/sdb存儲(chǔ)設(shè)備進(jìn)行分區(qū)操作前,有必要先說一下交換分區(qū)的劃分建議:在生產(chǎn)環(huán)境中,交換分區(qū)的大小一般為真實(shí)物理內(nèi)存的1.5~2倍,為了讓大家更明顯地感受交換分區(qū)空間的變化,這里取出一個(gè)大小為5GB的主分區(qū)作為交換分區(qū)資源。在分區(qū)創(chuàng)建完畢后保存并退出即可:

    [root@linuxprobe ~]# fdisk /dev/sdb
    Welcome to fdisk (util-linux 2.23.2).
    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 0xb3d27ce1.
    Command (m for help): n
    Partition type:
    p primary (1 primary, 0 extended, 3 free)
    e extendedSelect (default p): p
    Partition number (2-4, default 2): 
    First sector (4196352-41943039, default 4196352): 此處敲擊回車
    Using default value 4196352
    Last sector, +sectors or +size{K,M,G} (4196352-41943039, default 41943039): +5G
    Partition 2 of type Linux and of size 5 GiB is set
    Command (m for help): p
    Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 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 label type: dos
    Disk identifier: 0xb0ced57f
     Device Boot Start End Blocks Id System
    /dev/sdb1 2048 4196351 2097152 83 Linux
    /dev/sdb2 4196352 14682111 5242880 83 Linux
    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.

使用SWAP分區(qū)專用的格式化命令mkswap,對(duì)新建的主分區(qū)進(jìn)行格式化操作:

    [root@linuxprobe ~]# mkswap /dev/sdb2
    Setting up swapspace version 1, size = 5242876 KiB
    no label, UUID=2972f9cb-17f0-4113-84c6-c64b97c40c75

使用swapon命令把準(zhǔn)備好的SWAP分區(qū)設(shè)備正式掛載到系統(tǒng)中。我們可以使用free -m命令查看交換分區(qū)的大小變化(由2047MB增加到7167MB):

    [root@linuxprobe ~]# free -m
    total used free shared buffers cached
    Mem: 1483 782 701 9 0 254
    -/+ buffers/cache: 526 957
    Swap: 2047 0 2047
    [root@linuxprobe ~]# swapon /dev/sdb2
    [root@linuxprobe ~]# free -m
    total used free shared buffers cached
    Mem: 1483 785 697 9 0 254
    -/+ buffers/cache: 530 953
    Swap: 7167 0 7167

為了能夠讓新的交換分區(qū)設(shè)備在重啟后依然生效,需要按照下面的格式將相關(guān)信息寫入到配置文件中,并記得保存:

    [root@linuxprobe ~]# vim /etc/fstab
    #
    # /etc/fstab
    # Created by anaconda on Wed May 4 19:26:23 2017
    #
    # Accessible filesystems, by reference, are maintained under '/dev/disk'
    # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
    #
    /dev/mapper/rhel-root / xfs defaults 1 1
    UUID=812b1f7c-8b5b-43da-8c06-b9999e0fe48b /boot xfs defaults 1 2
    /dev/mapper/rhel-swap swap swap defaults 0 0
    /dev/cdrom /media/cdrom iso9660 defaults 0 0 
    /dev/sdb1 /newFS xfs defaults 0 0 
    /dev/sdb2 swap swap defaults 0 0
以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)