歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux教程

Linux下LVM添加磁盤實踐操作

LVM是 Logical Volume Manager(邏輯卷管理)的簡寫,它是Linux環境下對磁盤分區進行管理的一種機制,它由Heinz Mauelshagen在Linux 2.4內核上實現,目前最新版本為:穩定版1.0.5,開發版 1.1.0-rc2,以及LVM2開發版。

LVM是建立在硬盤和分區之上的一個邏輯層,來提高磁盤分區管理的靈活性

可以看一下lvm的示意圖

每個磁盤可以分成多個分區,每個分區相當於一個pv,將pv化分成vg,在vg的基礎上創建邏輯分區lv,邏輯分區lv上創建操作系統的文件系統。注意boot需要直接建到物理分區上去的。

RedHat默認情況下是安裝lvm包的。

檢測操作系統是否安裝了lvm

[root@rac3 ~]# rpm -qa |grep lvm
system-config-lvm-1.1.4-1.3.el4
lvm2-2.02.42-5.el4

在支持熱插拔的服務器上安裝一塊硬盤。

先用partprobe掃描是否有新的磁盤在用fdisk -l查看磁盤,我安裝的磁盤就是最後一個

Disk /dev/sdg: 1073 MB, 1073741824 bytes

[root@rac3 ~]# partprobe
[root@rac3 ~]# fdisk -l

Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 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         140     1020127+  8e  Linux LVM
/dev/sda3             141        1305     9357862+  8e  Linux LVM

Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1          37      297171   83  Linux
/dev/sdb2              38          74      297202+  83  Linux
/dev/sdb3              75         561     3911827+  83  Linux
/dev/sdb4             562        1305     5976180   83  Linux

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: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sde1               1         522     4192933+  83  Linux

Disk /dev/sdf: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdf1               1         522     4192933+  8e  Linux LVM

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

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

1、先對磁盤進行分區格式化

[root@rac3 ~]# fdisk /dev/sdg
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1 
First cylinder (1-130, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-130, default 130):
Using default value 130

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Copyright © Linux教程網 All Rights Reserved