Linux LVM檔案系統管理的建立和擴充套件
LVM(Logical Volume Manager)邏輯卷管理是在Linux2.4核心以上實現的磁碟管理技術。LVM將一個或多個硬碟的分割槽在邏輯上集合,相當於一個大硬碟來使用,當硬碟的空間不夠使用的時候,可以繼續將其它的硬碟的分割槽加入其中,這樣可以實現磁碟空間的動態管理,相對於普通的磁碟分割槽有很大的靈活性。與傳統的磁碟與分割槽相比,LVM為計算機提供了更高層次的磁碟儲存。它使系統管理員可以更方便的為應用與使用者分配儲存空間。在LVM管理下的儲存卷可以按需要隨時改變大小與移除(可能需對檔案系統工具進行升級)。LVM也允許按使用者組對儲存捲進行管理,允許管理員用更直觀的名稱(如"data'、 'oracle')代替物理磁碟名(如'sda'、'sdb')來標識儲存卷。
物理儲存介質(The physical media):這裡指系統的儲存裝置/dev/sda1、/dev/xvdb1等,是儲存系統最低層的儲存單元。
物理卷(physical volume):物理卷就是指硬碟分割槽或從邏輯上與磁碟分割槽具有同樣功能的裝置(如RAID),是LVM的基本儲存邏輯塊,但和基本的物理儲存介質(如分割槽、磁碟等)比較,卻包含有與LVM相關的管理引數,PV即物理的磁碟分割槽。
卷組(Volume Group):LVM卷組類似於非LVM系統中的物理硬碟,其由物理卷組成,可以在卷組上建立一個或多個“LVM分割槽”(邏輯卷),LVM卷組由一個或多個物理卷組成。
邏輯卷(logical volume):LVM的邏輯卷類似於非LVM系統中的硬碟分割槽,在邏輯卷之上可以建立檔案系統(比如/home或者/usr等)。
PE(physical extent):每一個物理卷被劃分為稱為PE(Physical Extents)的基本單元,具有唯一編號的PE是可以被LVM定址的最小單元。PE的大小是可配置的,預設為4MB。
LE(logical extent):邏輯卷也被劃分為被稱為LE(Logical Extents) 的可被定址的基本單位。在同一個卷組中,LE的大小和PE是相同的,並且一一對應。
建立PV
pvcreate /dev/xvdb1 /dev/xvdc1 /dev/xvde1
建立VG
vgcreate -s 8M datavg /dev/xvdb1 /dev/xvdc1 /dev/xvde1
建立LV
lvcreate -L 890G -n lvdata datavg
掛載LV
/dev/datavg/lvdata
建立PV
pvcreate /dev/xvdf1
擴充套件VG
vgextend datavg /dev/xvdf1
擴充套件LV
lvextend -L +100G /dev/datavg/lvdata
擴充套件檔案系統
resize2fs /dev/datavg/lvdata
案例:
[root@hkpgsadg dev]# ls -l /dev/xvd*
brw-rw---- 1 root disk 202, 0 Apr 13 16:37 /dev/xvda
brw-rw---- 1 root disk 202, 1 Apr 13 16:36 /dev/xvda1
brw-rw---- 1 root disk 202, 2 Apr 13 16:36 /dev/xvda2
brw-rw---- 1 root disk 202, 3 Apr 13 16:36 /dev/xvda3
brw-rw---- 1 root disk 202, 16 Apr 13 16:39 /dev/xvdb
brw-rw---- 1 root disk 202, 17 Apr 13 16:39 /dev/xvdb1
brw-rw---- 1 root disk 202, 32 Apr 13 16:37 /dev/xvdc
brw-rw---- 1 root disk 202, 64 Apr 13 16:37 /dev/xvde
brw-rw---- 1 root disk 202, 80 Apr 13 16:37 /dev/xvdf
[root@hkpgsadg dev]# fdisk /dev/xvdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x04acd4ca.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-65270, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-65270, default 65270):
Using default value 65270
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@hkpgsadg dev]# ls -l /dev/xvd*
brw-rw---- 1 root disk 202, 0 Apr 13 16:37 /dev/xvda
brw-rw---- 1 root disk 202, 1 Apr 13 16:36 /dev/xvda1
brw-rw---- 1 root disk 202, 2 Apr 13 16:36 /dev/xvda2
brw-rw---- 1 root disk 202, 3 Apr 13 16:36 /dev/xvda3
brw-rw---- 1 root disk 202, 16 Apr 13 16:39 /dev/xvdb
brw-rw---- 1 root disk 202, 17 Apr 13 16:39 /dev/xvdb1
brw-rw---- 1 root disk 202, 32 Apr 13 16:39 /dev/xvdc
brw-rw---- 1 root disk 202, 33 Apr 13 16:39 /dev/xvdc1
brw-rw---- 1 root disk 202, 64 Apr 13 16:40 /dev/xvde
brw-rw---- 1 root disk 202, 65 Apr 13 16:40 /dev/xvde1
brw-rw---- 1 root disk 202, 80 Apr 13 16:40 /dev/xvdf
brw-rw---- 1 root disk 202, 81 Apr 13 16:40 /dev/xvdf1
[root@hkpgsadg dev]# pvcreate /dev/xvdb1 /dev/xvdc1 /dev/xvde1
Physical volume "/dev/xvdb1" successfully created
Physical volume "/dev/xvdc1" successfully created
Physical volume "/dev/xvde1" successfully created
[root@hkpgsadg dev]# pvdisplay
--- Physical volume ---
PV Name /dev/xvda2
VG Name VolGroup
PV Size 19.51 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 4994
Free PE 0
Allocated PE 4994
PV UUID Tv6PfK-cNpj-zYU2-cPeY-Xp8H-guAW-YZOm7d
--- Physical volume ---
PV Name /dev/xvda3
VG Name VolGroup
PV Size 100.00 GiB / not usable 3.99 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 25599
Free PE 0
Allocated PE 25599
PV UUID hhOoov-6TnF-p1Mg-mPc6-66If-zNwT-v8cIKB
"/dev/xvdb1" is a new physical volume of "100.00 GiB"
--- NEW Physical volume ---
PV Name /dev/xvdb1
VG Name
PV Size 100.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID OujuQi-rD1R-K91R-Ni82-jyAX-PpjD-ZnQvo5
"/dev/xvdc1" is a new physical volume of "499.99 GiB"
--- NEW Physical volume ---
PV Name /dev/xvdc1
VG Name
PV Size 499.99 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID grJiiL-KGug-ef3c-XF2J-ffS1-AhTl-xfHSMW
"/dev/xvde1" is a new physical volume of "300.00 GiB"
--- NEW Physical volume ---
PV Name /dev/xvde1
VG Name
PV Size 300.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID 08dOWh-3dFQ-rQ00-VTGi-h9S2-PbaJ-aQKYSe
[root@hkpgsadg dev]# vgcreate -s 8M datavg /dev/xvdb1 /dev/xvdc1 /dev/xvde1
Volume group "datavg" successfully created
[root@hkpgsadg dev]# vgdisplay
--- Volume group ---
VG Name datavg
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 3
Act PV 3
VG Size 899.98 GiB
PE Size 8.00 MiB
Total PE 115197
Alloc PE / Size 0 / 0
Free PE / Size 115197 / 899.98 GiB
VG UUID fINMY5-wBKS-QBKi-N6QI-ihMD-YaVb-j90u0x
--- Volume group ---
VG Name VolGroup
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 119.50 GiB
PE Size 4.00 MiB
Total PE 30593
Alloc PE / Size 30593 / 119.50 GiB
Free PE / Size 0 / 0
VG UUID RdDeWr-qxlF-f1To-zNng-nxCV-e1Hd-3xVZfH
[root@hkpgsadg dev]# vgdisplay
--- Volume group ---
VG Name datavg
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 3
Act PV 3
VG Size 899.98 GiB
PE Size 8.00 MiB
Total PE 115197
Alloc PE / Size 0 / 0
Free PE / Size 115197 / 899.98 GiB
VG UUID fINMY5-wBKS-QBKi-N6QI-ihMD-YaVb-j90u0x
--- Volume group ---
VG Name VolGroup
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 119.50 GiB
PE Size 4.00 MiB
Total PE 30593
Alloc PE / Size 30593 / 119.50 GiB
Free PE / Size 0 / 0
VG UUID RdDeWr-qxlF-f1To-zNng-nxCV-e1Hd-3xVZfH
[root@hkpgsadg dev]# vgdisplay datavg
--- Volume group ---
VG Name datavg
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 3
Act PV 3
VG Size 899.98 GiB
PE Size 8.00 MiB
Total PE 115197
Alloc PE / Size 0 / 0
Free PE / Size 115197 / 899.98 GiB
VG UUID fINMY5-wBKS-QBKi-N6QI-ihMD-YaVb-j90u0x
[root@hkpgsadg dev]# lvcreate -L 890G -n lvdata datavg
Logical volume "lvdata" created
[root@hkpgsadg dev]# lvdisplay
--- Logical volume ---
LV Path /dev/datavg/lvdata
LV Name lvdata
VG Name datavg
LV UUID yFWfNu-E1cr-px49-K9tH-Q0vU-BjfL-yt8hWh
LV Write Access read/write
LV Creation host, time hkpgsadg, 2016-04-13 16:45:21 +0800
LV Status available
# open 0
LV Size 890.00 GiB
Current LE 113920
Segments 3
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
--- Logical volume ---
LV Path /dev/VolGroup/lv_root
LV Name lv_root
VG Name VolGroup
LV UUID 4bM3bz-gttp-qKgr-sd9L-d24M-RMEb-LO4L4h
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2014-07-07 18:28:07 +0800
LV Status available
# open 1
LV Size 115.58 GiB
Current LE 29589
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/VolGroup/lv_swap
LV Name lv_swap
VG Name VolGroup
LV UUID Ic6bZU-mt6c-b0LK-1n7F-62Kc-16V1-TkcXBU
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2014-07-07 18:28:11 +0800
LV Status available
# open 1
LV Size 3.92 GiB
Current LE 1004
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
[root@hkpgsadg dev]# mkfs.ext4 /dev/datavg/lvdata
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
58327040 inodes, 233308160 blocks
11665408 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
7120 block groups
32768 blocks per group, 32768 fragments per group
8192 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 (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@hkpgsadg dev]# mkdir /data
[root@hkpgsadg dev]# mount /dev/datavg/lvdata /data
[root@hkpgsadg dev]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
114G 4.5G 104G 5% /
tmpfs 62G 0 62G 0% /dev/shm
/dev/xvda1 485M 32M 428M 7% /boot
/dev/mapper/datavg-lvdata
877G 200M 832G 1% /data
[root@hkpgsadg dev]#
[root@hkpgsadg data]# pvcreate /dev/xvdf1
Physical volume "/dev/xvdf1" successfully created
[root@hkpgsadg data]# vgextend datavg /dev/xvdf1
Volume group "datavg" successfully extended
[root@hkpgsadg data]# lvdisplay
--- Logical volume ---
LV Path /dev/datavg/lvdata
LV Name lvdata
VG Name datavg
LV UUID yFWfNu-E1cr-px49-K9tH-Q0vU-BjfL-yt8hWh
LV Write Access read/write
LV Creation host, time hkpgsadg, 2016-04-13 16:45:21 +0800
LV Status available
# open 1
LV Size 890.00 GiB
Current LE 113920
Segments 3
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
[root@hkpgsadg data]# vgdisplay
--- Volume group ---
VG Name datavg
System ID
Format lvm2
Metadata Areas 4
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 4
Act PV 4
VG Size 1.17 TiB
PE Size 8.00 MiB
Total PE 153596
Alloc PE / Size 113920 / 890.00 GiB
Free PE / Size 39676 / 309.97 GiB
VG UUID fINMY5-wBKS-QBKi-N6QI-ihMD-YaVb-j90u0x
[root@hkpgsadg data]# lvextend -L +100G /dev/datavg/lvdata
Extending logical volume lvdata to 990.00 GiB
Logical volume lvdata successfully resized
[root@hkpgsadg data]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
114G 4.5G 104G 5% /
tmpfs 62G 0 62G 0% /dev/shm
/dev/xvda1 485M 32M 428M 7% /boot
/dev/mapper/datavg-lvdata
877G 200M 832G 1% /data
[root@hkpgsadg data]# resize2fs /dev/datavg/lvdata
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/datavg/lvdata is mounted on /data; on-line resizing required
old desc_blocks = 56, new_desc_blocks = 62
Performing an on-line resize of /dev/datavg/lvdata to 259522560 (4k) blocks.
The filesystem on /dev/datavg/lvdata is now 259522560 blocks long.
[root@hkpgsadg data]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
114G 4.5G 104G 5% /
tmpfs 62G 0 62G 0% /dev/shm
/dev/xvda1 485M 32M 428M 7% /boot
/dev/mapper/datavg-lvdata
975G 200M 925G 1% /data
Created by Tony.Tang[TangYun]2016.04
-------------End-----------------
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24930246/viewspace-2081694/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- LVM : 擴充套件檔案系統的容量LVM套件
- 【Linux】Linux檔案系統管理6 線上擴充套件、收縮lvm檔案系統Linux套件LVM
- Linux 檔案系統擴充套件Linux套件
- aix擴充套件檔案系統AI套件
- aix 擴充套件檔案系統AI套件
- Linux擴充套件LVM空間Linux套件LVM
- Linux下擴充套件根檔案系統所在的分割槽Linux套件
- 【Solaris】Solaris檔案系統管理5 ZFS檔案系統擴充套件池與檢查池套件
- Linux下使用LVM管理(擴充套件/縮小/刪除)LinuxLVM套件
- Linux LVM 擴充套件磁碟分割槽LinuxLVM套件
- 轉載hp--unix下檔案系統的擴充套件套件
- lvm管理之pv遷移與lv擴充套件LVM套件
- Laravel 檔案系統擴充套件(支援 OSS+ 七牛)Laravel套件
- hpux擴充檔案系統UX
- [外掛擴充套件]系統主題管理套件
- 【Linux】Linux檔案系統管理5 lvm邏輯卷管理LinuxLVM
- Lvm邏輯卷管理、建立、使用、擴充套件、縮減、遷移、快照、恢復LVM套件
- ?用Chrome擴充套件管理器, 管理你的擴充套件Chrome套件
- 擴充套件資料檔案大小套件
- windows系統磁碟擴容/擴充套件Windows套件
- 管理系統中風險是系統可用性和可擴充套件性的關鍵套件
- kotlin 擴充套件(擴充套件函式和擴充套件屬性)Kotlin套件函式
- 擴充套件系統的磁碟空間套件
- uboot和系統移植擴充套件--主Makefile分析boot套件
- Linux檔案系統-目錄和檔案管理Linux
- GNUC擴充套件:Linux作業系統的核心使用(轉)套件Linux作業系統
- Laravel 圖片,媒體檔案管理擴充套件包推薦Laravel套件
- 【Solaris】Solaris檔案系統管理1 UFS檔案系統的建立
- 【Solaris】Solaris檔案系統管理3 ZFS檔案系統的建立
- oracle 關閉資料檔案的擴充套件Oracle套件
- hp-ux 11.31中線上擴充套件/減小檔案系統UX套件
- 建立本地擴充套件包套件
- 使用 Rust 建立 PHP 擴充套件RustPHP套件
- linux 檔案系統擴容Linux
- Linux LVM空間擴充演示LinuxLVM
- hyperf oss/cos 檔案上傳擴充套件套件
- macOS 探尋檔案擴充套件屬性Mac套件
- 回滾段擴充套件資料檔案套件