对/home目录进行扩容

通过卷的一些命令,对/home目录进行扩容

-- 通过df -h 查看,/home目录大小不足。通过增加一块硬盘,扩大/home大小。

[root@wls10306-01 oracle]# df -h
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root   48G   26G   23G  54% /
devtmpfs               974M     0  974M   0% /dev
tmpfs                  991M     0  991M   0% /dev/shm
tmpfs                  991M   11M  980M   2% /run
tmpfs                  991M     0  991M   0% /sys/fs/cgroup
/dev/sda1             1014M  148M  867M  15% /boot
/dev/mapper/rhel-home  8.4G  8.2G  241M  98% /home
tmpfs                  199M     0  199M   0% /run/user/0
tmpfs                  199M   36K  199M   1% /run/user/1100
[root@wls10306-01 oracle]#

-- fdisk -l,查询到是/dev/sdb,进行分区后是/dev/sdb1


-- 创建pv

[root@wls10306-01 ~]# pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created.
[root@wls10306-01 ~]#

-- 扩展vg,vg扩展后,剩余空闲大小大约2G

[root@wls10306-01 ~]# vgdisplay
  --- Volume group ---
  VG Name               rhel
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <59.00 GiB
  PE Size               4.00 MiB
  Total PE              15103
  Alloc PE / Size       15102 / 58.99 GiB
  Free  PE / Size       1 / 4.00 MiB
  VG UUID               UCy2xg-RJGO-Zm4C-9tPd-lSog-tzMp-Ptf7FW

[root@wls10306-01 ~]# vgextend rhel /dev/sdb1
  Volume group "rhel" successfully extended
[root@wls10306-01 ~]# vgdisplay
  --- Volume group ---
  VG Name               rhel
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  5
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               60.99 GiB
  PE Size               4.00 MiB
  Total PE              15614
  Alloc PE / Size       15102 / 58.99 GiB
  Free  PE / Size       512 / 2.00 GiB
  VG UUID               UCy2xg-RJGO-Zm4C-9tPd-lSog-tzMp-Ptf7FW

[root@wls10306-01 ~]#

-- 查看逻辑卷,卷的大小,没有变化

 --- Logical volume ---
  LV Path                /dev/rhel/home
  LV Name                home
  VG Name                rhel
  LV UUID                uH4dWz-XASS-81f7-UjyX-wg0Y-JoIn-ll1oQE
  LV Write Access        read/write
  LV Creation host, time wls10306, 2020-01-06 08:39:35 +0800
  LV Status              available
  # open                 1
  LV Size                <8.37 GiB
  Current LE             2142
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:2

-- 扩展逻辑卷

[root@wls10306-01 ~]# lvextend -L +1.9G /dev/rhel/home
  Rounding size to boundary between physical extents: 1.90 GiB.
  Size of logical volume rhel/home changed from <8.37 GiB (2142 extents) to <10.27 GiB (2629 extents).
  Logical volume rhel/home successfully resized.
[root@wls10306-01 ~]#

-- 扩展后的大小

 --- Logical volume ---
  LV Path                /dev/rhel/home
  LV Name                home
  VG Name                rhel
  LV UUID                uH4dWz-XASS-81f7-UjyX-wg0Y-JoIn-ll1oQE
  LV Write Access        read/write
  LV Creation host, time wls10306, 2020-01-06 08:39:35 +0800
  LV Status              available
  # open                 1
  LV Size                <10.27 GiB
  Current LE             2629
  Segments               3
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:2

-- 查看/home的大小,还是8G多,使用resizfs2命令重新加载逻辑卷的大小 ,报错

[root@wls10306-01 ~]# resize2fs /dev/rhel/home
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block while trying to open /dev/rhel/home
Couldn't find valid filesystem superblock.
[root@wls10306-01 ~]#

-- 因为是xfs文件系统,所以要使用xfs_growfs命令调整xfs格式文件大小

[root@wls10306-01 ~]# xfs_growfs /dev/rhel/home
meta-data=/dev/mapper/rhel-home  isize=512    agcount=4, agsize=548352 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=2193408, 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 2193408 to 2692096
[root@wls10306-01 ~]#

-- 再次查看大小,扩展成功 。

[root@wls10306-01 ~]# df -h
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root   48G   26G   23G  54% /
devtmpfs               974M     0  974M   0% /dev
tmpfs                  991M     0  991M   0% /dev/shm
tmpfs                  991M   10M  981M   2% /run
tmpfs                  991M     0  991M   0% /sys/fs/cgroup
/dev/sda1             1014M  148M  867M  15% /boot
/dev/mapper/rhel-home   11G  8.2G  2.2G  80% /home
tmpfs                  199M     0  199M   0% /run/user/0
tmpfs                  199M     0  199M   0% /run/user/1100
[root@wls10306-01 ~]#  

END

你可能感兴趣的:(OS)