擴充根分區,各分區使用方式介紹,擴充根分區情況介紹

來源:互聯網
上載者:User

擴充根分區,各分區使用方式介紹,擴充根分區情況介紹

列出各分區使用方式:

# df -ThFilesystem              Type      Size  Used Avail Use% Mounted on/dev/mapper/centos-root xfs       997M  994M  2.9M 100% /devtmpfs                devtmpfs  915M     0  915M   0% /devtmpfs                   tmpfs     921M     0  921M   0% /dev/shmtmpfs                   tmpfs     921M   17M  905M   2% /runtmpfs                   tmpfs     921M     0  921M   0% /sys/fs/cgroup/dev/mapper/centos-usr  xfs       4.9G  1.6G  3.4G  33% /usr/dev/sda1               xfs        97M   66M   31M  69% /boot/dev/mapper/centos-var  xfs       2.4G  473M  1.9G  21% /var可以看見 /dev/mapper/centos-root 已經使用了100%,我們準備為它擴容。在VirtualBox中添加一塊新的虛擬磁碟:先關閉作業系統。在VirtualBox中選中當前VM,設定->儲存->控制器->SATA控制器,點擊表徵圖“添加虛擬硬碟”,建立一個虛擬硬碟。我增加了一塊3GiB大小的虛擬磁碟,儲存後再次啟動虛擬機器。建立新分區先看一下現有磁碟情況:# fdisk -l結果:Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x000940ec   Device Boot      Start         End      Blocks   Id  System/dev/sda1   *        2048      206847      102400   83  Linux/dev/sda2          206848    41943039    20868096   8e  Linux LVMDisk /dev/sdb: 3221 MB, 3221225472 bytes, 6291456 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/centos-swap: 2097 MB, 2097152000 bytes, 4096000 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/centos-usr: 5242 MB, 5242880000 bytes, 10240000 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/centos-root: 1048 MB, 1048576000 bytes, 2048000 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytes.........已經可以看到新磁碟/dev/sdb。對新磁碟進行分區:# fdisk /dev/sdb在fdisk的互動模式中,依次輸入:n  --建立新分區p  --建立主要磁碟分割<斷行符號>  --預設分區編號<斷行符號>  --預設起始扇區位置。<斷行符號>  --預設結束扇區位置。w  --寫入分區表這樣就把整個磁碟分成了一個區。再看一下現有磁碟情況:# fdisk -l已經多出了一個新分區:   Device Boot      Start         End      Blocks   Id  System/dev/sdb1            2048     6291455     3144704   83  Linux將新分區用於擴充/root先看一下卷分組:# vgdisplay -vFinding all volume groups    Finding volume group "centos"  --- Volume group ---  VG Name               centos  System ID               Format                lvm2  Metadata Areas        1  Metadata Sequence No  6  VG Access             read/write  VG Status             resizable  MAX LV                0  Cur LV                5  Open LV               5  Max PV                0  Cur PV                1  Act PV                1  VG Size               19.90 GiB  PE Size               4.00 MiB  Total PE              5094  Alloc PE / Size       5093 / 19.89 GiB  Free  PE / Size       1 / 4.00 MiB  VG UUID               vtJL08-7Jxi-5IqK-3fUg-Pben-682a-wiv2GL     --- Logical volume ---  LV Path                /dev/centos/root  LV Name                root  VG Name                centos  LV UUID                ZWTgoT-AMWs-g54v-dZA1-NQUj-mqGa-8tmr4U  LV Write Access        read/write  LV Creation host, time localhost, 2016-07-03 21:59:31 -0400  LV Status              available  # open                 1  LV Size                1000.00 MiB  Current LE             250  Segments               1  Allocation             inherit  Read ahead sectors     auto   currently set to     256  Block device           253:2  ...  ...  ...  --- Physical volumes ---  PV Name               /dev/sda2       PV UUID               fiVH1e-lwfi-63Lr-oIlK-GDZI-dcuZ-T04VlC  PV Status             allocatable  Total PE / Free PE    5094 / 1  可以看到當前卷分組名為"centos"。為之前新增的分區建立物理卷:# pvcreate /dev/sdb1提示是否擦除xfs簽名,我選了y:WARNING: xfs signature detected on /dev/sdb1 at offset 0. Wipe it? [y/n] y  Wiping xfs signature on /dev/sdb1.  Physical volume "/dev/sdb1" successfully created查看結果:# pvdisplay已經看到新建立的3GiB大小的物理卷:--- Physical volume ---  PV Name               /dev/sda2  VG Name               centos  PV Size               19.90 GiB / not usable 3.00 MiB  Allocatable           yes   PE Size               4.00 MiB  Total PE              5094  Free PE               1  Allocated PE          5093  PV UUID               fiVH1e-lwfi-63Lr-oIlK-GDZI-dcuZ-T04VlC     "/dev/sdb1" is a new physical volume of "3.00 GiB"  --- NEW Physical volume ---  PV Name               /dev/sdb1  VG Name                 PV Size               3.00 GiB  Allocatable           NO  PE Size               0     Total PE              0  Free PE               0  Allocated PE          0  PV UUID               VGXSAn-UiZ0-Fy40-eQxb-53xA-5hZM-3eGPg0擴充卷分組,"centos"是vgdisplay命令查到的卷分組名:# vgextend centos /dev/sdb1提示成功擴充。下面查看一下邏輯卷:# lvdisplay可以看到/dev/centos/root目前的LV Size是1000MiB。下面擴充邏輯卷/dev/centos/root:# lvextend -L +3G /dev/centos/root註:+3G是我們新增加的分區大小。擴充後,還要執行一步:# xfs_growfs /dev/centos/root將檔案系統擴大。完成。因為安裝CentOS用的xfs分區,所以使用命令xfs_growfs擴充檔案系統大小。否則的話使用resize2fs命令。查看結果:# df -Th/root已經擴充到4GiB:Filesystem              Type      Size  Used Avail Use% Mounted on/dev/mapper/centos-root xfs       4.0G  995M  3.1G  25% /devtmpfs                devtmpfs  915M     0  915M   0% /devtmpfs                   tmpfs     921M     0  921M   0% /dev/shmtmpfs                   tmpfs     921M  8.4M  913M   1% /runtmpfs                   tmpfs     921M     0  921M   0% /sys/fs/cgroup/dev/mapper/centos-usr  xfs       4.9G  1.6G  3.4G  33% /usr/dev/mapper/centos-home xfs       9.8G  391M  9.4G   4% /home/dev/mapper/centos-var  xfs       2.4G  469M  1.9G  20% /var/dev/sda1               xfs        97M   66M   31M  69% /boot

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.