本站使用了 Pjax 等基于 JavaScript 的开发技术,但您的浏览器已禁用 JavaScript,请开启 JavaScript 以保证网站正常显示!

DAY 2 Centos 7.6 Ubuntu 16.04 Debian 9.9 多硬盘扩容(Raid 0)

1.进入系统用 lsblk 和 df -h 查看磁盘分区情况
lsblk命令 用于列出所有可用块设备的信息,而且还能显示他们之间的依赖关系

[root@v2ray ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
vda    253:0    0   25G  0 disk 
├─vda1 253:1    0   24G  0 part /
└─vda2 253:2    0 1023M  0 part [SWAP]

可以看到还有一个没有使用的硬盘叫sdb

2.首先添加磁盘分区

fdisk /dev/sdb

命令动作

Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

输入n新建分区
然后一路默认,最后在输入w写入
示例
使用lsblk查看分区是否建立成功
查看新建分区

3.开始扩容
3.1创建物理卷:

[root@localhost ~]# lvm
lvm> pvcreate /dev/sdb1

3.2查看物理卷和卷组:

lvm> pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               centos
  PV Size               <1.91 TiB / not usable 3.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              500255
  Free PE               0
  Allocated PE          500255
  PV UUID               3l9glP-2Meh-UuQK-d1gf-mj0O-O90z-CJujR8
   
  "/dev/sdb1" is a new physical volume of "<1.91 TiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb1
  VG Name               
  PV Size               <1.91 TiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               fkDKLf-fZD5-W885-Ra52-192V-J03q-yg1OV2
   
lvm> vgdisplay
  --- Volume group ---
  VG Name               centos
  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               <1.91 TiB
  PE Size               4.00 MiB
  Total PE              500255
  Alloc PE / Size       500255 / <1.91 TiB
  Free  PE / Size       0 / 0   
  VG UUID               3eJ4aC-OcCg-9jT1-JxkH-n46a-SPke-mMR8J9

3.3将新创建的物理卷加入到卷组:

lvm> vgextend centos /dev/sdb1
  Volume group "centos" successfully extended
lvm> 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               <3.82 TiB
  PE Size               4.00 MiB
  Total PE              1000766
  Alloc PE / Size       500255 / <1.91 TiB
  Free  PE / Size       500511 / <1.91 TiB
  VG UUID               3eJ4aC-OcCg-9jT1-JxkH-n46a-SPke-mMR8J9

3.4可以看到卷组的Free size 增加了,将卷组剩余空间添加到逻辑卷/dev/centos/home

lvm> lvextend -l +100%FREE /dev/centos/home
  Size of logical volume centos/home changed from <1.86 TiB (486431 extents) to 3.76 TiB (986942 extents).
  Logical volume centos/home successfully resized.

3.5同步到文件系统,之前只是对逻辑卷扩容,还要同步到文件系统,实现扩容。
Centos7.6:

xfs_growfs /dev/centos/home

Ubuntu 16.4 && Debian9.0 :

root@piqiu:~# resize2fs /dev/piqiu-vg/root
resize2fs 1.43.4 (31-Jan-2017)
Filesystem at /dev/piqiu-vg/root is mounted on /; on-line resizing required
old_desc_blocks = 227, new_desc_blocks = 471
The filesystem on /dev/piqiu-vg/root is now 987244544 (4k) blocks long.

3.6然后再df -h查看挂载情况:
最终效果

物理卷PV(Physical Volumes)、卷组VG(Volume Groups) 、逻辑卷LV(Logical Volumes)
物理卷:一个物理卷指一块硬盘


 继续浏览关于 的文章

 本文最后更新于 2020/04/05 16:57:36,可能因经年累月而与现状有所差异

 引用转载请注明:极客俱乐部 > 运维 > DAY 2 Centos 7.6 Ubuntu 16.04 Debian 9.9 多硬盘扩容(Raid 0)