LVM擴容-----給虛擬機器新增空間
本來有臺上面配置好CACTI的監控服務的虛擬機器,一直是用來監控現在的伺服器,這天連線上去,才發現這臺機器當時是自己在本機上玩的,沒想到會用在真實工作環境下,現在空間快不夠了,需要給這臺虛擬機器擴下容量了,可是線上擴容我還真沒高過,沒辦法,在弄臺虛擬機器來玩玩。。。
[root@localhost ~]# lvextend -L +900M /dev/VolGroup00/LogVol00
Rounding up size to full physical extent 928.00 MB
Extending logical volume LogVol00 to 7.78 GB
Logical volume LogVol00 successfully resized
[root@localhost ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
6983168 2253172 4369548 35% /
/dev/sda1 101086 12056 83811 13% /boot
tmpfs 257668 0 257668 0% /dev/shm
[root@localhost ~]# fdisk -l
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
6983168 2253172 4369548 35% /
/dev/sda1 101086 12056 83811 13% /boot
tmpfs 257668 0 257668 0% /dev/shm
[root@localhost ~]# fdisk -l
Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1044 8281507+ 8e Linux LVM
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1044 8281507+ 8e Linux LVM
Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
上面是本機現在的清況,下面開始建立物理卷
[root@localhost ~]# pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created
[root@localhost ~]# pvdisplay ##可以用“pvdisplay”命令檢視物理卷情況
--- Physical volume ---
PV Name /dev/sda2
VG Name VolGroup00
PV Size 7.90 GB / not usable 23.41 MB
Allocatable yes (but full)
PE Size (KByte) 32768
Total PE 252
Free PE 0
Allocated PE 252
PV UUID Up0jiK-5I0E-d5J5-wZSu-WIhX-aKRA-OR9Pjm
"/dev/sdb" is a new physical volume of "1.00 GB" ###新建的物理卷
--- NEW Physical volume ---
PV Name /dev/sdb
VG Name
PV Size 1.00 GB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID zkullQ-PgoI-fHH4-xL3K-VLGm-JgMr-T7R1oA
Physical volume "/dev/sdb" successfully created
[root@localhost ~]# pvdisplay ##可以用“pvdisplay”命令檢視物理卷情況
--- Physical volume ---
PV Name /dev/sda2
VG Name VolGroup00
PV Size 7.90 GB / not usable 23.41 MB
Allocatable yes (but full)
PE Size (KByte) 32768
Total PE 252
Free PE 0
Allocated PE 252
PV UUID Up0jiK-5I0E-d5J5-wZSu-WIhX-aKRA-OR9Pjm
"/dev/sdb" is a new physical volume of "1.00 GB" ###新建的物理卷
--- NEW Physical volume ---
PV Name /dev/sdb
VG Name
PV Size 1.00 GB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID zkullQ-PgoI-fHH4-xL3K-VLGm-JgMr-T7R1oA
下面就是將新添的物理卷加入到已有的邏輯卷組中
[root@localhost ~]# vgextend /dev/VolGroup00 /dev/sdb
/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 "VolGroup00" successfully extended
/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 "VolGroup00" successfully extended
[root@localhost ~]# vgdisplay ##檢視卷組的空間
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 4
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 8.84 GB
PE Size 32.00 MB
Total PE 283
Alloc PE / Size 252 / 7.88 GB ###原有的
Free PE / Size 31 / 992.00 MB ##新加的擴容進去的空間
VG UUID 0q4Uy2-coR3-bLwU-izpJ-kLOC-PxO3-9Efm8H
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 4
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 8.84 GB
PE Size 32.00 MB
Total PE 283
Alloc PE / Size 252 / 7.88 GB ###原有的
Free PE / Size 31 / 992.00 MB ##新加的擴容進去的空間
VG UUID 0q4Uy2-coR3-bLwU-izpJ-kLOC-PxO3-9Efm8H
###############################################################
[root@localhost ~]# lvdisplay 檢視下分割槽
--- Logical volume ---
LV Name /dev/VolGroup00/LogVol00
VG Name VolGroup00
LV UUID DDmERv-LIlu-cwXR-oM9t-33wj-l2ko-zw715W
LV Write Access read/write
LV Status available
# open 1
LV Size 6.88 GB
Current LE 220
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 e0uO3o-HHrl-LFD1-iy3j-GSQc-U5mM-Q0GU4F
LV Write Access read/write
LV Status available
# open 1
LV Size 1.00 GB
Current LE 32
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
--- Logical volume ---
LV Name /dev/VolGroup00/LogVol00
VG Name VolGroup00
LV UUID DDmERv-LIlu-cwXR-oM9t-33wj-l2ko-zw715W
LV Write Access read/write
LV Status available
# open 1
LV Size 6.88 GB
Current LE 220
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 e0uO3o-HHrl-LFD1-iy3j-GSQc-U5mM-Q0GU4F
LV Write Access read/write
LV Status available
# open 1
LV Size 1.00 GB
Current LE 32
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
下面就開始擴容的操作了。。。
[root@localhost ~]# lvextend -L +1G /dev/VolGroup00/LogVol00
Extending logical volume LogVol00 to 7.88 GB
Insufficient free space: 32 extents needed, but only 31 available
Extending logical volume LogVol00 to 7.88 GB
Insufficient free space: 32 extents needed, but only 31 available
###這裡顯示失敗,空間不夠,我的命令是加一個G的空間,但是空間不足。。。
[root@localhost ~]# lvextend -L +900M /dev/VolGroup00/LogVol00
Rounding up size to full physical extent 928.00 MB
Extending logical volume LogVol00 to 7.78 GB
Logical volume LogVol00 successfully resized
##成功了,我改為新增900M,其實在上面vgdisplay 的時候可以看到他新增了多少空間,但是當時我操作的時候,沒注意看,呵呵。。。這個時候你在用lvdisplay命令看LV的空間的話,可以看到/dev/VolGroup00/LogVol00的空間已經增大了。。。
下面開始檢查LVM裝置對應inode和block之間的關係
[root@localhost ~]# e2fsck -f /dev/VolGroup00/LogVol00
e2fsck 1.39 (29-May-2006)
/dev/VolGroup00/LogVol00 is mounted.
e2fsck 1.39 (29-May-2006)
/dev/VolGroup00/LogVol00 is mounted.
WARNING!!! Running e2fsck on a mounted filesystem may cause
SEVERE filesystem damage.
SEVERE filesystem damage.
Do you really want to continue (y/n)? yes
/dev/VolGroup00/LogVol00: recovering journal
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/VolGroup00/LogVol00: ***** FILE SYSTEM WAS MODIFIED *****
/dev/VolGroup00/LogVol00: ***** REBOOT LINUX *****
/dev/VolGroup00/LogVol00: 108951/2064384 files (0.3% non-contiguous), 627952/2048000 blocks
/dev/VolGroup00/LogVol00: ***** REBOOT LINUX *****
/dev/VolGroup00/LogVol00: 108951/2064384 files (0.3% non-contiguous), 627952/2048000 blocks
最後是增加的容量生效
[root@localhost ~]# resize2fs /dev/VolGroup00/LogVol00
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/VolGroup00/LogVol00 to 2048000 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol00 is now 2048000 blocks long.
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/VolGroup00/LogVol00 to 2048000 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol00 is now 2048000 blocks long.
最後用df在看下現在的空間情況:
[root@localhost ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
7933376 2253184 5270604 30% / #本來是35%
/dev/sda1 101086 12056 83811 13% /boot
tmpfs 257668 0 257668 0% /dev/shm
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
7933376 2253184 5270604 30% / #本來是35%
/dev/sda1 101086 12056 83811 13% /boot
tmpfs 257668 0 257668 0% /dev/shm
至此在虛擬機器上,最簡單的一個LVM擴容操作完畢,為日後檢視寫本文做備忘。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25462274/viewspace-1442494/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ProxmoxVE虛擬機器LVM擴容虛擬機LVM
- 如何給VirtualBox虛擬機器的ubuntu LVM分割槽擴容虛擬機UbuntuLVM
- 給虛擬機器的增加空間虛擬機
- Ubuntu 22.04擴容LVM空間UbuntuLVM
- 虛擬機器中CentOS-7.9的硬碟空間擴容(EXSI)虛擬機CentOS硬碟
- pve7.2虛擬機器 lvm磁碟擴容,增加硬碟操作虛擬機LVM硬碟
- CentOS虛擬機器擴容CentOS虛擬機
- pve 下的群暉虛擬機器硬碟空間擴容的記錄虛擬機硬碟
- VMware虛擬機器Ubuntu根目錄磁碟空間(/dev/sda1)擴容虛擬機Ubuntudev
- Virtual Box 虛擬機器擴容虛擬機
- 虛擬機器磁碟擴容parted虛擬機
- vm exsi 擴充套件windows虛擬機器磁碟空間套件Windows虛擬機
- lvm 擴充邏輯卷空間(linux的磁碟擴容)LVMLinux
- linux 給lvm磁碟擴容LinuxLVM
- Virtualbox 《虛擬機器空間整理》虛擬機
- vmware中ubuntu虛擬機器擴容Ubuntu虛擬機
- Linux 新增LVM分割槽及LVM分割槽擴容LinuxLVM
- Linux擴充套件LVM空間Linux套件LVM
- LVM邏輯卷線上動態擴容磁碟空間LVM
- VirtualBox擴容CentOS-7虛擬機器磁碟CentOS虛擬機
- 用Jcmd命令分析虛擬機器Metaspace元空間虛擬機
- 解決Ubuntu虛擬機器佔用空間與實際空間不符問題Ubuntu虛擬機
- C. VMware下LINUX的虛擬機器增加磁碟空間Linux虛擬機
- Java虛擬機器的記憶體空間有幾種Java虛擬機記憶體
- Java虛擬機器的記憶體空間有幾種!Java虛擬機記憶體
- Ubuntu空間不足,如何擴容Ubuntu
- Linux虛擬機器擴充套件磁碟Linux虛擬機套件
- KVM虛擬機器新增物理網路卡虛擬機
- 程式虛擬空間分佈
- Dalvik虛擬機器、Java虛擬機器與ART虛擬機器虛擬機Java
- 虛擬機器Unbuntu如何修改硬碟空間大小(不需要分割槽)虛擬機硬碟
- windows下vmware虛擬機器擴充硬碟Windows虛擬機硬碟
- VM虛擬機器 linux系統新增磁碟虛擬機Linux
- 虛擬主機資料庫與空間關係資料庫
- win10系統下怎麼給虛擬磁碟(vhd/vhdx)擴容Win10
- Oracle RAC+DG 表空間擴容Oracle
- java虛擬機器和Dalvik虛擬機器Java虛擬機
- Android 虛擬機器 Vs Java 虛擬機器Android虛擬機Java
- 非 LVM 分割槽動態擴容LVM