关于linux在vultr如何升级扩容硬盘root系统盘根目录容量操作说明 LVM
关键命令使用代码复制模式,标红为必须执行# df -h
Filesystem SizeUsed Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
19G 14G4.2G76% /
tmpfs 499M 0499M 0% /dev/shm
/dev/vda1 477M 28M425M 7% /boot
#
从2.5美元升级到5美元,硬盘从20G升级到25G,但是df -h没有看到存在,下面来分区创建下
fdisk -l
Disk /dev/vda: 26.8 GB, 26843545600 bytes
16 heads, 63 sectors/track, 52012 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c2418
Device Boot Start End Blocks IdSystem
/dev/vda1 * 3 1018 512000 83Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2 1018 41611 20458496 8eLinux LVM
Partition 2 does not end on cylinder boundary.
Disk /dev/mapper/VolGroup-lv_root: 19.9 GB, 19906166784 bytes
255 heads, 63 sectors/track, 2420 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: 1040 MB, 1040187392 bytes
255 heads, 63 sectors/track, 126 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
fdisk /dev/vda
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):
请安步骤输入下面操作;
p 查看已分区数量(我看到有两个 /dev/vda1 /dev/vda2)
n 新增加一个分区
p 分区类型我们选择为主分区
3 分区号选3(因为1,2已经用过了,见上)
回车 填写/dev/vda2的数值41611(起始扇区)
回车 默认(结束扇区)
t 修改分区类型
3 选分区3
8e 修改为LVM(8e就是LVM)
w 写分区表(因为是系统硬盘,所以直接退出了,没有关系的)
分区完成后,然后reboot重启生效,因为是系统硬盘,必须要重启生效新的分区表,否则后续无法进行操作
格式化
mkfs -t ext4 /dev/vda3
添加新LVM到已有的LVM组,实现扩容
初始化刚才的分区
pvcreate /dev/vda3
查看卷容量,这时你会看到一个很大的卷了
pvdisplay
将初始化过的分区加入到虚拟卷组VolGroup中
vgextend VolGroup /dev/vda3
查看空间大小
vgdisplay
扩展已有卷的容量并且自动resize2fs刷新容量
lvextend -r -l +100%FREE /dev/mapper/VolGroup-lv_root
可以看到扩充完成的容量FreePE数值已经完全分配完毕
--- Volume group ---
VG Name VolGroup
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No5
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 24.50 GiB
PE Size 4.00 MiB
Total PE 6273
Alloc PE / Size 6273 / 24.50 GiB
FreePE / Size 0 / 0
VG UUID KVPwfe-CykZ-8ub5-7mct-W23P-pvno-jXYVZ
df -h看到容量已经变成了25G
Filesystem SizeUsed Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
24G763M 22G 4% /
tmpfs 499M 0499M 0% /dev/shm
/dev/vda1 477M 28M425M 7% /boot
通过pvs物理卷和vgs卷组与lvs逻辑卷等命令看到的确是成功了的
# pvs
PV VG FmtAttr PSizePFree
/dev/vda2VolGroup lvm2 a--u 19.51g 0
/dev/vda3VolGroup lvm2 a--u5.00g 0
#vgs
VG #PV #LV #SN Attr VSizeVFree
VolGroup 2 2 0 wz--n- 24.50g 0
# lvs
LV VG Attr LSize Pool Origin Data%Meta%Move Log Cpy%Sync Convert
lv_root VolGroup -wi-ao----23.54g
lv_swap VolGroup -wi-ao---- 992.00m
购买地址:http://www.vultr.com/?ref=6813695
教程部分摘选:https://unix.stackexchange.com/questions/138090/cant-resize-a-partition-using-resize2fs
我太懒了,,要复制好几次,下面还是一键吧先分好区然后
mkfs -t ext4 /dev/vda3
pvcreate /dev/vda3
vgextend VolGroup /dev/vda3
lvextend -r -l +100%FREE /dev/mapper/VolGroup-lv_root
df -h
教程现已确认可用状态。 lvm还可以把多块硬盘数据盘整合到系统盘
页:
[1]