linux⽂件系统lv是什么意思,LinuxLVM系列(⼆)lv缩容声明:xfs⽂件系统不⽀持lv缩容,这⾥是ext4⽂件系统
⾸先看下现在的⽂件系统挂载和使⽤情况
[root@aiker01 ~]# df -hT
Filesystem Type Size Ud Avail U% Mounted on
/dev/mapper/cl-root xfs 8.6G 5.3G 3.4G 62% /
devtmpfs devtmpfs 2.4G 0 2.4G 0% /dev
tmpfs tmpfs 2.4G 0 2.4G 0% /dev/shm
tmpfs tmpfs 2.4G 8.7M 2.4G 1% /run
tmpfs tmpfs 2.4G 0 2.4G 0% /sys/fs/cgroup
/dev/mapper/cl-home xfs 4.0G 33M 4.0G 1% /home
/dev/mapper/cl-var xfs 3.0G 159M 2.8G 6% /var
/dev/sda2 xfs 497M 132M 366M 27% /boot
/dev/mapper/vg1-lv1 ext4 5.9G 16M 5.6G 1% /mnt
tmpfs tmpfs 479M 0 479M 0% /run/ur/0
/dev/mapper/vg2-lv2 ext4 3.9G 16M 3.7G 1% /data
[root@aiker01 ~]# ll /mnt/
total 36
-rw-r--r-- 1 root root 9 Dec 7 02:
-rw-r--r-- 1 root root 9 Dec 7 02:
drwxr-xr-x 2 root root 4096 Dec 7 02:34 6
drwxr-xr-x 2 root root 4096 Dec 7 02:34 7
drwxr-xr-x 2 root root 4096 Dec 7 02:34 8
drwx------ 2 root root 16384 Dec 6 03:02 lost+found
[root@aiker01 ~]# cat /
12345678教育资格
卸载掉lv1卷
[root@aiker01 ~]# umount /mnt/
设置lv卷⼤⼩ 下⾯的做法经过试验是会报错的:
[root@aiker01 ~]# lvresize -L 2G /dev/vg1/lv1
WARNING: Reducing active logical volume to 2.00 GiB.
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce vg1/lv1? [y/n]:
WARNING: Invalid input ''.
Do you really want to reduce vg1/lv1? [y/n]: y
Size of logical volume vg1/lv1 changed from <5.99 GiB (1533 extents) to 2.00 GiB (512 extents). Logical volume vg1/lv1 successfully resized.
[root@aiker01 ~]# e2fsck -f !$
e2fsck -f /dev/vg1/lv1
e2fsck 1.42.9 (28-Dec-2013)
The filesystem size (according to the superblock) is 1569792 blocks
The physical size of the device is 524288 blocks
Either the superblock or the partition table is likely to be corrupt!
Abort? y
[root@aiker01 ~]# e2fsck -f /dev/vg1/lv1
e2fsck 1.42.9 (28-Dec-2013)
碰碰乐The filesystem size (according to the superblock) is 1569792 blocks
The physical size of the device is 524288 blocks
Either the superblock or the partition table is likely to be corrupt!
Abort? yes
正确的做法 刚才的错误可以修正回之前的⼤⼩:
[root@aiker01 ~]# lvresize -l 1533 /dev/vg1/lv1
Size of logical volume vg1/lv1 changed from <2.00 GiB (511 extents) to <5.99 GiB (1533 extents). Logical volume vg1/lv1 successfully resized.
[root@aiker01 ~]# resize2fs /dev/vg1/lv1 5.99G
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Invalid new size: 5.99G
雅思作文[root@aiker01 ~]# e2fsck -f /dev/vg1/lv1一年级新学期目标
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/vg1/lv1: 16/392448 files (0.0% non-contiguous), 45115/1569792 blocks
[root@aiker01 ~]# resize2fs /dev/vg1/lv1 4G
resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on /dev/vg1/lv1 to 1048576 (4k) blocks.
The filesystem on /dev/vg1/lv1 is now 1048576 blocks long.
[root@aiker01 ~]# lvresize -L 4G /dev/vg1/lv1 #设置lv⼤⼩为4G
WARNING: Reducing active logical volume to 4.00 GiB.
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce vg1/lv1? [y/n]: y
Size of logical volume vg1/lv1 changed from <5.99 GiB (1533 extents) to 4.00 GiB (1024 extents). Logical volume vg1/lv1 successfully resized.
[root@aiker01 ~]# !e2 #检查是lv有错误
e2fsck -f /dev/vg1/lv1
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/vg1/lv1: 16/261632 files (0.0% non-contiguous), 36907/1048576 blocks
[root@aiker01 ~]# lvdisplay /dev/vg1/lv1
--- Logical volume ---
LV Path /dev/vg1/lv1
LV Name lv1
平的成语
VG Name vg1
LV UUID q6dAzJ-1dbC-2EoY-Fzcp-QqEE-enuU-FS5BLT
LV Write Access read/write
LV Creation host, time aiker01, 2017-12-06 03:02:40 +0800
LV Status available
# open 0
死亡之组LV Size 4.00 GiB
Current LE 1024
Segments 3
Allocation inherit
Read ahead ctors auto
- currently t to 8192
Block device 253:4
[root@aiker01 ~]# vgdisplay /dev/vg1
--- Volume group ---
VG Name vg1
System ID房屋续租合同
Format lvm2
Metadata Areas 3
Metadata Sequence No 23
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.99 GiB
PE Size 4.00 MiB
Total PE 1533
Alloc PE / Size 1024 / 4.00 GiB
Free PE / Size 509 / <1.99 GiB
VG UUID dx3XD9-rQBV-QtBu-EebN-wgjI-CQcn-36iIbm [root@aiker01 ~]# mount /dev/vg1/lv1 /mnt/
[root@aiker01 ~]# ll /mnt/
total 36
-rw-r--r-- 1 root root 9 Dec 7 02:
-
rw-r--r-- 1 root root 9 Dec 7 02:
drwxr-xr-x 2 root root 4096 Dec 7 02:34 6
陷入困境英语
drwxr-xr-x 2 root root 4096 Dec 7 02:34 7
drwxr-xr-x 2 root root 4096 Dec 7 02:34 8
drwx------ 2 root root 16384 Dec 6 03:02 lost+found [root@aiker01 ~]# cat /
12345678
[root@aiker01 ~]# df -hT
Filesystem Type Size Ud Avail U% Mounted on
/dev/mapper/cl-root xfs 8.6G 5.3G 3.4G 62% /
devtmpfs devtmpfs 2.4G 0 2.4G 0% /dev
tmpfs tmpfs 2.4G 0 2.4G 0% /dev/shm
tmpfs tmpfs 2.4G 8.7M 2.4G 1% /run
tmpfs tmpfs 2.4G 0 2.4G 0% /sys/fs/cgroup
/dev/mapper/cl-home xfs 4.0G 33M 4.0G 1% /home
/dev/mapper/cl-var xfs 3.0G 159M 2.8G 6% /var
/dev/sda2 xfs 497M 132M 366M 27% /boot
tmpfs tmpfs 479M 0 479M 0% /run/ur/0
/dev/mapper/vg2-lv2 ext4 3.9G 16M 3.7G 1% /data
/dev/mapper/vg1-lv1 ext4 3.9G 16M 3.7G 1% /mnt
可以清楚的查看后lv1缩容后的⼤⼩,⾥⾯的⽂件并没有损坏。