创建lvm分区一例

发布时间:2020-11-08编辑:脚本学堂
创建lvm分区一例

1、添加三块硬盘到服务器

2、用fdisk -l 查看一下分区情况
看到了,刚加的3块硬盘
 

复制代码 代码如下:

Disk /dev/sdc: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdc doesn't contain a valid partition table

Disk /dev/sdd: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdd doesn't contain a valid partition table

Disk /dev/sde: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sde doesn't contain a valid partition table

3、添加三块硬盘
fdisk /dev/sdc
n
p
1
回车(保持默认)
回车保持默认(把所有的硬盘空间都使用)
w
保存退出。
以此类推,把sdd,sde都添加好。

4、重新查看一下磁盘使用情况:
 

复制代码 代码如下:

[root@sendmail ~]# fdisk -l
Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  linux
/dev/sda2              14        1044     8281507+  8e  Linux LVM

Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         130     1044193+  82  Linux swap / Solaris

Disk /dev/sdc: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1         130     1044193+  83  Linux

Disk /dev/sdd: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1         130     1044193+  83  Linux

Disk /dev/sde: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sde1               1         130     1044193+  83  Linux
[root@sendmail ~]#
 

5、内核重新载入三块磁盘的分区表
 

复制代码 代码如下:
[root@sendmail ~]# kpartx -a /dev/sdc
[root@sendmail ~]# kpartx -a /dev/sdd
[root@sendmail ~]# kpartx -a /dev/sde

6、pvcreate
7、vg
8、lv

9、格式化三个分区
 

复制代码 代码如下:
mkfs.ext4 /dev/sdc1
mkfs.ext4 /dev/sdd1
mkfs.ext4 /dev/sde1