centos6.5LVM磁盘管理
时间:2019-11-04 10:48 来源:linux.it.net.cn 作者:IT
# 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
Disk /dev/vda: 536.9 GB, 536870912000 bytes
16 heads, 63 sectors/track, 1040253 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: 0x0008e6ec
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 203583 102400000 8e Linux LVM
Partition 2 does not end on cylinder boundary.
/dev/vda3 203583 205664 1048576 82 Linux swap / Solaris
Partition 3 does not end on cylinder boundary.
Command (m for help): n
Command action
e extended
p primary partition (1-4)
e
Selected partition 4
First cylinder (1-1040253, default 1): 205665
Last cylinder, +cylinders or +size{K,M,G} (205665-1040253, default 1040253):
Using default value 1040253
Command (m for help): p
Disk /dev/vda: 536.9 GB, 536870912000 bytes
16 heads, 63 sectors/track, 1040253 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: 0x0008e6ec
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 203583 102400000 8e Linux LVM
Partition 2 does not end on cylinder boundary.
/dev/vda3 203583 205664 1048576 82 Linux swap / Solaris
Partition 3 does not end on cylinder boundary.
/dev/vda4 205665 1040253 420632856 5 Extended
Command (m for help):n
First cylinder (205665-1040253, default 205665):
Using default value 205665
Last cylinder, +cylinders or +size{K,M,G} (205665-1040253, default 1040253): +10G
Command (m for help): n
First cylinder (226471-1040253, default 226471):
Using default value 226471
Last cylinder, +cylinders or +size{K,M,G} (226471-1040253, default 1040253): +10G
Command (m for help): t
Partition number (1-6): 5
Hex code (type L to list codes): L
0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris
1 FAT12 39 Plan 9 82 Linux swap / So c1 DRDOS/sec (FAT-
2 XENIX root 3c PartitionMagic 83 Linux c4 DRDOS/sec (FAT-
3 XENIX usr 40 Venix 80286 84 OS/2 hidden C: c6 DRDOS/sec (FAT-
4 FAT16 <32M 41 PPC PReP Boot 85 Linux extended c7 Syrinx
5 Extended 42 SFS 86 NTFS volume set da Non-FS data
6 FAT16 4d QNX4.x 87 NTFS volume set db CP/M / CTOS / .
7 HPFS/NTFS 4e QNX4.x 2nd part 88 Linux plaintext de Dell Utility
8 AIX 4f QNX4.x 3rd part 8e Linux LVM df BootIt
9 AIX bootable 50 OnTrack DM 93 Amoeba e1 DOS access
a OS/2 Boot Manag 51 OnTrack DM6 Aux 94 Amoeba BBT e3 DOS R/O
b W95 FAT32 52 CP/M 9f BSD/OS e4 SpeedStor
c W95 FAT32 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi eb BeOS fs
e W95 FAT16 (LBA) 54 OnTrackDM6 a5 FreeBSD ee GPT
f W95 Ext'd (LBA) 55 EZ-Drive a6 OpenBSD ef EFI (FAT-12/16/
10 OPUS 56 Golden Bow a7 NeXTSTEP f0 Linux/PA-RISC b
11 Hidden FAT12 5c Priam Edisk a8 Darwin UFS f1 SpeedStor
12 Compaq diagnost 61 SpeedStor a9 NetBSD f4 SpeedStor
14 Hidden FAT16 <3 63 GNU HURD or Sys ab Darwin boot f2 DOS secondary
16 Hidden FAT16 64 Novell Netware af HFS / HFS+ fb VMware VMFS
17 Hidden HPFS/NTF 65 Novell Netware b7 BSDI fs fc VMware VMKCORE
18 AST SmartSleep 70 DiskSecure Mult b8 BSDI swap fd Linux raid auto
1b Hidden W95 FAT3 75 PC/IX bb Boot Wizard hid fe LANstep
1c Hidden W95 FAT3 80 Old Minix be Solaris boot ff BBT
1e Hidden W95 FAT1
Hex code (type L to list codes): 8e
Changed system type of partition 5 to 8e (Linux LVM)
Command (m for help): t
Partition number (1-6): 6
Hex code (type L to list codes): 8e
Changed system type of partition 6 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 16: 设备或资源忙.
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.
------------------------------------------
# ll /dev/vda*
brw-rw---- 1 root disk 252, 0 5月 6 11:31 /dev/vda
brw-rw---- 1 root disk 252, 1 5月 6 09:36 /dev/vda1
brw-rw---- 1 root disk 252, 2 5月 6 09:36 /dev/vda2
brw-rw---- 1 root disk 252, 3 5月 6 09:36 /dev/vda3
[root@it.net.cn ~]# partx -a /dev/vda
BLKPG: Device or resource busy
error adding partition 1
BLKPG: Device or resource busy
error adding partition 2
BLKPG: Device or resource busy
error adding partition 3
[root@it.net.cn ~]# ll /dev/vda*
brw-rw---- 1 root disk 252, 0 5月 6 11:31 /dev/vda
brw-rw---- 1 root disk 252, 1 5月 6 09:36 /dev/vda1
brw-rw---- 1 root disk 252, 2 5月 6 09:36 /dev/vda2
brw-rw---- 1 root disk 252, 3 5月 6 09:36 /dev/vda3
brw-rw---- 1 root disk 252, 4 5月 6 11:32 /dev/vda4
brw-rw---- 1 root disk 252, 5 5月 6 11:32 /dev/vda5
brw-rw---- 1 root disk 252, 6 5月 6 11:32 /dev/vda6
# pvcreate /dev/vda[5-6]
Physical volume "/dev/vda5" successfully created
Physical volume "/dev/vda6" successfully created
# pvdisplay | less
# pvsv
#vgcreate miantuan /dev/vda[5-6]
Volume group "miantuan" successfully created
# vgdisplay | less
# vgs
# lvcreate -n jiaozi -L +200M miantuan
Logical volume "jiaozi" created
# lvcreate -n jiaozi -L +200M miantuan
Logical volume "jiaozi" created
[root@it.net.cn ~]# lvcreate -n baozi -L +400M miantuan
Logical volume "baozi" created
[root@it.net.cn ~]# lvcreate -n youtiao -L +400M miantuan
Logical volume "youtiao" created
lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
baozi miantuan -wi-ao 400.00m
jiaozi miantuan -wi-ao 200.00m
youtiao miantuan -wi-ao 400.00m
25 mkfs.ext4 /dev/miantuan/jiaozi
26 mkfs.ext4 /dev/miantuan/baozi
27 mkfs.ext4 /dev/miantuan/youtiao
28 mkdir /mnt/youtiao
29 mkdir /mnt/baozi
30 mkdir /mnt/jiaozi
31 mount /dev/mapper/miantuan-youtiao /mnt/youtiao/
32 mount -t ext4 /dev/miantuan/baozi /mnt/baozi/
33 mount /dev/miantuan/jiaozi /mnt/jiaozi/
在线扩容:
# lvextend -L +100M /dev/miantuan/baozi --扩容 (住:+100M实在原来的基础上加100M.100M就是直接加到100M)
# resize2fs /dev/miantuan/baozi --刷新youtiao的容量
# df -h --查看是否成功
7.缩小容量:
[root@it.net.cn ~]# umount /mnt/youtiao/
[root@it.net.cn ~]# e2fsck -f /dev/miantuan/youtiao
e2fsck 1.41.12 (17-May-2010)
第一步: 检查inode,块,和大小
第二步: 检查目录结构
第3步: 检查目录连接性
Pass 4: Checking reference counts
第5步: 检查簇概要信息
/dev/miantuan/youtiao: 11/102400 files (0.0% non-contiguous), 23438/409600 blocks
[root@it.net.cn ~]# echo $?
0
[root@it.net.cn ~]# resize2fs /dev/miantuan/youtiao 200M
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/miantuan/youtiao to 204800 (1k) blocks.
The filesystem on /dev/miantuan/youtiao is now 204800 blocks long.
[root@it.net.cn ~]# lvreduce -L 200M /dev/miantuan/youtiao
WARNING: Reducing active logical volume to 200.00 MiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce youtiao? [y/n]: y
Reducing logical volume youtiao to 200.00 MiB
Logical volume youtiao successfully resized
[root@it.net.cn ~]# mount /dev/miantuan/youtiao /mnt/youtiao/
使用PE
# lvcreate -n mianbao -l 50 miantuan
# mkfs.ext4 /dev/miantuan/mianbao
# mkdir /mnt/mianbao
# mount /dev/miantuan/mianbao /mnt/mianbao/
---------------------------------------------------------------------------------------------------------------
删除
1. 卸载
umount /dev/miantuan/youtiao
[root@it.net.cn ~]# umount /dev/miantuan/baozi
[root@it.net.cn ~]# umount /dev/miantuan/jiaozi
[root@it.net.cn ~]# umount /dev/miantuan/mianbao
[root@it.net.cn ~]# df -h
文件系统 容量 已用 可用 已用%% 挂载点
/dev/mapper/vol0-root
39G 2.6G 34G 7% /
tmpfs 246M 260K 246M 1% /dev/shm
/dev/vda1 194M 58M 127M 32% /boot
/dev/mapper/vol0-home
504M 17M 462M 4% /home
2.删除LV
# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
baozi miantuan -wi-a- 500.00m
jiaozi miantuan -wi-a- 200.00m
mianbao miantuan -wi-a- 200.00m
rhel6 miantuan -wi-a- 2.00g
youtiao miantuan -wi-a- 200.00m
home vol0 -wi-ao 512.00m
root vol0 -wi-ao 39.06g
[root@it.net.cn ~]# lv
lvchange lvdisplay lvmchange lvmdump lvreduce lvresize
lvconvert lvextend lvmconf lvmsadc lvremove lvs
lvcreate lvm lvmdiskscan lvmsar lvrename lvscan
[root@it.net.cn ~]# lvremove /dev/miantuan/baozi
Do you really want to remove active logical volume baozi? [y/n]: y
Logical volume "baozi" successfully removed
-------------------------------------
[root@it.net.cn ~]# lvreduce /dev/miantuan/jlvreduciaozi
Please specify either size or extents but not both.
Run `lvreduce --help' for more information.
-----------------------------------------
[root@it.net.cn ~]# lvremove /dev/miantuan/jiaozi
Do you really want to remove active logical volume jiaozi? [y/n]: y
Logical volume "jiaozi" successfully removed
[root@it.net.cn ~]# lvremove /dev/miantuan/mianbao
Do you really want to remove active logical volume mianbao? [y/n]: y
Logical volume "mianbao" successfully removed
[root@it.net.cn ~]# lvremove /dev/miantuan/rhel6
Do you really want to remove active logical volume rhel6? [y/n]: y
Logical volume "rhel6" successfully removed
[root@it.net.cn ~]# lvremove /dev/miantuan/youtiao
Do you really want to remove active logical volume youtiao? [y/n]: y
Logical volume "youtiao" successfully removed
# vgremove /dev/vda[5-6] miantuan
Volume group "vda5" not found
Volume group "vda6" not found
Volume group "miantuan" successfully removed
# pvremove /dev/vda[5-6]
Labels on physical volume "/dev/vda5" successfully wiped
Labels on physical volume "/dev/vda6" successfully wiped
# pvs
PV VG Fmt Attr PSize PFree
/dev/vda2 vol0 lvm2 a- 97.62g 58.06g
[root@it.net.cn ~]# 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
Disk /dev/vda: 536.9 GB, 536870912000 bytes
16 heads, 63 sectors/track, 1040253 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: 0x0008e6ec
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 203583 102400000 8e Linux LVM
Partition 2 does not end on cylinder boundary.
/dev/vda3 203583 205664 1048576 82 Linux swap / Solaris
Partition 3 does not end on cylinder boundary.
/dev/vda4 205665 1040253 420632856 5 Extended
/dev/vda5 205665 226470 10486192+ 8e Linux LVM
/dev/vda6 226471 247276 10486192+ 8e Linux LVM
Command (m for help): d
Partition number (1-6): 6
Command (m for help): d
Partition number (1-5): 5
Command (m for help): p
Disk /dev/vda: 536.9 GB, 536870912000 bytes
16 heads, 63 sectors/track, 1040253 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: 0x0008e6ec
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 203583 102400000 8e Linux LVM
Partition 2 does not end on cylinder boundary.
/dev/vda3 203583 205664 1048576 82 Linux swap / Solaris
Partition 3 does not end on cylinder boundary.
/dev/vda4 205665 1040253 420632856 5 Extended
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 16: 设备或资源忙.
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.
(责任编辑:IT)
# 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
Disk /dev/vda: 536.9 GB, 536870912000 bytes
16 heads, 63 sectors/track, 1040253 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: 0x0008e6ec
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 203583 102400000 8e Linux LVM
Partition 2 does not end on cylinder boundary.
/dev/vda3 203583 205664 1048576 82 Linux swap / Solaris
Partition 3 does not end on cylinder boundary.
Command (m for help): n
Command action
e extended
p primary partition (1-4)
e
Selected partition 4
First cylinder (1-1040253, default 1): 205665
Last cylinder, +cylinders or +size{K,M,G} (205665-1040253, default 1040253):
Using default value 1040253
Command (m for help): p
Disk /dev/vda: 536.9 GB, 536870912000 bytes
16 heads, 63 sectors/track, 1040253 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: 0x0008e6ec
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 203583 102400000 8e Linux LVM
Partition 2 does not end on cylinder boundary.
/dev/vda3 203583 205664 1048576 82 Linux swap / Solaris
Partition 3 does not end on cylinder boundary.
/dev/vda4 205665 1040253 420632856 5 Extended
Command (m for help):n
First cylinder (205665-1040253, default 205665):
Using default value 205665
Last cylinder, +cylinders or +size{K,M,G} (205665-1040253, default 1040253): +10G
Command (m for help): n
First cylinder (226471-1040253, default 226471):
Using default value 226471
Last cylinder, +cylinders or +size{K,M,G} (226471-1040253, default 1040253): +10G
Command (m for help): t
Partition number (1-6): 5
Hex code (type L to list codes): L
0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris
1 FAT12 39 Plan 9 82 Linux swap / So c1 DRDOS/sec (FAT-
2 XENIX root 3c PartitionMagic 83 Linux c4 DRDOS/sec (FAT-
3 XENIX usr 40 Venix 80286 84 OS/2 hidden C: c6 DRDOS/sec (FAT-
4 FAT16 <32M 41 PPC PReP Boot 85 Linux extended c7 Syrinx
5 Extended 42 SFS 86 NTFS volume set da Non-FS data
6 FAT16 4d QNX4.x 87 NTFS volume set db CP/M / CTOS / .
7 HPFS/NTFS 4e QNX4.x 2nd part 88 Linux plaintext de Dell Utility
8 AIX 4f QNX4.x 3rd part 8e Linux LVM df BootIt
9 AIX bootable 50 OnTrack DM 93 Amoeba e1 DOS access
a OS/2 Boot Manag 51 OnTrack DM6 Aux 94 Amoeba BBT e3 DOS R/O
b W95 FAT32 52 CP/M 9f BSD/OS e4 SpeedStor
c W95 FAT32 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi eb BeOS fs
e W95 FAT16 (LBA) 54 OnTrackDM6 a5 FreeBSD ee GPT
f W95 Ext'd (LBA) 55 EZ-Drive a6 OpenBSD ef EFI (FAT-12/16/
10 OPUS 56 Golden Bow a7 NeXTSTEP f0 Linux/PA-RISC b
11 Hidden FAT12 5c Priam Edisk a8 Darwin UFS f1 SpeedStor
12 Compaq diagnost 61 SpeedStor a9 NetBSD f4 SpeedStor
14 Hidden FAT16 <3 63 GNU HURD or Sys ab Darwin boot f2 DOS secondary
16 Hidden FAT16 64 Novell Netware af HFS / HFS+ fb VMware VMFS
17 Hidden HPFS/NTF 65 Novell Netware b7 BSDI fs fc VMware VMKCORE
18 AST SmartSleep 70 DiskSecure Mult b8 BSDI swap fd Linux raid auto
1b Hidden W95 FAT3 75 PC/IX bb Boot Wizard hid fe LANstep
1c Hidden W95 FAT3 80 Old Minix be Solaris boot ff BBT
1e Hidden W95 FAT1
Hex code (type L to list codes): 8e
Changed system type of partition 5 to 8e (Linux LVM)
Command (m for help): t
Partition number (1-6): 6
Hex code (type L to list codes): 8e
Changed system type of partition 6 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 16: 设备或资源忙.
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.
------------------------------------------
# ll /dev/vda*
brw-rw---- 1 root disk 252, 0 5月 6 11:31 /dev/vda
brw-rw---- 1 root disk 252, 1 5月 6 09:36 /dev/vda1
brw-rw---- 1 root disk 252, 2 5月 6 09:36 /dev/vda2
brw-rw---- 1 root disk 252, 3 5月 6 09:36 /dev/vda3
[root@it.net.cn ~]# partx -a /dev/vda
BLKPG: Device or resource busy
error adding partition 1
BLKPG: Device or resource busy
error adding partition 2
BLKPG: Device or resource busy
error adding partition 3
[root@it.net.cn ~]# ll /dev/vda*
brw-rw---- 1 root disk 252, 0 5月 6 11:31 /dev/vda
brw-rw---- 1 root disk 252, 1 5月 6 09:36 /dev/vda1
brw-rw---- 1 root disk 252, 2 5月 6 09:36 /dev/vda2
brw-rw---- 1 root disk 252, 3 5月 6 09:36 /dev/vda3
brw-rw---- 1 root disk 252, 4 5月 6 11:32 /dev/vda4
brw-rw---- 1 root disk 252, 5 5月 6 11:32 /dev/vda5
brw-rw---- 1 root disk 252, 6 5月 6 11:32 /dev/vda6
# pvcreate /dev/vda[5-6]
Physical volume "/dev/vda5" successfully created
Physical volume "/dev/vda6" successfully created
# pvdisplay | less
# pvsv
#vgcreate miantuan /dev/vda[5-6]
Volume group "miantuan" successfully created
# vgdisplay | less
# vgs
# lvcreate -n jiaozi -L +200M miantuan
Logical volume "jiaozi" created
# lvcreate -n jiaozi -L +200M miantuan
Logical volume "jiaozi" created
[root@it.net.cn ~]# lvcreate -n baozi -L +400M miantuan
Logical volume "baozi" created
[root@it.net.cn ~]# lvcreate -n youtiao -L +400M miantuan
Logical volume "youtiao" created
lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
baozi miantuan -wi-ao 400.00m
jiaozi miantuan -wi-ao 200.00m
youtiao miantuan -wi-ao 400.00m
25 mkfs.ext4 /dev/miantuan/jiaozi
26 mkfs.ext4 /dev/miantuan/baozi
27 mkfs.ext4 /dev/miantuan/youtiao
28 mkdir /mnt/youtiao
29 mkdir /mnt/baozi
30 mkdir /mnt/jiaozi
31 mount /dev/mapper/miantuan-youtiao /mnt/youtiao/
32 mount -t ext4 /dev/miantuan/baozi /mnt/baozi/
33 mount /dev/miantuan/jiaozi /mnt/jiaozi/
在线扩容:
# lvextend -L +100M /dev/miantuan/baozi --扩容 (住:+100M实在原来的基础上加100M.100M就是直接加到100M)
# resize2fs /dev/miantuan/baozi --刷新youtiao的容量
# df -h --查看是否成功
7.缩小容量:
[root@it.net.cn ~]# umount /mnt/youtiao/
[root@it.net.cn ~]# e2fsck -f /dev/miantuan/youtiao
e2fsck 1.41.12 (17-May-2010)
第一步: 检查inode,块,和大小
第二步: 检查目录结构
第3步: 检查目录连接性
Pass 4: Checking reference counts
第5步: 检查簇概要信息
/dev/miantuan/youtiao: 11/102400 files (0.0% non-contiguous), 23438/409600 blocks
[root@it.net.cn ~]# echo $?
0
[root@it.net.cn ~]# resize2fs /dev/miantuan/youtiao 200M
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/miantuan/youtiao to 204800 (1k) blocks.
The filesystem on /dev/miantuan/youtiao is now 204800 blocks long.
[root@it.net.cn ~]# lvreduce -L 200M /dev/miantuan/youtiao
WARNING: Reducing active logical volume to 200.00 MiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce youtiao? [y/n]: y
Reducing logical volume youtiao to 200.00 MiB
Logical volume youtiao successfully resized
[root@it.net.cn ~]# mount /dev/miantuan/youtiao /mnt/youtiao/
使用PE
# lvcreate -n mianbao -l 50 miantuan
# mkfs.ext4 /dev/miantuan/mianbao
# mkdir /mnt/mianbao
# mount /dev/miantuan/mianbao /mnt/mianbao/
---------------------------------------------------------------------------------------------------------------
删除
1. 卸载
umount /dev/miantuan/youtiao
[root@it.net.cn ~]# umount /dev/miantuan/baozi
[root@it.net.cn ~]# umount /dev/miantuan/jiaozi
[root@it.net.cn ~]# umount /dev/miantuan/mianbao
[root@it.net.cn ~]# df -h
文件系统 容量 已用 可用 已用%% 挂载点
/dev/mapper/vol0-root
39G 2.6G 34G 7% /
tmpfs 246M 260K 246M 1% /dev/shm
/dev/vda1 194M 58M 127M 32% /boot
/dev/mapper/vol0-home
504M 17M 462M 4% /home
2.删除LV
# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
baozi miantuan -wi-a- 500.00m
jiaozi miantuan -wi-a- 200.00m
mianbao miantuan -wi-a- 200.00m
rhel6 miantuan -wi-a- 2.00g
youtiao miantuan -wi-a- 200.00m
home vol0 -wi-ao 512.00m
root vol0 -wi-ao 39.06g
[root@it.net.cn ~]# lv
lvchange lvdisplay lvmchange lvmdump lvreduce lvresize
lvconvert lvextend lvmconf lvmsadc lvremove lvs
lvcreate lvm lvmdiskscan lvmsar lvrename lvscan
[root@it.net.cn ~]# lvremove /dev/miantuan/baozi
Do you really want to remove active logical volume baozi? [y/n]: y
Logical volume "baozi" successfully removed
-------------------------------------
[root@it.net.cn ~]# lvreduce /dev/miantuan/jlvreduciaozi
Please specify either size or extents but not both.
Run `lvreduce --help' for more information.
-----------------------------------------
[root@it.net.cn ~]# lvremove /dev/miantuan/jiaozi
Do you really want to remove active logical volume jiaozi? [y/n]: y
Logical volume "jiaozi" successfully removed
[root@it.net.cn ~]# lvremove /dev/miantuan/mianbao
Do you really want to remove active logical volume mianbao? [y/n]: y
Logical volume "mianbao" successfully removed
[root@it.net.cn ~]# lvremove /dev/miantuan/rhel6
Do you really want to remove active logical volume rhel6? [y/n]: y
Logical volume "rhel6" successfully removed
[root@it.net.cn ~]# lvremove /dev/miantuan/youtiao
Do you really want to remove active logical volume youtiao? [y/n]: y
Logical volume "youtiao" successfully removed
# vgremove /dev/vda[5-6] miantuan
Volume group "vda5" not found
Volume group "vda6" not found
Volume group "miantuan" successfully removed
# pvremove /dev/vda[5-6]
Labels on physical volume "/dev/vda5" successfully wiped
Labels on physical volume "/dev/vda6" successfully wiped
# pvs
PV VG Fmt Attr PSize PFree
/dev/vda2 vol0 lvm2 a- 97.62g 58.06g
[root@it.net.cn ~]# 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
Disk /dev/vda: 536.9 GB, 536870912000 bytes
16 heads, 63 sectors/track, 1040253 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: 0x0008e6ec
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 203583 102400000 8e Linux LVM
Partition 2 does not end on cylinder boundary.
/dev/vda3 203583 205664 1048576 82 Linux swap / Solaris
Partition 3 does not end on cylinder boundary.
/dev/vda4 205665 1040253 420632856 5 Extended
/dev/vda5 205665 226470 10486192+ 8e Linux LVM
/dev/vda6 226471 247276 10486192+ 8e Linux LVM
Command (m for help): d
Partition number (1-6): 6
Command (m for help): d
Partition number (1-5): 5
Command (m for help): p
Disk /dev/vda: 536.9 GB, 536870912000 bytes
16 heads, 63 sectors/track, 1040253 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: 0x0008e6ec
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 203583 102400000 8e Linux LVM
Partition 2 does not end on cylinder boundary.
/dev/vda3 203583 205664 1048576 82 Linux swap / Solaris
Partition 3 does not end on cylinder boundary.
/dev/vda4 205665 1040253 420632856 5 Extended
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 16: 设备或资源忙.
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.
|