linux创建磁盘pv报错,Linux 磁盘管理

Linux 创建磁盘 以及磁盘分区管理

查看磁盘信息

[root@ZZSRV2 ~]# fdisk -l

Disk /dev/sda: 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: 0x000af460

Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *        2048     1026047      512000   83  Linux

/dev/sda2         1026048    83886079    41430016   8e  Linux LVM

Disk /dev/mapper/centos_zzsrv1-swap: 2181 MB, 2181038080 bytes, 4259840 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 /dev/mapper/centos_zzsrv1-root: 40.2 GB, 40240152576 bytes, 78594048 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

添加一块磁盘后重新扫描磁盘不需要重新启动

[root@ZZSRV2 ~]# echo "- - -" > /sys/class/scsi_host/host0/scan

[root@ZZSRV2 ~]# echo "- - -" > /sys/class/scsi_host/host1/scan

[root@ZZSRV2 ~]# echo "- - -" > /sys/class/scsi_host/host2/scan

[root@ZZSRV2 ~]# fdisk -l 再次查看磁盘信息,最下面就会看到新加的磁盘sdb

Disk /dev/sda: 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: 0x000af460

Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *        2048     1026047      512000   83  Linux

/dev/sda2         1026048    83886079    41430016   8e  Linux LVM

Disk /dev/mapper/centos_zzsrv1-swap: 2181 MB, 2181038080 bytes, 4259840 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 /dev/mapper/centos_zzsrv1-root: 40.2 GB, 40240152576 bytes, 78594048 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 /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 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

将磁盘分区(这里是将磁盘分一个区)

[root@ZZSRV2 ~]# fdisk /dev/sdb

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 0x7d9737a7.

Command (m for help): n

Partition type:

p   primary (0 primary, 0 extended, 4 free)

e   extended

Select (default p): p

Partition number (1-4, default 1):      →这里是可以将磁盘分几个区

First sector (2048-41943039, default 2048):

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039):  →分区的大小不可以超过磁盘的大小

Using default value 41943039

Partition 1 of type Linux and of size 20 GiB is set

Command (m for help): p

Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 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: 0x7d9737a7

Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048    41943039    20970496   83  Linux

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

创建PV

[root@ZZSRV2 ~]# pvscan

PV /dev/sda2   VG centos_zzsrv1   lvm2 [39.51 GiB / 0    free]

Total: 1 [39.51 GiB] / in use: 1 [39.51 GiB] / in no VG: 0 [0   ]

[root@ZZSRV2 ~]# pvcreate /dev/sdb1

Physical volume "/dev/sdb1" successfully created

[root@ZZSRV2 ~]# pvscan

PV /dev/sda2   VG centos_zzsrv1   lvm2 [39.51 GiB / 0    free]

PV /dev/sdb1                      lvm2 [20.00 GiB]

Total: 2 [59.51 GiB] / in use: 1 [39.51 GiB] / in no VG: 1 [20.00 GiB]

创建VG

[root@ZZSRV2 ~]# vgscan

Reading all physical volumes.  This may take a while...

Found volume group "centos_zzsrv1" using metadata type lvm2

[root@ZZSRV2 ~]# vgcreate VG /dev/sdb1

Volume group "VG" successfully created

[root@ZZSRV2 ~]# vgscan

Reading all physical volumes.  This may take a while...

Found volume group "VG" using metadata type lvm2

Found volume group "centos_zzsrv1" using metadata type lvm2

[root@ZZSRV2 ~]# vgdisplay VG

--- Volume group ---

VG Name               VG

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               20.00 GiB

PE Size               4.00 MiB

Total PE              5119  →记着这个数字

Alloc PE / Size       0 / 0

Free  PE / Size       5119 / 20.00 GiB

VG UUID               qHpcWT-mjRd-xcsT-QBac-XM94-b1H4-P2NQdF

创建一个LV,使用VG的全部PE

[root@ZZSRV2 ~]# lvscan

ACTIVE            '/dev/centos_zzsrv1/swap' [2.03 GiB] inherit

ACTIVE            '/dev/centos_zzsrv1/root' [37.48 GiB] inherit

LV的名称为LV1

[root@ZZSRV2 ~]# lvcreate -n LV1 -l 5119 VG

Logical volume "LV1" created

[root@ZZSRV2 ~]# lvscan

ACTIVE            '/dev/VG/LV1' [20.00 GiB] inherit

ACTIVE            '/dev/centos_zzsrv1/swap' [2.03 GiB] inherit

ACTIVE            '/dev/centos_zzsrv1/root' [37.48 GiB] inherit

[root@ZZSRV2 ~]# lvdisplay /dev/VG/LV1

--- Logical volume ---

LV Path                /dev/VG/LV1

LV Name                LV1

VG Name                VG

LV UUID                2OHuKM-6wyj-7TFr-lJCT-ZfzH-OcKd-f6oLr8

LV Write Access        read/write

LV Creation host, time ZZSRV2.localdomain, 2014-08-20 10:31:10 +0800

LV Status              available

# open                 0

LV Size                20.00 GiB

Current LE             5119

Segments               1

Allocation             inherit

Read ahead sectors     auto

- currently set to     8192

Block device           253:2

[root@ZZSRV2 ~]# vgdisplay VG

--- Volume group ---

VG Name               VG

System ID

Format                lvm2

Metadata Areas        1

Metadata Sequence No  2

VG Access             read/write

VG Status             resizable

MAX LV                0

Cur LV                1

Open LV               0

Max PV                0

Cur PV                1

Act PV                1

VG Size               20.00 GiB

PE Size               4.00 MiB

Total PE              5119

Alloc PE / Size       5119 / 20.00 GiB

Free  PE / Size       0 / 0   →注意这儿,已经没有剩余空间,说明全部的空间已经被使用

VG UUID               qHpcWT-mjRd-xcsT-QBac-XM94-b1H4-P2NQdF

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值