在pvcreate创建物理卷时出错:Device /dev/sdb not found.我的报错情况没有(or ignored by filtering),

原因说明:显然,在/dev/目录下应该是要存在一个硬盘分区的,即/dev/sdb。接下来我分两种情况来说明这个问题。

解决:

第一种情况:

①先列出硬盘分区:

[root@centos7 ~]# fdisk -l
 
Disk /dev/vda: 42.9 GB, 42949672960 bytes, 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0008e2e1
 
   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    83886046    41941999+  83  Linux
 
Disk /dev/vdb: 50.5 GB, 50465865728 bytes, 98566144 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

从列出的信息可以看到,我事先分配的硬盘分区为:/dev/vdb.但是没有sdb,那么我就改用vdb了。虽然有分区了,但是需要经过一系列操作才能生效。

②如下:

[root@centos7 ~]# fdisk /dev/vdb 
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 0xec0e9e9e.
 
Command (m for help): p
 
Disk /dev/vdb: 50.5 GB, 50465865728 bytes, 98566144 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xec0e9e9e
 
   Device Boot      Start         End      Blocks   Id  System
 
Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): 
Using default response p
Partition number (1-4, default 1): 1
First sector (2048-98566143, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-98566143, default 98566143): 
Using default value 98566143
Partition 1 of type Linux and of size 47 GiB is set
 
Command (m for help): p
 
Disk /dev/vdb: 50.5 GB, 50465865728 bytes, 98566144 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xec0e9e9e
 
   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048    98566143    49282048   83  Linux
 
Command (m for help): w
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
Syncing disks.

其中按提示操作 p打印 n新增 d 删除 w操作生效 q退出。

③查看分区是否完成分配。

[root@centos7 ~]# fdisk -l
 
Disk /dev/vda: 42.9 GB, 42949672960 bytes, 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0008e2e1
 
   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    83886046    41941999+  83  Linux
 
Disk /dev/vdb: 50.5 GB, 50465865728 bytes, 98566144 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xec0e9e9e
 
   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048    98566143    49282048   83  Linux

可以看到,出现了/dev/vdb1分区表已成功分配。

④更新分区表,并查看系统是否接收新的分区表。

[root@centos7 ~]# partprobe
[root@centos7 ~]# cat /proc/partitions
major minor  #blocks  name
 253        0   41943040 vda
 253        1   41941999 vda1
 253       16   49283072 vdb
 253       17   49282048 vdb1

上述信息出现vdb的两条信息说明已成功更新分区表。

⑤格式化新加的分区表

[root@centos7 ~]# mkfs.ext3 /dev/vdb1
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
3080192 inodes, 12320512 blocks
616025 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
376 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

那么到此就完成了,我的目标是完成硬盘分区来创建物理卷。

⑥查看系统有无PV

[root@centos7 ~]# pvscan
  No matching physical volumes found

没有。

⑦这里我将刚才创建的分区 /dev/vdb1作为物理卷。

[root@centos7 ~]# pvcreate /dev/vdb1
WARNING: ext3 signature detected on /dev/vdb1 at offset 1080. Wipe it? [y/n]: y
  Wiping ext3 signature on /dev/vdb1.
  Physical volume "/dev/vdb1" successfully created.

⑧再次查看

[root@centos7 ~]# pvscan
  PV /dev/vdb1                      lvm2 [<47.00 GiB]
  Total: 1 [<47.00 GiB] / in use: 0 [0   ] / in no VG: 1 [<47.00 GiB]
[root@centos7 ~]# pvdisplay 
  "/dev/vdb1" is a new physical volume of "<47.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/vdb1
  VG Name               
  PV Size               <47.00 GiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               p9pkiw-Pd5G-mKFY-eTqw-xYEv-56tJ-SLa4te

成功。

⑨查看物理卷组,发现没有,并创建volume group 为stack-volumes-lvmdriver-1

[root@centos7 ~]# vgs
[root@centos7 ~]# vgcreate stack-volumes-lvmdriver-1 /dev/vdb1 
  Volume group "stack-volumes-lvmdriver-1" successfully created
[root@centos7 ~]# vgs
  VG                        #PV #LV #SN Attr   VSize   VFree  
  stack-volumes-lvmdriver-1   1   0   0 wz--n- <47.00g <47.00g

完成。。。

如果想挂载硬盘到某个目录下,请继续。。。

⑩挂载硬盘到某一目录下,比如是/mnt.

# cd /mnt/
 
# mkdir home
 
挂载到/mnt/home
# mount /dev/vdb1 /mnt/home
 
查看
# df -h
 
把home下的东西拷到挂载的目录下,备份
# cp -a /home/* /mnt/home/ 
 
把home下的东西删干净
# rm -rf /home/* 
 
卸载硬盘
# umount /dev/vdb1
 
查看
# df -h

⑪设置开机挂载

# vi /etc/fstab
 
末尾增加一行
 
/dev/vdb1  /mnt/home  ext3  defaults  1  2
 
保存退出
 
查看 /home是否被挂载
# df -h
 
挂载/etc/fstab 中未挂载的分区
# mount -a
 
查看
# df -h

原文链接
https://blog.csdn.net/ANXIN997483092/article/details/82907016
推荐博客
https://blog.csdn.net/weixin_42186413/article/details/84338380

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐