手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

Linux fdisk LVM soft RAID 配置管理

[日期:2010-11-06] 来源:Linux社区  作者:wfliving [字体:大 中 小]

一.fdisk 磁盘分区
[root@localhost ~]# fdisk -l   (显示当前磁盘分区情况)

Disk /dev/hdb: 5368 MB, 5368709120 bytes
16 heads, 63 sectors/track, 10402 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

   Device Boot      Start         End      Blocks   Id  System

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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        2610    20860402+  8e  Linux LVM

以上信息表明,有2块硬盘,一块是SCSI的,一块是IDE的。其中/dev/hdb 是5G的,有16个磁面,63个扇区。10402个磁柱.每个磁柱的容量是0.516096M。每一个分区的容量是
Blocks = (相应分区End数值 - 相应分区Start数值)x 单位cylinder(磁柱)的容量,比如说/dev/sda1=(13-1)*8225.280=98703.36=98M (由于硬盘都是按1000M为单位,所以有一些偏差),之所以没有/dev/hda 是因为已经被光驱占用了。

下面对Disk /dev/hdb进行分区,分区方案如下:
/dev/hdb1  主分区    容量:1G
/dev/hdb2  扩展分区 容量:4G
/dev/hdb5  逻辑分区 容量 :1G
/dev/hdb6  逻辑分区 容量 :1G
/dev/hdb7  逻辑分区 容量 :1G
/dev/hdb8  逻辑分区 容量 :1G

说明:分区(包括扩展分区)的总个数不能超过四个;也不能把扩展分区包围在主分区之间;分区(包括扩展分区)的总个数不能超过四个;也不能把扩展分区包围在主分区之间;系统默认会将磁盘编号1-4给主分区,从5~16给逻辑分区。所以LINUX系统最多只能存在16个分区。

[root@localhost ~]# fdisk /dev/hdb  (对硬盘/dev/hdb进行分区)

The number of cylinders for this disk is set to 10402.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): n   (创建分区)
Command action
   e   extended
   p   primary partition (1-4)  
p   (创建主分区)
Partition number (1-4): 1    (选择分区ID号)
First cylinder (1-10402, default 1):    (起始磁柱值直接回车默认就行)
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-10402, default 10402): +1G  (结束磁柱值 1G)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
e  (划分扩展分区)
Partition number (1-4): 2
First cylinder (1940-10402, default 1940):
Using default value 1940
Last cylinder or +size or +sizeM or +sizeK (1940-10402, default 10402):
Using default value 10402
Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l  (划分逻辑分区1)
First cylinder (1940-10402, default 1940):
Using default value 1940
Last cylinder or +size or +sizeM or +sizeK (1940-10402, default 10402): +1G
Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l (划分逻辑分区2)
First cylinder (3879-10402, default 3879):
Using default value 3879
Last cylinder or +size or +sizeM or +sizeK (3879-10402, default 10402): +1G
Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l (划分逻辑分区3)
First cylinder (5818-10402, default 5818):
Using default value 5818
Last cylinder or +size or +sizeM or +sizeK (5818-10402, default 10402): +1G
Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l (划分逻辑分区4)
First cylinder (7757-10402, default 7757): +1G^H^H^H^H^H^H
Value out of range.
First cylinder (7757-10402, default 7757):
Using default value 7757
Last cylinder or +size or +sizeM or +sizeK (7757-10402, default 10402): +1G

www.linuxidc.com

Command (m for help): p  (打印输入分区信息)

Disk /dev/hdb: 5368 MB, 5368709120 bytes
16 heads, 63 sectors/track, 10402 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hdb1               1        1939      977224+  83  Linux
/dev/hdb2            1940       10402     4265352    5  Extended
/dev/hdb5            1940        3878      977224+  83  Linux
/dev/hdb6            3879        5817      977224+  83  Linux
/dev/hdb7            5818        7756      977224+  83  Linux
/dev/hdb8            7757        9695      977224+  83  Linux

partprobe /dev/hdb   (同步写入分区表,不用重启LINUX)
以上分区结束。

参考文章: http://www.pconline.com.cn/pcjob/system/linux/others/0512/743298.html
                  http://www.360doc.com/content/07/0808/00/9144_659342.shtml
                  http://server.zol.com.cn/127/1271401.html

二.LVM(logical volume management) 逻辑卷管理器

LVM(logical volume management)就是解决磁盘空间不足的问题,必须满足的是其它磁盘分区要有剩余的空间我们才能创建逻辑卷管理。
在逻辑卷管理器中我们会常用到以下:
Pv代表的是物理卷可一块硬盘也可以是一个分区
Vg 代表的是逻辑卷组
Lv 代表的是逻辑卷

解决方案1:创建1个新的LVM分区,划分大小为500M并使用
1.创建物理卷
[root@localhost ~]# pvcreate /dev/hdb5     (创建PV)
  Physical volume "/dev/hdb5" successfully created
[root@localhost ~]# pvdisplay /dev/hdb5    (显示PV信息)
  --- Physical volume ---
  PV Name               /dev/hdb5
  VG Name               vg1
  PV Size               954.32 MB / not usable 2.32 MB
  Allocatable           yes
  PE Size (KByte)       4096
  Total PE              238
  Free PE               113
  Allocated PE          125
  PV UUID               c0230M-LDop-9P6h-urrm-PVfS-wF5O-7RsxnR

2.创建逻辑卷组
[root@localhost ~]# vgcreate vg1 /dev/hdb5  (vg1是逻辑卷组名,可以随便起)
Volume group "vg1" successfully created
[root@localhost ~]# vgdisplay vg1                    (显示VG信息)
  --- Volume group ---
  VG Name               vg1
  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               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               952.00 MB
  PE Size               4.00 MB
  Total PE              238
  Alloc PE / Size       125 / 500.00 MB
  Free  PE / Size       113 / 452.00 MB
  VG UUID               erhVbI-5Ckz-befx-QpFZ-RbhV-Hl9K-qZ0x9Z

linux
相关资讯       Linux服务器 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款