cenots扩容vgextend centos /dev/sdb1时报错

时间:2024-03-14 18:19:01

在扩容时,执行

vgextend centos /dev/sdb1

cenots扩容vgextend centos /dev/sdb1时报错

cenots扩容vgextend centos /dev/sdb1时报错

创建卷组

[[email protected] ~]# vgcreate centos /dev/sda4
  Physical volume "/dev/sda4" successfully created
  Volume group "centos" successfully created
[[email protected] ~]# vgdisplay
  --- Volume group ---
  VG Name               centos
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               44.00 GiB
  PE Size               4.00 MiB
  Total PE              11263
  Alloc PE / Size       0 / 0   
  Free  PE / Size       11263 / 44.00 GiB
  VG UUID               3r3gTx-mrY2-6RAA-mrPt-RBnn-8BaV-3DlO1l
   

5、创建逻辑卷

[[email protected] ~]# lvcreate -L 43G -n root centos   # 创建
  Logical volume "root" created.
[[email protected] ~]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/centos/root
  LV Name                root
  VG Name                centos
  LV UUID                XNJ9Ut-0fmU-RQqq-AY2f-xC2j-9zhL-qLFuwY
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2019-08-13 11:31:18 +0800
  LV Status              available
  # open                 0
  LV Size                43.00 GiB
  Current LE             11008
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0
   
[[email protected] /]# mkfs.ext3 /dev/centos/root    #格式化逻辑分区
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
2818048 inodes, 11272192 blocks
563609 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
344 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
        4096000, 7962624, 11239424

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done  

 

6、挂载点,这里把新增逻辑分区,挂在到了 /data 目录

[[email protected] /]# mount /dev/centos/root /data
[[email protected] /]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/sda3                 18G  8.2G  9.6G  46% /
devtmpfs                 475M     0  475M   0% /dev
tmpfs                    489M   84K  489M   1% /dev/shm
tmpfs                    489M  7.1M  482M   2% /run
tmpfs                    489M     0  489M   0% /sys/fs/cgroup
/dev/sda1                297M  144M  154M  49% /boot
tmpfs                     98M   20K   98M   1% /run/user/42
tmpfs                     98M     0   98M   0% /run/user/0
/dev/mapper/centos-root   43G   52M   40G   1% /data
# 这里从逻辑分区 /dev/centos/root  变成了 /dev/mapper/centos-root,是个很奇怪的点,后续要弄清楚

 7、永久挂载

普通mount ,重启机器后,就会失效,如果想永久挂载,还需要修改配置文件

[[email protected] bin]# vim /etc/fstab   # 修改配置文件
#
# /etc/fstab
# Created by anaconda on Mon Jul  1 01:07:33 2019
#
# 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
#
UUID=f66e8bc7-ef82-473e-b565-df8ef7cfcda7 /                       xfs     defaults        0 0
UUID=c6e2743d-3e47-40a6-a74f-e429e1b3efc4 /boot                   xfs     defaults        0 0
UUID=681ef8e7-767e-47d4-84c4-7d705ac9dea4 swap                    swap    defaults        0 0
#/dev/cetnos/root   /data  xfs  auto 0 0 
#逻辑分区   挂载点   文件格式(与前面格式化文件格式保持一致)  defaults(默认是读写)  0 0 
/dev/mapper/centos-root /date                 ext3     defaults        0 0】
[[email protected] bin]# umount /dev/centos/root  #卸载挂载点 
[[email protected] bin]# mount -a                 #读取配置文件挂载
[[email protected] bin]# root                     #重启,查看挂载点,是否失效

 

备注

df -T -h   # 查看挂载的分区信息
parted -l  #查看所有的分区信息
 blkid

[[email protected]]# mkfs -t ext3 /dev/sda4
mke2fs 1.39 (29-May-2006)
/dev/sda4 isapparently in use by the system; will not make a filesystem here!
提示/dev/sda4 正在被使用。 /dev/sda4 正在被DM管理,所以我们创建文件系统时提示报错,我们手工的移除,就可以正常的创建文件系统,操作如下:
[[email protected] ]# dmsetup status
[[email protected]]# dmsetup remove_all
fuser -km /data   # 强制终止 data进程