[root@oem /]# cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)
====以下是失败的操作
[root@oem /]# cp /home/oracle/soft/em13400_linux64-5.zip /app/
[root@oem /]# df -hT /app
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/datavg-datalv ext4 985M 774M 145M 85% /app
[root@oem /]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 1 2 0 wz--n- 138.69g 4.00m
datavg 1 1 0 wz--n- 1020.00m 4.00m
[root@oem /]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 138.69g 4.00m
/dev/sdb datavg lvm2 a-- 1020.00m 4.00m
[root@oem /]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- 132.00g
swap centos -wi-ao---- <6.69g
datalv datavg -wi-ao---- 1016.00m
[root@oem /]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 140G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 138.7G 0 part
├─centos-root 253:0 0 132G 0 lvm /
└─centos-swap 253:1 0 6.7G 0 lvm [SWAP]
sdb 8:16 0 1G 0 disk
└─datavg-datalv 253:2 0 1016M 0 lvm /app
sdc 8:32 0 1G 0 disk
sr0 11:0 1 1024M 0 rom
[root@oem /]# pvcreate /dev/sdc
Physical volume "/dev/sdc" successfully created.
[root@oem /]# vgextend datavg /dev/sdc
Volume group "datavg" successfully extended
[root@oem /]# lvextend -l +%100free /dev/datavg/datalv
Invalid argument for --extents: +%100free
Error during parsing of command line.
[root@oem /]# history|grep lvextend
1028 lvextend?-l +100%free /dev/datavg/datalv
1029 lvextend -l +100%free /dev/datavg/datalv
1093 lvextend -l +%100free /dev/datavg/datalv
1094 history|grep lvextend
[root@oem /]# lvextend -l +100%free /dev/datavg/datalv
Size of logical volume datavg/datalv changed from 1016.00 MiB (254 extents) to 1.99 GiB (510 extents).
Logical volume datavg/datalv successfully resized.
[root@oem /]# df -hT /app
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/datavg-datalv ext4 985M 774M 145M 85% /app
[root@oem /]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- 132.00g
swap centos -wi-ao---- <6.69g
datalv datavg -wi-ao---- 1.99g
[root@oem /]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 138.69g 4.00m
/dev/sdb datavg lvm2 a-- 1020.00m 0
/dev/sdc datavg lvm2 a-- 1020.00m 0
[root@oem /]# history|grep resize
1024 resize2fs /app
1025 resize2fs /dev/datavg/datalv
1032 resize2fs /dev/datavg/datalv
1045 resize2fs /dev/datavg/datalv
1047 resize2fs /dev/datavg/datalv
1051 resize2fs /dev/datavg/datalv
1053 resize2fs /dev/datavg/datalv
1057 resize2fs /dev/datavg/datalv 1G
1099 history|grep resize
[root@oem /]# resize2fs /dev/datavg/datalv
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/datavg/datalv is mounted on /app; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/datavg/datalv is now 522240 blocks long.
[root@oem /]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 6.6G 0 6.6G 0% /dev
tmpfs tmpfs 6.7G 0 6.7G 0% /dev/shm
tmpfs tmpfs 6.7G 12M 6.6G 1% /run
tmpfs tmpfs 6.7G 0 6.7G 0% /sys/fs/cgroup
/dev/mapper/centos-root xfs 132G 97G 36G 74% /
/dev/sda1 xfs 1014M 198M 817M 20% /boot
tmpfs tmpfs 1.4G 0 1.4G 0% /run/user/0
/dev/mapper/datavg-datalv ext4 2.0G 774M 1.1G 42% /app
[root@oem /]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 138.69g 4.00m
/dev/sdb datavg lvm2 a-- 1020.00m 0
/dev/sdc datavg lvm2 a-- 1020.00m 0
[root@oem /]# resize2fs /dev/datavg/datalv 1G
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/datavg/datalv is mounted on /app; on-line resizing required
resize2fs: On-line shrinking not supported
[root@oem /]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 6.6G 0 6.6G 0% /dev
tmpfs tmpfs 6.7G 0 6.7G 0% /dev/shm
tmpfs tmpfs 6.7G 12M 6.6G 1% /run
tmpfs tmpfs 6.7G 0 6.7G 0% /sys/fs/cgroup
/dev/mapper/centos-root xfs 132G 97G 36G 74% /
/dev/sda1 xfs 1014M 198M 817M 20% /boot
tmpfs tmpfs 1.4G 0 1.4G 0% /run/user/0
/dev/mapper/datavg-datalv ext4 2.0G 774M 1.1G 42% /app
[root@oem /]# umount /app
[root@oem /]# resize2fs /dev/datavg/datalv 1G
resize2fs 1.42.9 (28-Dec-2013)
Please run 'e2fsck -f /dev/datavg/datalv' first.
[root@oem /]# mount /app
[root@oem /]# df -hT /app
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/datavg-datalv ext4 2.0G 774M 1.1G 42% /app
[root@oem /]# umount /app
[root@oem /]# resize2fs /dev/datavg/datalv -1G
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: invalid option -- '1'
Usage: resize2fs [-d debug_flags] [-f] [-F] [-M] [-P] [-p] device [new_size]
[root@oem /]# resize2fs /dev/datavg/datalv 1G
resize2fs 1.42.9 (28-Dec-2013)
Please run 'e2fsck -f /dev/datavg/datalv' first.
[root@oem /]# e2fsck -f /dev/datavg/datalv
e2fsck 1.42.9 (28-Dec-2013)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/datavg/datalv: 12/130048 files (0.0% non-contiguous), 210301/522240 blocks
[root@oem /]# resize2fs /dev/datavg/datalv 1G
resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on /dev/datavg/datalv to 262144 (4k) blocks.
The filesystem on /dev/datavg/datalv is now 262144 blocks long.
[root@oem /]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 6.6G 0 6.6G 0% /dev
tmpfs tmpfs 6.7G 0 6.7G 0% /dev/shm
tmpfs tmpfs 6.7G 12M 6.6G 1% /run
tmpfs tmpfs 6.7G 0 6.7G 0% /sys/fs/cgroup
/dev/mapper/centos-root xfs 132G 97G 36G 74% /
/dev/sda1 xfs 1014M 198M 817M 20% /boot
tmpfs tmpfs 1.4G 0 1.4G 0% /run/user/0
[root@oem /]# mount /app
[root@oem /]# df -hT /app
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/datavg-datalv ext4 993M 774M 158M 84% /app
[root@oem /]# umount /app
[root@oem /]# vgreduce datavg /dev/sdc
Physical volume "/dev/sdc" still in use
[root@oem /]# lvreduce -L -1G /dev/datavg/datalv
WARNING: Reducing active logical volume to 1016.00 MiB.
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce datavg/datalv? [y/n]: y
Size of logical volume datavg/datalv changed from 1.99 GiB (510 extents) to 1016.00 MiB (254 extents).
Logical volume datavg/datalv successfully resized.
[root@oem /]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- 132.00g
swap centos -wi-ao---- <6.69g
datalv datavg -wi-a----- 1016.00m
[root@oem /]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 138.69g 4.00m
/dev/sdb datavg lvm2 a-- 1020.00m 4.00m
/dev/sdc datavg lvm2 a-- 1020.00m 1020.00m
[root@oem /]# vgreduce datavg /dev/sdc
Removed "/dev/sdc" from volume group "datavg"
[root@oem /]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 138.69g 4.00m
/dev/sdb datavg lvm2 a-- 1020.00m 4.00m
/dev/sdc lvm2 --- 1.00g 1.00g
[root@oem /]# pvremove /dev/sdc
Labels on physical volume "/dev/sdc" successfully wiped.
[root@oem /]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 138.69g 4.00m
/dev/sdb datavg lvm2 a-- 1020.00m 4.00m
[root@oem /]# mount /app
mount: wrong fs type, bad option, bad superblock on /dev/mapper/datavg-datalv,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so.
[root@oem /]# fsck -y /dev/datavg/datalv
fsck from util-linux 2.23.2
e2fsck 1.42.9 (28-Dec-2013)
The filesystem size (according to the superblock) is 262144 blocks
The physical size of the device is 260096 blocks
Either the superblock or the partition table is likely to be corrupt!
Abort? yes
[root@oem /]# mount /app
mount: wrong fs type, bad option, bad superblock on /dev/mapper/datavg-datalv,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so.
[root@oem /]# df -hT /app
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/centos-root xfs 132G 97G 36G 74% /
====以上是失败的操作
===以下是正确的操作===
[root@oem /]# mkfs.ext4 /dev/datavg/datalv
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
65024 inodes, 260096 blocks
13004 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=266338304
8 block groups
32768 blocks per group, 32768 fragments per group
8128 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
[root@oem /]# mount /app
[root@oem /]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 6.6G 0 6.6G 0% /dev
tmpfs tmpfs 6.7G 0 6.7G 0% /dev/shm
tmpfs tmpfs 6.7G 12M 6.6G 1% /run
tmpfs tmpfs 6.7G 0 6.7G 0% /sys/fs/cgroup
/dev/mapper/centos-root xfs 132G 97G 36G 74% /
/dev/sda1 xfs 1014M 198M 817M 20% /boot
tmpfs tmpfs 1.4G 0 1.4G 0% /run/user/0
/dev/mapper/datavg-datalv ext4 985M 2.5M 915M 1% /app
[root@oem /]# cp /home/oracle/soft/em13400_linux64-5.zip /app/
[root@oem /]# df -hT /app
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/datavg-datalv ext4 985M 774M 145M 85% /app
[root@oem /]# pvcreate /dev/sdc
Physical volume "/dev/sdc" successfully created.
[root@oem /]# vgextend datavg /dev/sdc
Volume group "datavg" successfully extended
[root@oem /]# lvextend -l +100%free /dev/datavg/datalv
Size of logical volume datavg/datalv changed from 1016.00 MiB (254 extents) to 1.99 GiB (510 extents).
Logical volume datavg/datalv successfully resized.
[root@oem /]# resize2fs /dev/datavg/datalv
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/datavg/datalv is mounted on /app; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/datavg/datalv is now 522240 blocks long.
[root@oem /]# df -hT /app
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/datavg-datalv ext4 2.0G 774M 1.1G 42% /app
[root@oem /]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 138.69g 4.00m
/dev/sdb datavg lvm2 a-- 1020.00m 0
/dev/sdc datavg lvm2 a-- 1020.00m 0
[root@oem /]# vgreduce datavg /dev/sdc
Physical volume "/dev/sdc" still in use
[root@oem /]# umount /app
[root@oem /]# resize2fs /dev/datavg/datalv 1G
resize2fs 1.42.9 (28-Dec-2013)
Please run 'e2fsck -f /dev/datavg/datalv' first.
[root@oem /]# e2fsck -f /dev/datavg/datalv
e2fsck 1.42.9 (28-Dec-2013)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/datavg/datalv: 12/130048 files (0.0% non-contiguous), 210301/522240 blocks
[root@oem /]# resize2fs /dev/datavg/datalv 1G ===此步骤不需要操作,下面lvresize -r替换操作
resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on /dev/datavg/datalv to 262144 (4k) blocks.
The filesystem on /dev/datavg/datalv is now 262144 blocks long.
[root@oem /]# df -hT /app
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/centos-root xfs 132G 97G 36G 74% /
[root@oem /]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- 132.00g
swap centos -wi-ao---- <6.69g
datalv datavg -wi-a----- 1.99g
[root@oem /]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 138.69g 4.00m
/dev/sdb datavg lvm2 a-- 1020.00m 0
/dev/sdc datavg lvm2 a-- 1020.00m 0
[root@oem /]# mount /app
[root@oem /]# df -hT /app
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/datavg-datalv ext4 993M 774M 158M 84% /app
[root@oem /]# umount /app
[root@oem /]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 138.69g 4.00m
/dev/sdb datavg lvm2 a-- 1020.00m 0
/dev/sdc datavg lvm2 a-- 1020.00m 0
[root@oem /]# pvmove -i 2 /dev/sdc
No extents available for allocation.
[root@oem /]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 138.69g 4.00m
/dev/sdb datavg lvm2 a-- 1020.00m 0
/dev/sdc datavg lvm2 a-- 1020.00m 0
[root@oem /]# pvmove /dev/sdc
No extents available for allocation.
[root@oem /]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 138.69g 4.00m
/dev/sdb datavg lvm2 a-- 1020.00m 0
/dev/sdc datavg lvm2 a-- 1020.00m 0
[root@oem /]# vgreduce datavg /dev/sdc
Physical volume "/dev/sdc" still in use
[root@oem /]# lvresize -L 1G -r /dev/datavg/datalv
fsck from util-linux 2.23.2
/dev/mapper/datavg-datalv: 12/65024 files (0.0% non-contiguous), 206093/262144 blocks
resize2fs 1.42.9 (28-Dec-2013)
The filesystem is already 262144 blocks long. Nothing to do!
Size of logical volume datavg/datalv changed from 1.99 GiB (510 extents) to 1.00 GiB (256 extents).
Logical volume datavg/datalv successfully resized.
[root@oem /]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- 132.00g
swap centos -wi-ao---- <6.69g
datalv datavg -wi-a----- 1.00g
[root@oem /]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 138.69g 4.00m
/dev/sdb datavg lvm2 a-- 1020.00m 0
/dev/sdc datavg lvm2 a-- 1020.00m 1016.00m
[root@oem /]# mount /app
[root@oem /]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 6.6G 0 6.6G 0% /dev
tmpfs tmpfs 6.7G 0 6.7G 0% /dev/shm
tmpfs tmpfs 6.7G 12M 6.6G 1% /run
tmpfs tmpfs 6.7G 0 6.7G 0% /sys/fs/cgroup
/dev/mapper/centos-root xfs 132G 97G 36G 74% /
/dev/sda1 xfs 1014M 198M 817M 20% /boot
tmpfs tmpfs 1.4G 0 1.4G 0% /run/user/0
/dev/mapper/datavg-datalv ext4 993M 774M 158M 84% /app
[root@oem /]# vgreduce datavg /dev/sdc
Physical volume "/dev/sdc" still in use
[root@oem /]# pvmove /dev/sdc
No extents available for allocation.
[root@oem /]# pvremove /dev/sdc
PV /dev/sdc is used by VG datavg so please use vgreduce first.
(If you are certain you need pvremove, then confirm by using --force twice.)
/dev/sdc: physical volume label not removed.
[root@oem /]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 138.69g 4.00m
/dev/sdb datavg lvm2 a-- 1020.00m 0
/dev/sdc datavg lvm2 a-- 1020.00m 1016.00m
[root@oem /]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 6.6G 0 6.6G 0% /dev
tmpfs tmpfs 6.7G 0 6.7G 0% /dev/shm
tmpfs tmpfs 6.7G 12M 6.6G 1% /run
tmpfs tmpfs 6.7G 0 6.7G 0% /sys/fs/cgroup
/dev/mapper/centos-root xfs 132G 97G 36G 74% /
/dev/sda1 xfs 1014M 198M 817M 20% /boot
tmpfs tmpfs 1.4G 0 1.4G 0% /run/user/0
/dev/mapper/datavg-datalv ext4 993M 774M 158M 84% /app
[root@oem /]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 138.69g 4.00m
/dev/sdb datavg lvm2 a-- 1020.00m 0
/dev/sdc datavg lvm2 a-- 1020.00m 1016.00m
[root@oem /]# umount /app
[root@oem /]# vgreduce datavg /dev/sdc
Physical volume "/dev/sdc" still in use
[root@oem /]# pvmove /dev/sdc
No extents available for allocation.
[root@oem /]# vgreduce datavg /dev/sdc
Physical volume "/dev/sdc" still in use
[root@oem /]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 138.69g 4.00m
/dev/sdb datavg lvm2 a-- 1020.00m 0
/dev/sdc datavg lvm2 a-- 1020.00m 1016.00m
[root@oem /]# pvs -o+pv_used
PV VG Fmt Attr PSize PFree Used
/dev/sda2 centos lvm2 a-- 138.69g 4.00m <138.69g
/dev/sdb datavg lvm2 a-- 1020.00m 0 1020.00m
/dev/sdc datavg lvm2 a-- 1020.00m 1016.00m 4.00m
[root@oem /]# pvmove /dev/sdc /dev/sdb
WARNING: No free extents on physical volume "/dev/sdb".
No specified PVs have space available.
[root@oem /]# lvresize -L 1.1G -r /dev/datavg/datalv
Rounding size to boundary between physical extents: 1.10 GiB.
fsck from util-linux 2.23.2
/dev/mapper/datavg-datalv: 12/65024 files (0.0% non-contiguous), 206093/262144 blocks
Size of logical volume datavg/datalv changed from 1.00 GiB (256 extents) to 1.10 GiB (282 extents).
Logical volume datavg/datalv successfully resized.
resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on /dev/mapper/datavg-datalv to 288768 (4k) blocks.
The filesystem on /dev/mapper/datavg-datalv is now 288768 blocks long.
[root@oem /]# pvs -o+pv_used
PV VG Fmt Attr PSize PFree Used
/dev/sda2 centos lvm2 a-- 138.69g 4.00m <138.69g
/dev/sdb datavg lvm2 a-- 1020.00m 0 1020.00m
/dev/sdc datavg lvm2 a-- 1020.00m 912.00m 108.00m
[root@oem /]# lvresize -L 0.9G -r /dev/datavg/datalv
Rounding size to boundary between physical extents: 924.00 MiB.
fsck from util-linux 2.23.2
/dev/mapper/datavg-datalv: clean, 12/73152 files, 206603/288768 blocks
resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on /dev/mapper/datavg-datalv to 236544 (4k) blocks.
The filesystem on /dev/mapper/datavg-datalv is now 236544 blocks long.
Size of logical volume datavg/datalv changed from 1.10 GiB (282 extents) to 924.00 MiB (231 extents).
Logical volume datavg/datalv successfully resized.
[root@oem /]# pvs -o+pv_used
PV VG Fmt Attr PSize PFree Used
/dev/sda2 centos lvm2 a-- 138.69g 4.00m <138.69g
/dev/sdb datavg lvm2 a-- 1020.00m 96.00m 924.00m
/dev/sdc datavg lvm2 a-- 1020.00m 1020.00m 0
[root@oem /]# pvmove /dev/sdc /dev/sdb
No data to move for datavg.
[root@oem /]# vgreduce datavg /dev/sdc
Removed "/dev/sdc" from volume group "datavg"
[root@oem /]# df -hT /app
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/centos-root xfs 132G 97G 36G 74% /
[root@oem /]# pvremove /dev/sdc
Labels on physical volume "/dev/sdc" successfully wiped.
[root@oem /]# mount /app
[root@oem /]# df -hT /app
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/datavg-datalv ext4 893M 774M 62M 93% /app
[root@oem /]# ll /app
total 789100
-rw-r--r-- 1 root root 808014516 Sep 3 13:21 em13400_linux64-5.zip
drwx------ 2 root root 16384 Sep 3 13:20 lost+found
[root@oem /]#
相关参考: