VirtualBox 虚拟 CentOS 7 磁盘扩容
之前已经按照以上操作挂载到了 /data02,格式是 EXT4
现在希望按照下面方式,重新挂载并扩充 root 和 home

VirtualBox 虚拟CentOS7新增虚拟盘,并扩充 root和home 目录容量

报错 Device /dev/sdb excluded by a filter.

  1. pvcreate 创建逻辑卷报错

    pvcreate /dev/sdb

     Device /dev/sdb excluded by a filter.
    
  2. 查看逻辑卷组

vgs

  VG                 #PV #LV #SN Attr   VSize  VFree
  centos_centos7-189   1   2   0 wz--n- <7.00g    0 
  1. 对比 /dev/sdb1 和 /dev/sda1 ,为什么 pvcreate 不行?
    # file -s /dev/sdb1

     /dev/sdb1: Linux rev 1.0 ext4 filesystem data, UUID=4a62122e-66cc-4f4c-a78c-3b21f91a3ced (needs journal recovery) (extents) (64bit) (large files) (huge files)
    

    file -s /dev/sda1

     /dev/sda1: SGI XFS filesystem data (blksz 4096, inosz 512, v2 dirs)
    

    file -s /dev/sda2

     /dev/sda2: LVM2 PV (Linux Logical Volume Manager), UUID: YybaVN-sZR3-yrvS-t8mj-4HCh-cB1C-43l3Dw, size: 7515144192
    

难道是因为 EXT4 和 XFS ?

  1. 重新分区
    # parted /dev/sdb

     GNU Parted 3.1
     使用 /dev/sdb
     Welcome to GNU Parted! Type 'help' to view a list of commands.
     (parted) mklabel msdos                                                    
     警告: 正在使用 /dev/sdb 上的分区。
     忽略/Ignore/放弃/Cancel? Ignore                                           
     警告: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
     是/Yes/否/No? yes                                                         
     错误: Partition(s) 1 on /dev/sdb have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use.  As a result,
     the old partition(s) will remain in use.  You should reboot now before making further changes.
     忽略/Ignore/放弃/Cancel? Ignore                                           
     (parted) quit                                                             
     信息: You may need to update /etc/fstab.
    

    file -s /dev/sdb1

     /dev/sdb1: Linux rev 1.0 ext4 filesystem data, UUID=4a62122e-66cc-4f4c-a78c-3b21f91a3ced (needs journal recovery) (extents) (64bit) (large files) (huge files)
    
  2. 再来pvcreate
    # pvcreate /dev/sdb

       Can't open /dev/sdb exclusively.  Mounted filesystem?
       Can't open /dev/sdb exclusively.  Mounted filesystem?
    
  3. unmount
    # unmount /dev/sdb1
    # file -s /dev/sdb1

    /dev/sdb1: Linux rev 1.0 ext4 filesystem data, UUID=4a62122e-66cc-4f4c-a78c-3b21f91a3ced (extents) (64bit) (large files) (huge files)
    

    df -lh

    文件系统                              容量  已用  可用 已用% 挂载点
    /dev/mapper/centos_centos7--189-root  6.2G  3.0G  3.3G   48% /
    devtmpfs                              1.9G     0  1.9G    0% /dev
    tmpfs                                 1.9G     0  1.9G    0% /dev/shm
    tmpfs                                 1.9G   17M  1.9G    1% /run
    tmpfs                                 1.9G     0  1.9G    0% /sys/fs/cgroup
    /dev/sda1                            1014M  145M  870M   15% /boot
    tmpfs                                 379M     0  379M    0% /run/user/0
    

    /dev/sdb1不在文件系统中了!

    file -s /dev/sdb1

    /dev/sdb1: Linux rev 1.0 ext4 filesystem data, UUID=4a62122e-66cc-4f4c-a78c-3b21f91a3ced (extents) (64bit) (large files) (huge files)
    
  4. 再来pvcreate
    # pvcreate /dev/sdb

     WARNING: dos signature detected on /dev/sdb at offset 510. Wipe it? [y/n]: y
       Wiping dos signature on /dev/sdb.
       Physical volume "/dev/sdb" successfully created.
    

这次 OK了,后面就应该是一样的了!

VirtualBox 虚拟CentOS7新增虚拟盘,并扩充 root和home 目录容量

CentOS7 扩容时发现 /dev/mapper/centos-home 不存在,创建后登录终端显示 -bash-4.2

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐