Linux 卷管理详解[ pv vg lv] ―― 之三

 创建基于分区的LV

1     通过fdisk创建分区,详细步骤省略,可参考如下:

http://blog.csdn.net/wuweilong/article/details/7538647

http://space.itpub.net/?uid-20674423-action-viewspace-itemid-722812

 

[root@jetsen /]# fdisk /dev/sdc  n\ p\ 1\ +500m\ w\--创建了500M分区

[root@jetsen /]# fdisk /dev/sdc  n\ p\ 1\ +1024m\ w\--创建了1G分区

 

查看分区信息

[root@jetsen /]# fdisk -l /dev/sdc                ----分区已经创建成功

 

Disk /dev/sdc: 536.8 GB, 536870912000 bytes

255 heads, 63 sectors/track, 65270 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

  Device Boot     Start        End     Blocks  Id System

/dev/sdc1              1         62     497983+ 83 Linux

/dev/sdc2             63        187    1004062+ 83 Linux

[root@jetsen /]#

 

2    创建基于分区的物理卷

[root@jetsen /]# pvcreate /dev/sdc1

 Physical volume "/dev/sdc1" successfully created

[root@jetsen /]# pvcreate /dev/sdc2

 Physical volume "/dev/sdc2" successfully created

 

3    创建卷组:

[root@jetsen /]# vgcreate soft /dev/sdc1 /dev/sdc2

 /dev/cdrom: open failed: Read-only file system

 /dev/cdrom: open failed: Read-only file system

 Attempt to close device '/dev/cdrom' which is not open.

 Volume group "soft" successfully created

[root@jetsen /]#

 

4    激活卷组

[root@jetsen /]# vgchange -a y soft

 0 logical volume(s) in volume group "soft" now active

[root@jetsen /]#

 

5         从卷组中删除物理卷

[root@jetsen /]# vgreduce soft /dev/sdc2

 Removed "/dev/sdc2" from volume group "soft"

[root@jetsen /]#

 

6    添加卷组到物理卷

[root@jetsen /]# vgextend soft /dev/sdc2

 /dev/cdrom: open failed: Read-only file system

 Attempt to close device '/dev/cdrom' which is not open.

 Volume group "soft" successfully extended

[root@jetsen /]#

 

7    创建LV

先查看VG的大小,为1.5G,包含2PV

[root@jetsen /]# vgdisplay soft

 --- Volume group ---

 VG Name              soft

 System ID            

 Format               lvm2

 Metadata Areas       2

 Metadata Sequence No 3

 VG Access            read/write

 VG Status            resizable

 MAX LV               0

 Cur LV               0

 Open LV              0

 Max PV               0

 Cur PV               2

 Act PV               2

 VG Size              1.43 GB

 PE Size              4.00 MB

 Total PE             366

 Alloc PE / Size      0 / 0  

 Free PE / Size      366 / 1.43 GB

 VG UUID              D3x6JY-BVIL-C4ld-013H-U2Rq-hb1q-1oOVnx

  

[root@jetsen /]#

1.5G366PE创建一个LV

[root@jetsen /]# lvcreate -l366 soft -n soft01

 Logical volume "soft01" created

[root@jetsen /]#

 

8    创建文件系统:

[root@jetsen /]# mkfs.ext4 /dev/soft/soft01

mke4fs 1.41.5 (23-Apr-2009)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

93696 inodes, 374784 blocks

18739 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=385875968

12 block groups

32768 blocks per group, 32768 fragments per group

7808 inodes per group

Superblock backups stored on blocks:

       32768, 98304, 163840, 229376, 294912

 

Writing inode tables: done                           

Creating journal (8192 blocks): done

Writing superblocks and filesystem accounting information: done

 

This filesystem will be automatically checked every 29 mounts or

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

[root@jetsen /]#

 

9    挂载文件系统

[root@jetsen /]# mkdir /soft

[root@jetsen /]# mount /dev/soft/soft01 /soft

[root@jetsen /]# df -h

Filesystem                          Size  Used  Avail Use% Mounted on

/dev/mapper/VolGroup00-LogVol00     18G 5.8G  11G  35%  /

/dev/sda1                            99M 12M  82M 13%   /boot

tmpfs                               506M 4.0K 506M  1%  /dev/shm

/dev/mapper/soft-soft01              1.5G  35M  1.4G  3%  /soft

你可能感兴趣的:(linux,卷管理)