首页 技术 正文
技术 2022年11月17日
0 收藏 419 点赞 2,684 浏览 2995 个字

本次扩容的目的是要扩展 / 的整体容量,具体操作如下:

1、首先查看是否存在未分配的磁盘

[root@NH-Test-44 ~]# fdisk -l

Disk /dev/vda: 53.7 GB, 53687091200 bytes
16 heads, 63 sectors/track, 104025 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: 0x00020122

Device Boot Start End Blocks Id System
/dev/vda1 * 3 409 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2 409 104023 52221760 8e Linux LVM
Partition 2 does not end on cylinder boundary.

Disk /dev/vdb: 10.7 GB, 10737418240 bytes  //大概是这样子,实际上这里已经被格式化了
16 heads, 63 sectors/track, 20805 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: 0x00000000

2、格式化成lvm特定的8e格式

[root@localhost ~]# fdisk /dev/vdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xb86ae868.
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-145634, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-145634, default 145634):
Using default value 145634

Command (m for help): t   //注意这步的操作
Selected partition 1
Hex code (type L to list codes): 8e          //写8e
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 22: Invalid argument.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

3、格式化成pv
[root@localhost ~]# pvcreate /dev/vdb1
Physical volume “/dev/vdb1” successfully created

[root@localhost ~]# vgdisplay
— Volume group —
VG Name vmvg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 9.80 GiB
PE Size 4.00 MiB
Total PE 2509
Alloc PE / Size 2509 / 9.80 GiB
Free PE / Size 0 / 0
VG UUID feom8p-Nh5i-wu2E-PkuJ-8uTb-lkNv-r8zUHm

4、vg扩展
[root@localhost ~]# vgextend vmvg /dev/vdb1
Volume group “vmvg” successfully extended
[root@localhost ~]# vgdisplay
— Volume group —
VG Name vmvg
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 79.80 GiB
PE Size 4.00 MiB
Total PE 20428
Alloc PE / Size 2509 / 9.80 GiB
Free PE / Size 17919 / 70.00 GiB
VG UUID feom8p-Nh5i-wu2E-PkuJ-8uTb-lkNv-r8zUHm

5、还要继续操作如下2步,不然看不到磁盘的增加

[root@NH-Test-44 ~]# df -h
Filesystem                 Size  Used  Avail  Use%  Mounted on
/dev/mapper/vmvg-root  //   
                                45G   12G   32G    27%         /
tmpfs                        3.9G    0      3.9G   0%        /dev/shm
/dev/vda1                  190M  88M   93M   49%       /boot

lvextend -l +100%FREE /dev/mapper/vmvg-root   //扩容对应的lvm,在这里目录 / 对应的lvm卷名字为/dev/mapper/vmvg-root

resize2fs -p /dev/mapper/vmvg-root  //文件系统扩容(占满LV)

再用df -h查看磁盘容量就会发现增大了很多。

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,026
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,517
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,364
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,145
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,779
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,856