LVM的基本應用、擴展及縮減實現

LVM : app

     Logical Volume Manager 邏輯卷管理, 它是一種能夠用在Linux內核的邏輯分卷管理器,經常使用於管理磁盤和其餘大型存儲設備上。ide



LVM的應用:ui

             在生產環境中常見於增長磁盤,可將多個磁盤合理的合併成一個或多個,但又不會影響業務的進行。spa


與raid的區別:
orm

              LVM是軟件的卷管理方式,而RAID是磁盤保護的方法。對於重要的業務來講,通常是同時存在。RAID用來保護物理的磁盤不會由於故障而中斷業務。LVM用來實現對卷的良性的管理,更好的利用磁盤資源。ci



LVM的擴展及縮減實例: 

資源

1,首先查看邏輯卷容量
[root@bogon ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       39G  461M   37G   2% /
/dev/mapper/VolGroup00-LogVol03
                       64G  222M   61G   1% /var
/dev/mapper/VolGroup00-LogVol02
                       49G  2.0G   45G   5% /usr
/dev/mapper/VolGroup00-LogVol01
                       39G  177M   37G   1% /home
/dev/sda1              99M   13M   82M  14% /boot
tmpfs                1005M     0 1005M   0% /dev/shm
/dev/hdc              3.5G  3.5G     0 100% /media

it


2,在home下有lost+found能夠看到home分區單獨掛載到一個分區下面
[root@bogon ~]# ls /home/
innofidei  lost+found

io

3,卸載並驗證
[root@bogon ~]# umount /dev/mapper/VolGroup00-LogVol01 
[root@bogon ~]# ls /home/

form

4,resize2fs  卷組
[root@bogon ~]# resize2fs /dev/mapper/VolGroup00-LogVol01 20G 
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/mapper/VolGroup00-LogVol01 to 5242880 (4k) blocks.
The filesystem on /dev/mapper/VolGroup00-LogVol01 is now 5242880 blocks long.
注意這裏會提醒你e2fsck的
因此resize2fs以前要這樣作: e2fsck -f /dev/mapper/VolGroup-logVol01

5,縮減lvm
[root@bogon ~]# lvreduce -L 20G /dev/mapper/VolGroup00-LogVol01
  /dev/hdc: open failed: Read-only file system
  WARNING: Reducing active logical volume to 20.00 GB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce LogVol01? [y/n]: y
  Reducing logical volume LogVol01 to 20.00 GB
  Logical volume LogVol01 successfully resized

6,從新掛載並驗證
[root@bogon ~]# mount -a
[root@bogon ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       39G  461M   37G   2% /
/dev/mapper/VolGroup00-LogVol03
                       64G  222M   61G   1% /var
/dev/mapper/VolGroup00-LogVol02
                       49G  2.0G   45G   5% /usr
/dev/sda1              99M   13M   82M  14% /boot
tmpfs                1005M     0 1005M   0% /dev/shm
/dev/hdc              3.5G  3.5G     0 100% /media
/dev/mapper/VolGroup00-LogVol01
                       20G  173M   19G   1% /home
[root@bogon ~]# ls /home/
innofidei  lost+found

7,擴展另外一lvm
[root@bogon ~]# lvextend -L +20G /dev/mapper/VolGroup00-LogVol02
  /dev/hdc: open failed: Read-only file system
  Extending logical volume LogVol02 to 70.00 GB
  Logical volume LogVol02 successfully resized
[root@bogon ~]# resize2fs /dev/mapper/VolGroup00-LogVol02
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/mapper/VolGroup00-LogVol02 is mounted on /usr; on-line resizing required
Performing an on-line resize of /dev/mapper/VolGroup00-LogVol02 to 18350080 (4k) blocks.
The filesystem on /dev/mapper/VolGroup00-LogVol02 is now 18350080 blocks long.

8,再驗證
[root@bogon ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       39G  461M   37G   2% /
/dev/mapper/VolGroup00-LogVol03
                       64G  222M   61G   1% /var
/dev/mapper/VolGroup00-LogVol02
                       68G  2.0G   63G   4% /usr
/dev/sda1              99M   13M   82M  14% /boot
tmpfs                1005M     0 1005M   0% /dev/shm
/dev/hdc              3.5G  3.5G     0 100% /media
/dev/mapper/VolGroup00-LogVol01
                       20G  173M   19G   1% /home

相關文章
相關標籤/搜索