Chinaunix首页 | 论坛 | 博客
  • 博客访问: 261658
  • 博文数量: 93
  • 博客积分: 3001
  • 博客等级: 中校
  • 技术积分: 1050
  • 用 户 组: 普通用户
  • 注册时间: 2009-07-11 13:20
文章分类

全部博文(93)

文章存档

2011年(1)

2009年(92)

我的朋友

分类: LINUX

2009-07-13 09:26:50

linux 增加新硬盘 lvm 操作笔记

 

用fdisk分区

----------------------------------------

fdisk /dev/sdb

Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-182203, default 1):

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-182203, default 182203):

Using default value 182203

 

Command (m for help): p

 

Disk /dev/sdb: 1498.6 GB, 1498675150848 bytes

255 heads, 63 sectors/track, 182203 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1      182203  1463545566   83  Linux

 

Command (m for help): t

Selected partition 1

Hex code (type L to list codes): 8e

Changed system type of partition 1 to 8e (Linux LVM)

 

Command (m for help): p

 

Disk /dev/sdb: 1498.6 GB, 1498675150848 bytes

255 heads, 63 sectors/track, 182203 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1      182203  1463545566   8e  Linux LVM

 

Command (m for help):w

 

创建物理卷

----------------------------------------

pvcreate /dev/sdb1

pvdisplay

 

  --- Physical volume ---

  PV Name               /dev/sdb1

  VG Name               VolGroup01

  PV Size               1.36 TB / not usable 3.72 MB

  Allocatable           yes (but full)

  PE Size (KByte)       4096

  Total PE              357310

  Free PE               0

  Allocated PE          357310

  PV UUID               sZRivL-zIzC-Ysq5-WRLb-ll9e-royp-Ovg8Y5

 

  --- Physical volume ---

  PV Name               /dev/sda2

  VG Name               VolGroup00

  PV Size               465.15 GB / not usable 21.99 MB

  Allocatable           yes

  PE Size (KByte)       32768

  Total PE              14884

  Free PE               1

  Allocated PE          14883

  PV UUID               2c2wFj-inYf-8dwK-K9Ip-C0Qh-oYwp-XPuccz

 

创建卷组

----------------------------------------

vgcreate VolGroup01 /dev/sdb1

vgdisplay

 

  --- Volume group ---

  VG Name               VolGroup01

  System ID

  Format                lvm2

  Metadata Areas        1

  Metadata Sequence No  3

  VG Access             read/write

  VG Status             resizable

  MAX LV                0

  Cur LV                1

  Open LV               0

  Max PV                0

  Cur PV                1

  Act PV                1

  VG Size               1.36 TB

  PE Size               4.00 MB

  Total PE              357310

  Alloc PE / Size       357310 / 1.36 TB

  Free  PE / Size       0 / 0

  VG UUID               6m2kb9-xueP-dDUf-GiQS-y5ve-vUYu-b5eJHM

 

创建逻辑卷

----------------------------------------

lvcreate -l 357310 -n LogVol02 VolGroup01

 

在逻辑卷上创建ext3文件系统

----------------------------------------

mkfs -t ext3 /dev/VolGroup01/LogVol02

 

mke2fs 1.35 (28-Feb-2004)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

182943744 inodes, 365885440 blocks

18294272 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=4294967296

11166 block groups

32768 blocks per group, 32768 fragments per group

16384 inodes per group

Superblock backups stored on blocks:

        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,

        102400000, 214990848

 

Writing inode tables: done

Creating journal (8192 blocks): done

Writing superblocks and filesystem accounting information: done

 

This filesystem will be automatically checked every 34 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

 

挂载文件系统

----------------------------------------

mkdir /data

mount /dev/VolGroup01/LogVol02 /data

 

# df -h

Filesystem            容量  已用 可用 已用% 挂载点

/dev/mapper/VolGroup00-LogVol00

                      449G  2.2G  424G   1% /

/dev/sda1              99M   15M   80M  16% /boot

none                  3.9G     0  3.9G   0% /dev/shm

/dev/mapper/VolGroup01-LogVol02

                      1.4T  102M  1.3T   1% /data

 

设置启动时自动挂载

----------------------------------------

在系统启动时自动加载文件系统,则还需要在/etc/fstab中添加内容

/dev/VolGroup01/LogVol02                /data           ext3    defaults        1 2

 

为保证不出现人为的错误编辑fstab,可在图形界面(gnome)中设置:系统设置——逻辑卷管理器——找到对应逻辑卷(LogVol02)——编辑属性——文件系统——重新启动时自动挂载(/data)——确定

 

 

阅读(1920) | 评论(0) | 转发(0) |
0

上一篇: 基本安装配置

下一篇:专业术语

给主人留下些什么吧!~~