溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

centos7怎么添加磁盤到根目錄下

發(fā)布時(shí)間:2021-09-03 13:42:02 來源:億速云 閱讀:198 作者:chen 欄目:建站服務(wù)器

這篇文章主要介紹“centos7怎么添加磁盤到根目錄下”,在日常操作中,相信很多人在centos7怎么添加磁盤到根目錄下問題上存在疑惑,小編查閱了各式資料,整理出簡(jiǎn)單好用的操作方法,希望對(duì)大家解答”centos7怎么添加磁盤到根目錄下”的疑惑有所幫助!接下來,請(qǐng)跟著小編一起來學(xué)習(xí)吧!

centos7中使用vg方式擴(kuò)充root分區(qū)

1.創(chuàng)建pv

fdisk /dev/sdb

輸入n增加分區(qū)

輸入p類型設(shè)置為:主分區(qū)

輸入1分區(qū)編號(hào)設(shè)置為1

回車 為默認(rèn)大小

回車 為默認(rèn) 大小

輸入w退出

2.把pv加入vg中,相當(dāng)于擴(kuò)充vg的大小

擴(kuò)展vg,使用vgextend命令

[root@localhost ~]# vgextend centos /dev/sdb1

  Volume group "centos" successfully extended

vgextend名字命令接的vg的名字,后面是磁盤的位置

3.我們成功把vg卷擴(kuò)展了,在用vgs查看一下

[root@localhost ~]# vgs

  VG     #PV #LV #SN Attr   VSize  VFree

  centos   2   2   0 wz--n- 39.50g 20.04g

[root@localhost ~]# lvs

  LV   VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert

  root centos -wi-ao---- 17.47g                                                   

  swap centos -wi-ao----  2.00g  <br><br>雖然我們把vg擴(kuò)展了,但是lv還沒有擴(kuò)展

4.擴(kuò)展lv,使用lvextend命令

[root@localhost ~]# lvextend -L +20G /dev/mapper/centos-root

  Size of logical volume centos/root changed from 17.47 GiB (4472 extents) to 37.47 GiB 

   (9592 extents).

  Logical volume root successfully resized.<br>-L 

指定擴(kuò)展多大的空間到lv中去,后面的/dev/mapper/centos-root是指定擴(kuò)展的文件位置,可在df-h中看見

查看lv大小

[root@localhost ~]# lvs

  LV   VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert

  root centos -wi-ao---- 37.47g                                                   

  swap centos -wi-ao----  2.00g  

查看df  -h中變化沒有

[root@localhost ~]# df -h

文件系統(tǒng)                 容量  已用  可用 已用% 掛載點(diǎn)

/dev/mapper/centos-root   18G  1.1G   17G    6% /

devtmpfs                 479M     0  479M    0% /dev

tmpfs                    489M     0  489M    0% /dev/shm

tmpfs                    489M  6.7M  483M    2% /run

tmpfs                    489M     0  489M    0% /sys/fs/cgroup

/dev/sda1                497M  125M  373M   25% /boot

tmpfs                     98M     0   98M    0% /run/user/0<br><br>沒有變化。

那么我們要使用[root@localhost ~]# xfs_growfs /dev/mapper/centos-root 命令使系統(tǒng)重新讀取大小

[root@localhost ~]# xfs_growfs /dev/mapper/centos-root

meta-data=/dev/mapper/centos-root isize=256    agcount=4, agsize=1144832 blks

         =                       sectsz=512   attr=2, projid32bit=1

         =                       crc=0        finobt=0

data     =                       bsize=4096   blocks=4579328, imaxpct=25

         =                       sunit=0      swidth=0 blks

naming   =version 2              bsize=4096   ascii-ci=0 ftype=0

log      =internal               bsize=4096   blocks=2560, version=2

         =                       sectsz=512   sunit=0 blks, lazy-count=1

realtime =none                   extsz=4096   blocks=0, rtextents=0

data blocks changed from 4579328 to 9822208

再使用df  -h查看

[root@localhost ~]# df -h

文件系統(tǒng)                 容量  已用  可用 已用% 掛載點(diǎn)

/dev/mapper/centos-root   38G  1.1G   37G    3% /

devtmpfs                 479M     0  479M    0% /dev

tmpfs                    489M     0  489M    0% /dev/shm

tmpfs                    489M  6.7M  483M    2% /run

tmpfs                    489M     0  489M    0% /sys/fs/cgroup

/dev/sda1                497M  125M  373M   25% /boot

tmpfs                     98M     0   98M    0% /run/user/0

到這里我們就成功擴(kuò)展了。

備注:我們可以自行生產(chǎn)vg組以及在新的vg中生成lv

vgcreate       創(chuàng)建新的vg組

lvcreate        在新的vg中創(chuàng)建新的lv,但是要指定對(duì)vg名字

vgreduce      把pv從vg中移除,若vg中只有一個(gè)pv則直接使用vgremove

到此,關(guān)于“centos7怎么添加磁盤到根目錄下”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識(shí),請(qǐng)繼續(xù)關(guān)注億速云網(wǎng)站,小編會(huì)繼續(xù)努力為大家?guī)砀鄬?shí)用的文章!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI