2、卸载磁盘:
[root@Platform-Ops-datacenter03 ~]# umount /data/
umount: /data: device is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
红色部分报错,是因为/data分区中有正在使用的文件或程序。
查看什么程序在使用/data下文件:使用lsof命令
[root@Platform-Ops-datacenter03 ~]# lsof /data/
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
agent 10450 root 5u REG 253,0 254 18079747 /data/logs/agent/agent.log
3、重新创建分区并修改分区格式:
[root@10-19-64-242 ~]# 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 0x40e1b7b1.
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-124830, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-124830, default 124830):
Using default value 124830
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
[root@10-19-64-242 ~]# pvdisplay
"/dev/vdb1" is a new physical volume of "60.00 GiB"
--- NEW Physical volume ---
PV Name /dev/vdb1
VG Name
PV Size 60.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID CtAqc6-MXW6-cUuS-q0n2-yObL-CrP8-gAXtFv
创建vg:
[root@10-19-64-242 ~]# vgcreate DataCenter0 /dev/vdb1
Volume group "DataCenter0" successfully created
[root@10-19-64-242 ~]# vgdisplay
--- Volume group ---
VG Name DataCenter0
System ID
Format lvm2
Metadata Areas 1
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 1
Act PV 1
VG Size 60.00 GiB
PE Size 4.00 MiB
Total PE 15359
Alloc PE / Size 0 / 0
Free PE / Size 15359 / 60.00 GiB
VG UUID LMBzfK-0BVm-xCoy-tfPG-pxQC-gLSH-HURQzO
[root@10-19-64-242 ~]#
创建lv:
[root@10-19-64-242 ~]# lvcreate -l 15359 -n lvDatacenter DataCenter0
Logical volume "lvDatacenter" created.
[root@10-19-64-242 ~]# lvdisplay
--- Logical volume ---
LV Path /dev/DataCenter0/lvDatacenter
LV Name lvDatacenter
VG Name DataCenter0
LV UUID CSh3kj-pVZz-uPAZ-SFgh-3ktd-gJUn-0Fdf3x
LV Write Access read/write
LV Creation host, time 10-19-64-242, 2016-09-19 17:36:17 +0800
LV Status available
# open 0
LV Size 60.00 GiB
Current LE 15359
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
[root@10-19-64-242 ~]#
格式化lv:
[root@10-19-64-242 ~]# mkfs -t ext3 /dev/DataCenter0/lvDatacenter
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
3932160 inodes, 15727616 blocks
786380 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
480 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
This filesystem will be automatically checked every 20 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@10-19-64-242 ~]#
可见新加udisk已经挂载成功。
4、开始扩容lvm(可以参考http://123.59.83.120:8080/forum. ... 3&highlight=lvm)
a、新加udisk创建分区:
[root@Platform-Ops-datacenter03 ~]# fdisk /dev/vdd
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x6b4d8acd.
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)
1
Invalid partition number for type `1'
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-4161015, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-4161015, default 4161015):
Using default value 4161015
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
b、格式化分区:
[root@Platform-Ops-datacenter03 ~]# mkfs -t ext3 /dev/vdd1
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
131072000 inodes, 524287882 blocks
26214394 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
16000 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, 512000000
This filesystem will be automatically checked every 38 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@Platform-Ops-datacenter03 ~]#
磁盘较大,格式化时间较长,请耐心等待。
c、创建pv:
[root@Platform-Ops-datacenter03 ~]# pvcreate /dev/vdd1
Physical volume "/dev/vdd1" successfully created
[root@Platform-Ops-datacenter03 ~]#
d、扩展vg:
[root@Platform-Ops-datacenter03 ~]# vgdisplay
--- Volume group ---
VG Name DataCenter0
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 2
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 2
Act PV 2
VG Size 3.91 TiB
PE Size 4.00 MiB
Total PE 1023998
Alloc PE / Size 1023998 / 3.91 TiB
Free PE / Size 0 / 0
VG UUID 0P1yKj-JUpM-BLUM-SM2e-unGE-UMS6-QOsYTd
扩展pv:
[root@Platform-Ops-datacenter03 ~]# vgdisplay
--- Volume group ---
VG Name DataCenter0
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 0
Max PV 0
Cur PV 3
Act PV 3
VG Size 5.86 TiB
PE Size 4.00 MiB
Total PE 1535997
Alloc PE / Size 1023998 / 3.91 TiB
Free PE / Size 511999 / 1.95 TiB
VG UUID 0P1yKj-JUpM-BLUM-SM2e-unGE-UMS6-QOsYTd
[root@Platform-Ops-datacenter03 ~]#
可以看见还有511999个pe可用;
[root@Platform-Ops-datacenter03 ~]# lvextend -l +511999 /dev/DataCenter0/lvDataCenter
Size of logical volume DataCenter0/lvDataCenter changed from 3.91 TiB (1023998 extents) to 5.86 TiB (1535997 extents).
Logical volume lvDataCenter successfully resized
[root@Platform-Ops-datacenter03 ~]#