本文来自:https://blog.csdn.net/max229max/article/details/80356250
# Step 0: 查看磁盘空间,lv_root 经常100%,目的扩容 lv_root
-
[root@localhost ~]
# df -h
-
Filesystem Size Used Avail Use% Mounted on
-
/dev/mapper/VolGroup-lv_root
-
12G
3.2G
7.7G
30% /
-
tmpfs
1.9G
0
1.9G
0% /dev/shm
-
/dev/sda1
485M
32M
429M
7% /boot
通过命令行查找对应UUID:
VBoxManage.exe list hdds
在location处找到对应的vdi名,找到第一行的UUID
重新分配内存:
VBoxManage modifyhd UUID --resize(--resizebyte) 20480(单位为Mb)
-
[root@localhost ~]
# fdisk -l
-
-
Disk /dev/sda:
107.4 GB,
107374182400 bytes
# 磁盘扩容到100G
-
255 heads,
63 sectors/track,
13054 cylinders
-
Units = cylinders of
16065 *
512 =
8225280 bytes
-
Sector size (logical/physical):
512 bytes /
512 bytes
-
I/O size (minimum/optimal):
512 bytes /
512 bytes
-
Disk identifier:
0x000c9934
-
-
Device Boot Start End Blocks Id System
-
/dev/sda1 *
1
64
512000
83 Linux
-
Partition
1 does
not end on cylinder boundary.
-
/dev/sda2
64
2089
16264192
8e Linux LVM
-
-
Disk /dev/mapper/VolGroup-lv_root:
12.5 GB,
12490637312 bytes
-
255 heads,
63 sectors/track,
1518 cylinders
-
Units = cylinders of
16065 *
512 =
8225280 bytes
-
Sector size (logical/physical):
512 bytes /
512 bytes
-
I/O size (minimum/optimal):
512 bytes /
512 bytes
-
Disk identifier:
0x00000000
-
-
-
Disk /dev/mapper/VolGroup-lv_swap:
4160 MB,
4160749568 bytes
-
255 heads,
63 sectors/track,
505 cylinders
-
Units = cylinders of
16065 *
512 =
8225280 bytes
-
Sector size (logical/physical):
512 bytes /
512 bytes
-
I/O size (minimum/optimal):
512 bytes /
512 bytes
-
Disk identifier:
0x00000000
-
[root@localhost ~]
# fdisk /dev/sda
-
-
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 # new 新分区
-
Command action
-
e extended
-
p primary partition (1-4)
-
p # 选择主分区
-
Partition number (1-4): 3 # 分区序号 3
-
First cylinder (2089-13054, default 2089): # 分区开始块,回车使用默认
-
Using default value 2089
-
Last cylinder, +cylinders or +size{K,M,G} (2089-13054, default 13054): # 分区结束块,回车使用默认
-
Using default value 13054
-
-
Command (m for help): t # 修改分区格式
-
Partition number (1-4): 3 # 选择分区序号
-
Hex code (type L to list codes): 8e # 格式选择8e linux LVM
-
Changed system type of partition 3 to 8e (Linux LVM)
-
-
Command (m for help): p # 显示分区信息
-
-
Disk /dev/sda: 107.4 GB, 107374182400 bytes
-
255 heads, 63 sectors/track, 13054 cylinders
-
Units = cylinders of 16065 * 512 = 8225280 bytes
-
Sector size (logical/physical): 512 bytes / 512 bytes
-
I/O size (minimum/optimal): 512 bytes / 512 bytes
-
Disk identifier: 0x000c9934
-
-
Device Boot Start End Blocks Id System
-
/dev/sda1 * 1 64 512000 83 Linux
-
Partition 1 does not end on cylinder boundary.
-
/dev/sda2 64 2089 16264192 8e Linux LVM
-
/dev/sda3 2089 13054 88079039 8e Linux LVM # 新建的分区,格式8e
-
-
Command (m for help): w # 保存信息
-
The partition table has been altered!
[root@localhost ~]# shutdown -r now
-
[root@ganxide ~]
# pvcreate /dev/sda3
-
Writing physical volume data to disk
"/dev/sda3"
-
Physical volume
"/dev/sda3" successfully created
-
[root@ganxide ~]
# pvdisplay
-
--- Physical volume ---
-
PV Name /dev/sda2
-
VG Name VolGroup
# lv_root卷组
-
PV Size
15.51 GiB /
not usable
3.00 MiB
-
Allocatable yes (but full)
-
PE Size
4.00 MiB
-
Total PE
3970
-
Free PE
0
-
Allocated PE
3970
-
PV UUID
1GHup8
-7fYH-IpYZ-QPgO-cxSl-on5z-M9oPrU
-
-
"/dev/sda3"
is a new physical volume of
"84.00 GiB"
#新的物理卷
-
--- NEW Physical volume ---
-
PV Name /dev/sda3
# 卷名
-
VG Name
# 卷组
-
PV Size
84.00 GiB
-
Allocatable NO
-
PE Size
0
-
Total PE
0
-
Free PE
0
-
Allocated PE
0
-
PV UUID ZnLTXE-nGPK-jQAq-wMwy-f1Mb
-5cvQ
-4lhkmU
-
[root@ganxide ~]
# vgextend VolGroup /dev/sda3
-
Volume group
"VolGroup" successfully extended
-
[root@ganxide ~]
# vgdisplay
-
--- Volume group ---
-
VG Name VolGroup
-
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
99.50 GiB
-
PE Size
4.00 MiB
-
Total PE
25473
-
Alloc PE / Size
3970 /
15.51 GiB
-
Free PE / Size
21503 /
84.00 GiB
# 未分配空间
-
VG UUID pwCU5u-NikD-vMp3-goth-CXJU-Pf18
-0ihmoV
-
[root@ganxide ~]
# df -h
-
Filesystem Size Used Avail Use% Mounted on
-
/dev/mapper/VolGroup-lv_root
-
12G
5.3G
5.7G
49% /
-
tmpfs
1.9G
0
1.9G
0% /dev/shm
-
/dev/sda1
485M
32M
429M
7% /boot
-
-
[root@ganxide ~]
# lvresize -L +50G /dev/mapper/VolGroup-lv_root
-
Extending logical volume lv_root to
61.63 GiB
-
Logical volume lv_root successfully resized
-
[root@ganxide ~]
# resize2fs /dev/mapper/VolGroup-lv_root
-
resize2fs
1.41
.12 (
17-May
-2010)
-
Filesystem at /dev/mapper/VolGroup-lv_root
is mounted on /; on-line resizing required
-
old desc_blocks =
1, new_desc_blocks =
4
-
Performing an on-line resize of /dev/mapper/VolGroup-lv_root to
16156672 (
4k) blocks.
-
The filesystem on /dev/mapper/VolGroup-lv_root
is now
16156672 blocks long.
-
[root@ganxide ~]
# df -h
-
Filesystem Size Used Avail Use% Mounted on
-
/dev/mapper/VolGroup-lv_root
-
61G
5.3G
53G
10% /
# 空间增加到61G 原来只有15G
-
tmpfs
1.9G
0
1.9G
0% /dev/shm
-
/dev/sda1
485M
32M
429M
7% /boot