Linux pvcreate命令

Linux pvcreate命令:创建物理卷。

Linux pvcreate命令 功能描述

使用pvcreate命令可以将物理磁盘分区初始化创建为物理卷。

Linux pvcreate命令 语法

pvcreate [选项] [物理卷名]

命令中各选项的含义如表所示。

pvcreate命令选项含义

Linux pvcreate命令 示例

创建物理卷/dev/sda5和/dev/sda6

[root@rhel ~]# pvcreate /dev/sda5 /dev/sda6
 Physical volume "/dev/sda5" successfully created
 Physical volume "/dev/sda6" successfully created
备注:创建LVM准备工作——创建磁盘分区。
在创建物理卷之前必须先对磁盘进行分区,并且将磁盘分区的类型设置为8e,之后才能将分区初始化为物理卷。
在磁盘上创建磁盘分区/dev/sda5、/dev/sda6和/dev/sda7,每个分区容量都是100GB,文件系统为8e,也就是Linux LVM。

[root@rhel ~]# fdisk /dev/sda
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
    switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command(m for help): n
Command action
  e  extended
  p  primary partition(1-4)
e
//在此输入e,开始创建扩展分区
Selected partition 4
First cylinder (19856-65270, default 19856):
//直接按回车键,从磁盘剩余起始柱面开始创建扩展分区
Using default value 19856
Last cylinder, +cylinders or +size{K, M, G} (19856-65270, default 65270):
//直接按回车键,则从第19856个柱面到最后一个柱面均为扩展分区
Using default value 65270
Command(m for help): n
//在此输入n,开始创建第一个逻辑驱动器
First cylinder (19856-65270, default 19856):
//直接按回车键,从磁盘剩余起始柱面开始创建逻辑驱动器
Using default value 19856
Last cylinder, +cylinders or+size{K, M, G}(19856-65270, default 65270): +100G
//在此输入“+100G”,代表创建容量为100GB的逻辑驱动器
Command(m for help): n
First cylinder (32911-65270, default 32911):
Using default value 32911
Last cylinder, +cylinders or+size{K, M, G}(32911-65270, default 65270): +100G
Command(m for help): n
First cylinder (45966-65270, default 45966):
Using default value 45966
Last cylinder, +cylinders or+size{K, M, G}(45966-65270, default 65270): +100G
Command(m for help): t
//在此输入t,开始转换分区类型
Partition number(1-7):5
//输入分区号码,在此输入5,说明要转换/dev/sda5分区的类型
Hex code(type L to list codes):8e
Changed system type of partition 5 to 8e (Linux LVM)
//转换5号分区类型为8e (Linux LVM)
Command(m for help): t
Partition number(1-7):6
Hex code(type L to list codes):8e
Changed system type of partition 6 to 8e (Linux LVM)
Command(m for help): t
Partition number (1-7): 7
Hex code(type L to list codes):8e
Changed system type of partition 7 to 8e (Linux LVM)
Command(m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
磁盘分区之后,应该重启计算机系统,然后使用以下命令查看当前系统磁盘分区情况。
[root@rhel ~]# fdisk -l /dev/sda
Disk /dev/sda: 536.9 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00034c36
  Device Boot     Start      End      Blocks   Id  System
/dev/sda1 *         1       13      102400   83   Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2          13    19595   157286400   83   Linux
/dev/sda3        19595    19856     2097152   82   Linux swap/Solaris
/dev/sda4        19856    65270   364794299    5   Extended
/dev/sda5        19856    32910   104862567+   8e   Linux LVM
/dev/sda6        32911    45965   104864256   8e   Linux LVM
/dev/sda7        45966    59020   104864256   8e   Linux LVM
//可以看到/dev/sda5、/dev/sda6和/dev/sda7分区类型ID都是8e

Camera课程

Python教程

Java教程

Web教程

数据库教程

图形图像教程

办公软件教程

Linux教程

计算机教程

大数据教程

开发工具教程