回收步骤
1、先通过umount命令卸载掉逻辑卷/bak
2、通过lvremove 删除逻辑卷bakv
3、通过vgremove 删除卷组bakvg
4、通过pvremove 将物理卷转化成普通分区。
5、删除分区
fdisk /dev/sdc
m
d
d
w
分区步骤
1、划分区
(1) 查看有没有可用盘
fdisk -l
echo "- - -" > /sys/class/scsi_host/host0/scan
echo "- - -" > /sys/class/scsi_host/host1/scan
echo "- - -" > /sys/class/scsi_host/host2/scan
(2) 建立分区
fdisk /dev/sdb <<EOF
n
p
1
t
8e
w
EOF
2、创建物理卷
pvcreate /dev/sdb1
3、创建卷组
vgcreate appvg /dev/sdb1
4、创建及扩展逻辑卷
lvcreate -L 2g -n applv appvg
lvextend /dev/mapper/appvg-applv /dev/sdb1
5、格式化逻辑卷
mkfs.ext4 /dev/mapper/appvg-applv
6、逻辑卷及挂载点加入开机自启动
echo '/dev/mapper/appvg-applv /app ext4 defaults 0 0' >>/etc/fstab
7、创建挂载点及挂载
mkdir /app
mount -a
8、查看挂载信息
df –h
在线扩容步骤:
fdisk /dev/sdc<<EOF
n
p
1
t
8e
w
EOF
pvcreate /dev/sdc1
vgextend appvg /dev/sdc
lvextend -l 524824 /dev/mapper/appvg-applv /dev/sdc1
resize2fs /dev/mapper/appvg-applv
df -h
[root@Idmsim04-v-szzb ~]# fdisk -l
Disk /dev/sda: 53.7 GB, 53687091200 bytes
64 heads, 32 sectors/track, 51200 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0006faf1
Device Boot Start End Blocks Id System
/dev/sda1 * 2 401 409600 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 402 51200 52018176 8e Linux LVM
Partition 2 does not end on cylinder boundary.
Disk /dev/sdb: 53.7 GB, 53687091200 bytes
64 heads, 32 sectors/track, 51200 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xab80f46e
Device Boot Start End Blocks Id System
/dev/sdb1 1 51200 52428784 8e Linux LVM
Disk /dev/mapper/vg01-lv_root: 36.1 GB, 36083597312 bytes
255 heads, 63 sectors/track, 4386 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/vg01-lv_swap: 17.2 GB, 17179869184 bytes
255 heads, 63 sectors/track, 2088 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/appvg-applv: 53.7 GB, 53682896896 bytes
255 heads, 63 sectors/track, 6526 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/sdc: 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: 0x00000000
[root@Idmsim04-v-szzb ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
applv appvg -wi-ao---- 50.00g
lv_root vg01 -wi-ao---- 33.61g
lv_swap vg01 -wi-ao---- 16.00g
[root@Idmsim04-v-szzb ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 vg01 lvm2 a-- 49.61g 0
/dev/sdb1 appvg lvm2 a-- 50.00g 0
[root@Idmsim04-v-szzb ~]# vgs
VG #PV #LV #SN Attr VSize VFree
appvg 1 1 0 wz--n- 50.00g 0
vg01 1 2 0 wz--n- 49.61g 0
[root@Idmsim04-v-szzb ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg01-lv_root
33G 4.0G 28G 13% /
tmpfs 7.8G 0 7.8G 0% /dev/shm
/dev/sda1 380M 108M 252M 31% /boot
/dev/mapper/appvg-applv
50G 34G 14G 72% /app
[root@Idmsim04-v-szzb ~]# pvcreate /dev/sdc
Physical volume "/dev/sdc" successfully created
[root@Idmsim04-v-szzb ~]# vgextend appvg /dev/sdc
Volume group "appvg" successfully extended
[root@Idmsim04-v-szzb ~]# vgs
VG #PV #LV #SN Attr VSize VFree
appvg 2 1 0 wz--n- 149.99g 100.00g
vg01 1 2 0 wz--n- 49.61g 0
[root@Idmsim04-v-szzb ~]# vgdisplay
--- Volume group ---
VG Name appvg
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 4
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 149.99 GiB
PE Size 4.00 MiB
Total PE 38398
Alloc PE / Size 12799 / 50.00 GiB
Free PE / Size 25599 / 100.00 GiB
VG UUID dswZw4-gZCG-z4BX-b5q5-fPTd-ET5p-8A5Q7i
--- Volume group ---
VG Name vg01
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 49.61 GiB
PE Size 4.00 MiB
Total PE 12699
Alloc PE / Size 12699 / 49.61 GiB
Free PE / Size 0 / 0
VG UUID nqpzwm-eUVo-HNHM-V3V8-m3dp-ZsnV-8f7WEm
[root@Idmsim04-v-szzb ~]# lvextend -l 38398 /dev/mapper/appvg-applv /dev/sdc
Size of logical volume appvg/applv changed from 50.00 GiB (12799 extents) to 149.99 GiB (38398 extents).
Logical volume applv successfully resized
[root@Idmsim04-v-szzb ~]# resize2fs /dev/mapper/appvg-applv
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/appvg-applv is mounted on /app; on-line resizing required
old desc_blocks = 4, new_desc_blocks = 10
Performing an on-line resize of /dev/mapper/appvg-applv to 39319552 (4k) blocks.
The filesystem on /dev/mapper/appvg-applv is now 39319552 blocks long.
[root@Idmsim04-v-szzb ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg01-lv_root
33G 4.0G 28G 13% /
tmpfs 7.8G 0 7.8G 0% /dev/shm
/dev/sda1 380M 108M 252M 31% /boot
/dev/mapper/appvg-applv
148G 34G 107G 24% /app
附上一条parted扩盘的博客分析:
https://www.niaoyun.com/help/server/380.html