回收步驟html
一、先經過umount命令卸載掉邏輯卷/bakapp
二、經過lvremove 刪除邏輯卷bakvide
三、經過vgremove 刪除卷組bakvgui
四、經過pvremove 將物理卷轉化成普通分區。3d
五、刪除分區code
fdisk /dev/sdcorm
mserver
dhtm
d rem
w
分區步驟
一、劃分區
(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
二、建立物理卷
pvcreate /dev/sdb1
三、建立卷組
vgcreate appvg /dev/sdb1
四、建立及擴展邏輯卷
lvcreate -L 2g -n applv appvg
lvextend /dev/mapper/appvg-applv /dev/sdb1
五、格式化邏輯卷
mkfs.ext4 /dev/mapper/appvg-applv
六、邏輯卷及掛載點加入開機自啓動
echo '/dev/mapper/appvg-applv /app ext4 defaults 0 0' >>/etc/fstab
七、建立掛載點及掛載
mkdir /app
mount -a
八、查看掛載信息
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