linux如何無損調(diào)整分區(qū)大小
情況:
- home:500G
- root:50G
- root分區(qū)不夠用
思路:把home分區(qū)的空間劃一部分到root分區(qū)
# 設(shè)置home分區(qū)大小為200G,釋放300G空間 $ lvreduce -L 200G /dev/centos/home # 將空閑空間擴(kuò)展到root分區(qū) $ lvextend -l +100%FREE /dev/centos/root # 使用XFS文件系統(tǒng)自帶的命令集增加分區(qū)空間 $ xfs_growfs /dev/mapper/centos-root
實(shí)例
situation
掛載在根目錄的分區(qū) /dev/mapper/centos-root 爆滿,占用100%
$ df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos-root 50G 50G 19M 100% / devtmpfs 32G 0 32G 0% /dev tmpfs 32G 0 32G 0% /dev/shm tmpfs 32G 2.5G 29G 8% /run tmpfs 32G 0 32G 0% /sys/fs/cgroup /dev/mapper/centos-home 476G 33M 476G 1% /home /dev/sda1 497M 238M 259M 48% /boot tmpfs 6.3G 0 6.3G 0% /run/user/0
analyze
掛載在根目錄的分區(qū)空間太小,只有50G,而服務(wù)器 home 目錄為非常用目錄,掛在了近500G的空間。
思路:從 centos-home 分區(qū)劃出300G空間到 centos-root 分區(qū)。
operation
1.查看各分區(qū)信息
$ lvdisplay --- Logical volume --- LV Path /dev/centos/home LV Name home VG Name centos LV UUID 1fAt1E-bQsa-1HXR-MCE2-5VZ1-xzBz-iI1SLv LV Write Access read/write LV Creation host, time localhost, 2016-10-26 17:23:47 +0800 LV Status available # open 0 LV Size 475.70 GiB Current LE 121778 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:2 --- Logical volume --- LV Path /dev/centos/root LV Name root VG Name centos LV UUID lD64zY-yc3Z-SZaB-dAjK-03YM-2gM8-pfj4oo LV Write Access read/write LV Creation host, time localhost, 2016-10-26 17:23:48 +0800 LV Status available # open 1 LV Size 50.00 GiB Current LE 12800 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0
2.減少/home分區(qū)空間
# 釋放 /dev/centos/home 分區(qū) 300G 的空間 # 命令設(shè)置 /dev/centos/home 分區(qū) 200G空間 $ lvreduce -L 200G /dev/centos/home WARNING: Reducing active logical volume to 200.00 GiB. THIS MAY DESTROY YOUR DATA (filesystem etc.) Do you really want to reduce centos/home? [y/n]: y Size of logical volume centos/home changed from 475.70 GiB (121778 extents) to 200.00 GiB (51200 extents). Logical volume centos/home successfully resized.
3.增加/root分區(qū)空間
$ lvextend -l +100%FREE /dev/centos/root Size of logical volume centos/root changed from 50.06 GiB (12816 extents) to 325.76 GiB (83394 extents). Logical volume centos/root successfully resized.
4.擴(kuò)展XFS文件空間大小
$ xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=256 agcount=4, agsize=3276800 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0 spinodes=0
data = bsize=4096 blocks=13107200, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal bsize=4096 blocks=6400, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 13107200 to 85395456
完成
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- XenServer 虛擬機(jī)擴(kuò)容LVM磁盤分區(qū)的方法
- linux大于2T的磁盤使用GPT分區(qū)的方法分享
- linux下查看swap分區(qū)被哪些進(jìn)程占用實(shí)現(xiàn)腳本
- linux文件系統(tǒng)調(diào)整大小的方法(linux調(diào)整分區(qū)大小)
- Linux下掛載硬盤分區(qū)的幾種方法
- Linux 自動(dòng)分區(qū)、格式化、掛載腳本詳解
- 詳解Centos/Linux下調(diào)整分區(qū)大小(以home和根分區(qū)為例)
- 如何解決Linux系統(tǒng)下Docker占滿分區(qū)的問題
- 詳解Linux 虛擬機(jī)根分區(qū)磁盤擴(kuò)充空間記錄
- Linux中對(duì)lvm邏輯卷分區(qū)大小的調(diào)整教程(針對(duì)xfs與ext4不同文件系統(tǒng))
相關(guān)文章
詳解CentOS如何使用NTP同步時(shí)間服務(wù)器
在Linux系統(tǒng)中,時(shí)間同步對(duì)于各種應(yīng)用是非常關(guān)鍵的,例如,系統(tǒng)日志和許多監(jiān)控應(yīng)用程序都需要在多個(gè)服務(wù)器之間保持時(shí)間同步,NTP協(xié)議是一種常見的協(xié)議,它使得您可以在系統(tǒng)之間同步時(shí)間,下面我們將詳細(xì)討論CentOS如何使用NTP同步時(shí)間服務(wù)器,需要的朋友可以參考下2023-11-11
Apache多虛擬主機(jī)多站點(diǎn)配置的兩種實(shí)現(xiàn)方案
本文介紹了在Apache服務(wù)器上配置多虛擬主機(jī)的兩種方案:基于IP地址的虛擬主機(jī)配置和基于域名的虛擬主機(jī)配置,詳細(xì)說明了每個(gè)方案的配置步驟,以實(shí)現(xiàn)在同一臺(tái)服務(wù)器上托管多個(gè)網(wǎng)站的目的,感興趣的可以了解一下2024-09-09
Apache日志管理和統(tǒng)計(jì)分析知識(shí)
Apache服務(wù)器具備強(qiáng)大的日志功能,管理員可以方便、準(zhǔn)備、及時(shí)地了解服務(wù)器狀況;可以更好地防范黑客的攻擊2016-04-04
使用腳本實(shí)現(xiàn)故障時(shí)自動(dòng)重啟Apache
這篇文章主要介紹了使用腳本實(shí)現(xiàn)故障時(shí)自動(dòng)重啟Apache,需要的朋友可以參考下2014-12-12
centos 6.8命令行下使用pptpsetup進(jìn)行pptp撥號(hào)的實(shí)現(xiàn)方法
centos 6.8 命令行下可使用pptpsetup進(jìn)行pptp撥號(hào),首先安裝ppp,pptp和pptp-setup三個(gè)包,使用pptpsetup進(jìn)行連接,下面給大家介紹的非常詳細(xì),感興趣的朋友一起看看吧2016-10-10
Apache Rewrite url重定向功能的簡(jiǎn)單配置
Rewrite url重定向就是實(shí)現(xiàn)URL的跳轉(zhuǎn)和隱藏真實(shí)地址,基于Perl語言的正則表達(dá)式規(guī)范。平時(shí)幫助我們實(shí)現(xiàn)擬靜態(tài),擬目錄,域名跳轉(zhuǎn),防止盜鏈等2010-08-08

