首页 > 代码库 > Linux LVM

Linux LVM

针对操作系统:Red Hat Enterprise Linux Server release 5.8 (Tikanga)

注:自己的测试环境-----测试没有问题

1.查看逻辑卷
[root@localhost ~]# lvdisplay
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                E6hkkL-rkLw-OA2l-072h-QfMh-LDIN-feGjSM
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                10.00 GB
  Current LE             320
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
  
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol01
  VG Name                VolGroup00
  LV UUID                azpGdn-iCfZ-DQX4-LNP8-Z0L4-aNKO-EqJ6A4
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                10.00 GB
  Current LE             320
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

 
2.查看剩余空间
[root@localhost ~]# vgs
  VG         #PV #LV #SN Attr   VSize  VFree
  VolGroup00   1   3   0 wz--n- 47.78G 22.78G

 

3.新建一个逻辑分区: name:/dev/VolGroup00/LogVol02
[root@localhost ~]# lvcreate -L5120M -n /dev/VolGroup00/LogVol02 VolGroup00
  Logical volume "LogVol02" created

4.再次查看逻辑分区
[root@localhost ~]# lvdisplay
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                E6hkkL-rkLw-OA2l-072h-QfMh-LDIN-feGjSM
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                10.00 GB
  Current LE             320
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
  
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol01
  VG Name                VolGroup00
  LV UUID                azpGdn-iCfZ-DQX4-LNP8-Z0L4-aNKO-EqJ6A4
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                10.00 GB
  Current LE             320
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1
  
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol02
  VG Name                VolGroup00
  LV UUID                O2U6Wa-1rxy-rOTr-Pw52-PM6g-vX0d-9mJs5h
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                5.00 GB
  Current LE             160
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2

 
5.新建需要挂载的目录
[root@localhost ~]# mkdir /data1

6.需要格式化新建分区
[root@localhost ~]# mkfs -t ext3 -j /dev/VolGroup00/LogVol02
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
655360 inodes, 1310720 blocks
65536 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1342177280
40 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

Writing inode tables: done                           
Creating journal (32768 blocks):
done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 38 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.


7. mount 挂载新建分区到目录
[root@localhost ~]# mount /dev/mapper/VolGroup00-LogVol02 /data1


8. 查看挂载结果
[root@localhost ~]# df -lh
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                      9.7G  529M  8.7G   6% /
/dev/mapper/VolGroup00-LogVol01
                      9.7G  3.1G  6.2G  34% /usr
/dev/sda1             190M   13M  168M   8% /boot
tmpfs                 249M     0  249M   0% /dev/shm
/dev/mapper/VolGroup00-LogVol02
                      5.0G  139M  4.6G   3% /data1
注明:已经操作成功

9. 不用重启就直接生效
[root@localhost ~]# partprobe
Warning: Unable to open /dev/hdc read-write (Read-only file system).  /dev/hdc has been opened read-only.

10. 开机自动挂载
[root@localhost data1]# vi /etc/fstab
/dev/VolGroup00/LogVol00 /                       ext3    defaults        1 1
/dev/VolGroup00/LogVol01 /usr                    ext3    defaults        1 2
/dev/VolGroup00/LogVol02 /data1                  ext3   defaults        1 2   ###加入到这行,就可以完成配置
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
LABEL=SWAP-sda2         swap                    swap    defaults        0 0

11. 写入硬盘操作
sync ; sync

 

 

 

本文出自 “夜冷” 博客,请务必保留此出处http://miaopan.blog.51cto.com/4233458/1559111

Linux LVM