問題解決:pvcreate過程中錯誤Device /dev/sdb not found (or ignored by filtering)
阿新 • • 發佈:2018-10-31
在pvcreate建立物理卷時出錯:Device /dev/sdb not found.我的報錯情況沒有(or ignored by filtering),
原因說明:顯然,在/dev/目錄下應該是要存在一個硬碟分割槽的,即/dev/sdb。接下來我分兩種情況來說明這個問題。
解決:
第一種情況:
①先列出硬碟分割槽:
[[email protected] ~]# 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了。雖然有分割槽了,但是需要經過一系列操作才能生效。
②如下:
[[email protected] ~]# 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退出。
③檢視分割槽是否完成分配。
[[email protected] ~]# 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分割槽表已成功分配。
④更新分割槽表,並檢視系統是否接收新的分割槽表。
[[email protected] ~]# partprobe
[[email protected] ~]# cat /proc/partitions
major minor #blocks name
253 0 41943040 vda
253 1 41941999 vda1
253 16 49283072 vdb
253 17 49282048 vdb1
上述資訊出現vdb的兩條資訊說明已成功更新分割槽表。
⑤格式化新加的分割槽表
[[email protected] ~]# 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
[[email protected] ~]# pvscan
No matching physical volumes found
沒有。
⑦這裡我將剛才建立的分割槽 /dev/vdb1作為物理卷。
[[email protected] ~]# 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.
⑧再次檢視
[[email protected] ~]# pvscan
PV /dev/vdb1 lvm2 [<47.00 GiB]
Total: 1 [<47.00 GiB] / in use: 0 [0 ] / in no VG: 1 [<47.00 GiB]
[[email protected] ~]# 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
[[email protected] ~]# vgs
[[email protected] ~]# vgcreate stack-volumes-lvmdriver-1 /dev/vdb1
Volume group "stack-volumes-lvmdriver-1" successfully created
[[email protected] ~]# 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/sdu_king/article/details/74933121。
最後推薦幾篇博文:
增加一塊新硬碟,如何把它掛載到/home目錄 從而擴大home空間
總有一款適合你:)