[转]Fedora 12下使用LVM添加硬盘驱动器

LVM是 Logical Volume Manager(逻辑卷管理 )的简写,它由Heinz Mauelshagen在Linux 2.4内核上实现,与传统的磁盘与分区相比,LVM为计算机提供了更高层次的磁盘存储。因为最近需要在两种不同的存储介质上运行数据库,因此不得不在机器上再添加一块硬盘,无奈之下对LVM捣鼓了一下,最后总算是把新的硬盘mount上去了,哈哈,欣喜之余立博为证!
Linux下的逻辑卷管理的主要机制就是通过卷组来进行管理,卷组之下分为物理卷和逻辑卷两部分,逻辑卷在卷组的物理卷上进行构建,也就是把物理卷的存储空间映射到逻辑卷上,然后在逻辑卷上构建文件系统。下面就简单介绍一下在Fedora 12上如何使用LVM机制添加新的硬盘驱动器。


首先,安装新的硬盘驱动器。注意数据线和电源线都要插好,插的时候把机器关了电源拔了(哎呀,不好意思,不由自主地嚼舌了),装好之后启动机器。此时,我们打开一个终端,使用以下的各种命令进行配置。


1)因为LVM的操作只能以root权限进行,所以我们最好切换到root用户:
[flash@localhost ~]$ su - 
密码:


2)使用fdisk命令查看机器是否已经检测到了新安装的设备(新设备标识为/dev/sdb):
[root@localhost ~]# fdisk -l
Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xf0b1ebb0
Device Boot  Start  End  Blocks  Id  System
/dev/sda1  *  1  26  204800  83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2  26  30401  243991201  8e  Linux LVM
Disk /dev/sdb: 62.9 GB, 62881005568 bytes
255 heads, 63 sectors/track, 7644 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x788d7bfb
Device Boot  Start  End  Blocks  Id  System
/dev/sdb1  *  1  26  204800  83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sdb2  26  7644  61195598+  8e  Linux LVM
Disk /dev/dm-0: 245.6 GB, 245618442240 bytes
255 heads, 63 sectors/track, 29861 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000
Disk /dev/dm-0 doesn't contain a valid partition table
Disk /dev/dm-1: 4227 MB, 4227858432 bytes
255 heads, 63 sectors/track, 514 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000
Disk /dev/dm-1 doesn't contain a valid partition table


3)使用新设备的分区创建一个物理卷/dev/sdb2:
[root@localhost ~]# pvcreate /dev/sdb2
Physical volume "/dev/sdb2" successfully created


4)创建一个新的卷组vg_wamdm:
[root@localhost ~]# vgcreate vg_wamdm /dev/sdb2
Volume group "vg_wamdm" successfully created


5)激活刚刚创建的卷组vg_wamdm:
[root@localhost ~]# vgchange -a y vg_wamdm
0 logical volume(s) in volume group "vg_wamdm" now active


6)在卷组内创建一个逻辑卷ssd1,注意大小不可超过硬盘驱动器本身的大小:
[root@localhost ~]# lvcreate -l 30000 -n ssd1 vg_wamdm
Insufficient free extents (14940) in volume group vg_wamdm: 30000 required
实际大小只有14940个块,而我们申请了30000个块,因此报错,下面我们重新申请7470即一半实际大小的块
[root@localhost ~]# lvcreate -l 7470 -n ssd1 vg_wamdm
Logical volume "ssd1" created


7)使用命令lvscan查看现在已有的逻辑卷,其中后两个为系统原有设备的逻辑卷,第一个为我们刚刚创建的逻辑卷:
[root@localhost ~]# lvscan
ACTIVE  '/dev/vg_wamdm/ssd1' [29.18 GB] inherit
ACTIVE  '/dev/VolGroup/lv_root' [228.75 GB] inherit
ACTIVE  '/dev/VolGroup/lv_swap' [3.94 GB] inherit


8)在逻辑卷上构建文件系统,然后将其mount到一个现有的文件目录下:
[root@localhost ~]# mount -t ext3 /dev/vg_wamdm/ssd1 /home/flash/ssdstore
mount: wrong fs type, bad option, bad superblock on /dev/mapper/vg_wamdm-ssd1,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail  or so


在没有构建文件系统的情况下进行mount操作会报错如上,可以利用Fedora 12自带的工具Palimpsest构建文件系统,但一定要注意要选择和原有系统一致的文件系统(这里是ext4)构建,有了文件系统之后就可以进行mount操作了


[root@localhost ~]# mount -t ext4 /dev/vg_wamdm/ssd1 /home/flash/ssdstore
[root@localhost ~]#


在经过以上步骤之后,我们就完成了硬盘驱动器的加载,我们可以在各种界面下找到这个已经mount到系统中的文件系统目录,如在“系统”-->“管理”-->"逻辑卷管理器"下(如图一所示)、文件目录浏览器下(如图二、三所示)和工具Palimpsest下(如图四所示)。
Fedora <wbr>12下使用LVM添加硬盘驱动器

图一

image
图二

Fedora <wbr>12下使用LVM添加硬盘驱动器

图三

Fedora <wbr>12下使用LVM添加硬盘驱动器

图四

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值