23.用LVM扩展系统的根分区

扩展前根分区只有18G的总大小

[root@zcfmini7 ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 475M     0  475M   0% /dev
tmpfs                    487M     0  487M   0% /dev/shm
tmpfs                    487M  7.7M  479M   2% /run
tmpfs                    487M     0  487M   0% /sys/fs/cgroup
/dev/mapper/centos-root   18G  1.7G   16G  10% /
/dev/mapper/centos-home  497M   26M  472M   6% /home
/dev/sda1                497M  131M  367M  27% /boot
tmpfs                     98M     0   98M   0% /run/user/0

1.添加一块磁盘,使用fdisk -l 命令查看添加的磁盘,在分区格式化。

2.fdisk /dev/sdb 分区

[root@zcfmini7 ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xc4da08de.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-2097151, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151):
Using default value 2097151
Partition 1 of type Linux and of size 1023 MiB is set

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

3.mkfs.xfs  /dev/sdb1 ,格式化

[root@zcfmini7 ~]# mkfs.xfs /dev/sdb1
meta-data=/dev/sdb1              isize=512    agcount=4, agsize=65472 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=261888, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=855, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

4.把刚才新加的硬盘创建成物理卷。

pvcreate  /dev/sdb1


[root@zcfmini7 ~]# pvcreate /dev/sdb1
WARNING: xfs signature detected on /dev/sdb1 at offset 0. Wipe it? [y/n]: y
  Wiping xfs signature on /dev/sdb1.
  Physical volume "/dev/sdb1" successfully created.

用pvdisplay查看已经有这个pv了

[root@zcfmini7 ~]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               centos
  PV Size               19.51 GiB / not usable 3.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              4994
  Free PE               1
  Allocated PE          4993
  PV UUID               4N6qJl-Q2fN-3qAr-x3Cw-dg71-PPYt-CCYDhg

  "/dev/sdb1" is a new physical volume of "1023.00 MiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb1
  VG Name
  PV Size               1023.00 MiB
  Allocatable           NO
  PE Size               0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               QEBvxa-11hc-eymi-YzQs-yyhH-WQ4a-dnvq0z

5.把物理卷加到卷组里,卷组名为centos。

vgextend centos /dev/sdb1

[root@zcfmini7 ~]# vgextend centos /dev/sdb1
  Volume group "centos" successfully extended

用vgdisplay查看


[root@zcfmini7 ~]# vgdisplay
  --- Volume group ---
  VG Name               centos
  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               20.50 GiB
  PE Size               4.00 MiB
  Total PE              5249
  Alloc PE / Size       4993 / 19.50 GiB
  Free  PE / Size       256 / 1.00 GiB
  VG UUID               sUbWL3-IHcQ-Ov8I-OhMA-ER9n-LcMd-hnug2P

6.扩容lv

lvextend -l +100%FREE /dev/mapper/centos-root

[root@zcfmini7 ~]# lvextend -l +100%FREE /dev/mapper/centos-root
  Size of logical volume centos/root changed from <17.02 GiB (4356 extents) to <18.02 GiB (4612 extents).
  Logical volume centos/root successfully resized.

扩容文件系统

xfs_growfs /dev/mapper/centos-root

8.02 GiB (4612 extents).
  Logical volume centos/root successfully resized.
[root@zcfmini7 ~]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=512    agcount=4, agsize=1115136 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=4460544, 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 4460544 to 4722688

7.df -h查看,比原来大一个1G

[root@zcfmini7 ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 475M     0  475M   0% /dev
tmpfs                    487M     0  487M   0% /dev/shm
tmpfs                    487M  7.7M  479M   2% /run
tmpfs                    487M     0  487M   0% /sys/fs/cgroup
/dev/mapper/centos-root   19G  1.7G   17G  10% /
/dev/mapper/centos-home  497M   26M  472M   6% /home
/dev/sda1                497M  131M  367M  27% /boot
tmpfs                     98M     0   98M   0% /run/user/0

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值