1. 程式人生 > >Linux 根目錄滿了解決方法

Linux 根目錄滿了解決方法

ffffff eat 效果 nal process fdisk linu 需要 -o

今天正在做一個實驗,突然發現根目錄滿了,把這個過程記錄下來(當初創建的時候給根目錄分配的磁盤太小了.ahhhhh)

  1. 這是目前的磁盤情況
    技術分享圖片
  2. 我查看了一下磁盤/dev/sda還有空余的空間
    技術分享圖片
  3. 這種情況下,我只需要擴展vg的容量,然後給lv擴容即可,首先進行/dev/sda的磁盤分區,記得把新分的區改成8e
    [root@centos7 ~]# fdisk /dev/sda
    [root@centos7 ~]# partprobe /dev/sda  #使kernel重新讀取分區 信息,從而避免重啟系統。
  4. 再次查看,發現已經分區了一塊5G大小的空間
    技術分享圖片
  5. 創建pv
    [root@centos7 ~]# pvcreate /dev/sda3
    Physical volume "/dev/sda3" successfully created.
  6. 擴展vg,首先先查看一下vg的信息,以免出錯
    [root@centos7 ~]# vgs
    VG     #PV #LV #SN Attr   VSize  VFree
    centos   1   3   0 wz--n- 12.00g 4.00m
    [root@centos7 ~]# vgextend centos /dev/sda3
    Volume group "centos" successfully extended
    [root@centos7 ~]# vgs
    VG     #PV #LV #SN Attr   VSize  VFree
    centos   2   3   0 wz--n- 17.00g 5.00g
  7. 擴展lv,讓lv的大小增加5G
    [root@centos7 ~]# lvextend -L +5G /dev/mapper/centos-root
    Size of logical volume centos/root changed from 5.00 GiB (1280 extents) to 10.00 GiB (2560 extents).
    Logical volume centos/root successfully resized.
    [root@centos7 ~]# xfs_growfs /dev/mapper/centos-root  # 命令使系統重新讀取大小
    meta-data=/dev/mapper/centos-root isize=512    agcount=4, agsize=327680 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
    data     =                       bsize=4096   blocks=1310720, imaxpct=25
         =                       sunit=0      swidth=0 blks
    naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
    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 1310720 to 2621440    
  8. 查看效果,根目錄已經擴容
    [root@centos7 ~]# lvs  
    LV   VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
    app  centos -wi-ao----  5.00g                                                    
    root centos -wi-ao---- 10.00g                                                    
    swap centos -wi-ao----  2.00g
    [root@centos7 ~]# df -h
    文件系統                 容量  已用  可用 已用% 掛載點
    /dev/mapper/centos-root   10G  4.6G  5.4G   46% /
    devtmpfs                 471M     0  471M    0% /dev
    tmpfs                    488M     0  488M    0% /dev/shm
    tmpfs                    488M   21M  467M    5% /run
    tmpfs                    488M     0  488M    0% /sys/fs/cgroup
    /dev/mapper/centos-app   5.0G   33M  5.0G    1% /app
    /dev/sda1                 97M   60M   38M   62% /boot
    tmpfs                     98M   12K   98M    1% /run/user/42
    tmpfs                     98M     0   98M    0% /run/user/0

這是一種情況,還有另一種情況,我就不再舉例了,我前面博客有詳細介紹

Linux 根目錄滿了解決方法