日日噜噜夜夜狠狠久久丁香五月,人人摸人人操,人人妻人人,添人人爽,欧美一区,色婷婷综合缴情综,欧美午夜精品久久久久久浪潮

<>
文檔首頁(yè)> 網(wǎng)維技術(shù)> linux系統(tǒng)根目錄擴(kuò)容

linux系統(tǒng)根目錄擴(kuò)容

發(fā)布時(shí)間:2024-09-08 11:40       

硬盤(pán)根目錄空間不夠 把/home分區(qū)的容量擴(kuò)容到 /

這里以物理機(jī)為例,默認(rèn)安裝后 / 目錄只有50G,其余空間分在 /home 目錄

把 /home 刪除,剩余空間擴(kuò)容到 /

生產(chǎn)中的服務(wù)器操作有風(fēng)險(xiǎn),請(qǐng)謹(jǐn)慎操作,本教程不對(duì)任何數(shù)據(jù)丟失負(fù)責(zé)

[root@localhost ~]# df -h    #查看分區(qū)情況,準(zhǔn)備卸載/home和刪除/home所在的lv

Filesystem               Size  Used Avail Use% Mounted on

/dev/mapper/centos-root   50G  3.8G   47G   8% /

devtmpfs                 1.9G     0  1.9G   0% /dev

tmpfs                    1.9G     0  1.9G   0% /dev/shm

tmpfs                    1.9G   18M  1.9G   1% /run

tmpfs                    1.9G     0  1.9G   0% /sys/fs/cgroup

/dev/sda1               1014M  178M  837M  18% /boot

/dev/mapper/centos-home  245G   33M  245G   1% /home

tmpfs                    379M     0  379M   0% /run/user/0

 

[root@localhost ~]# fdisk -l  #查看磁盤(pán)lv名稱(chēng)

Disk /dev/sda: 322.1 GB, 322122547200 bytes, 629145600 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 4096 bytes

I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk label type: dos

Disk identifier: 0x000ed6dc

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *        2048     2099199     1048576   83  Linux

/dev/sda2         2099200   629145599   313523200   8e  Linux LVM

 

Disk /dev/mapper/centos-root: 53.7 GB, 53687091200 bytes, 104857600 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 4096 bytes

I/O size (minimum/optimal): 4096 bytes / 4096 bytes

 

Disk /dev/mapper/centos-swap: 4160 MB, 4160749568 bytes, 8126464 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 4096 bytes

I/O size (minimum/optimal): 4096 bytes / 4096 bytes

 

Disk /dev/mapper/centos-home: 263.2 GB, 263192576000 bytes, 514048000 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 4096 bytes

I/O size (minimum/optimal): 4096 bytes / 4096 bytes

 

[root@localhost ~]# umount /home  #卸載/home

 

注意:若出現(xiàn)無(wú)法卸載情況可使用umount -lf 命令強(qiáng)制卸載,如果 /home 目錄有數(shù)據(jù)請(qǐng)先備份數(shù)據(jù)

 

[root@localhost ~]# lvremove /dev/mapper/centos-home  # 刪除/home所在lv

Do you really want to remove active logical volume centos/home? [y/n]: y  #輸入y回車(chē)

  Logical volume "home" successfully removed

 

[root@localhost ~]# lvextend -l +100%FREE /dev/mapper/centos-root  #剩余容量全部分到 / ,回車(chē)后操作完成

  Size of logical volume centos/root changed from 50.00 GiB (12800 extents) to 2                                    95.12 GiB (75551 extents).

  Logical volume centos/root successfully resized.

meta-data=/dev/mapper/centos-root isize=512    agcount=4, agsize=3276800 blks

         =                       sectsz=4096  attr=2, projid32bit=1

         =                       crc=1        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=1

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

         =                       sectsz=4096  sunit=1 blks, lazy-count=1

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

data blocks changed from 13107200 to 77364224

 

[root@localhost ~]# xfs_growfs /dev/mapper/centos-root  #刷新文件系統(tǒng)(ext4的文件格式使用resize2fs,xfs的文件格式使用xfs_growfs)

 

[root@localhost ~]# df -h  # 根目錄現(xiàn)在已經(jīng)擴(kuò)容完成

Filesystem               Size  Used Avail Use% Mounted on

/dev/mapper/centos-root  296G  3.8G  292G   2% /

devtmpfs                 1.9G     0  1.9G   0% /dev

tmpfs                    1.9G     0  1.9G   0% /dev/shm

tmpfs                    1.9G   18M  1.9G   1% /run

tmpfs                    1.9G     0  1.9G   0% /sys/fs/cgroup

/dev/sda1               1014M  178M  837M  18% /boot

tmpfs                    379M     0  379M   0% /run/user/0

 

[root@localhost ~]# vi /etc/fstab   # 需要編輯此文件,刪除/home分區(qū)掛載,不然重啟后會(huì)無(wú)法開(kāi)機(jī)

 

# /etc/fstab

# Created by anaconda on Sat Mar  7 06:19:07 2020

#

# 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/centos-root /                       xfs     defaults        0 0

UUID=c02c8818-6a16-49df-a6f2-89e377303b9c /boot                   xfs     defaults        0 0

/dev/mapper/centos-home /home                   xfs     defaults        0 0    # 刪除這一行保存退出   

/dev/mapper/centos-swap swap                    swap    defaults        0 0