系统中有一个sda2是linux lvm格式的,对应了一个lvm的逻辑卷,怎么实现sda2对应二个或者多个逻辑卷呢,详细操作过程如下:
前面二篇文章,也是有关LVM的,每一步都说的很清楚,有兴趣的可以看一下
[root@localhost ~]# df -h //缩小空间前 Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root 356G 39G 299G 12% / tmpfs 3.9G 72K 3.9G 1% /dev/shm /dev/sda1 485M 40M 420M 9% /boot /dev/mapper/VolGroup-lv_home 99G 23G 72G 22% /home [root@localhost ~]# umount /home/ //取消挂载 [root@localhost ~]# e2fsck -f /dev/mapper/VolGroup-lv_home //磁盘检测 e2fsck 1.41.12 (17-May-2010) 第一步: 检查inode,块,和大小 第二步: 检查目录结构 第3步: 检查目录连接性 Pass 4: Checking reference counts 第5步: 检查簇概要信息 /dev/mapper/VolGroup-lv_home: 1580/5898240 files (4.4% non-contiguous), 6244001/23592960 blocks [root@localhost ~]# resize2fs -p /dev/mapper/VolGroup-lv_home 85G resize2fs 1.41.12 (17-May-2010) Resizing the filesystem on /dev/mapper/VolGroup-lv_home to 22282240 (4k) blocks. Begin pass 3 (max = 720) 正在扫描inode表 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX The filesystem on /dev/mapper/VolGroup-lv_home is now 22282240 blocks long. [root@localhost ~]# mount /home/ //在挂上去 [root@localhost ~]# df -h //在看一下,分区情况 Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root 356G 39G 299G 12% / tmpfs 3.9G 72K 3.9G 1% /dev/shm /dev/sda1 485M 40M 420M 9% /boot /dev/mapper/VolGroup-lv_home 84G 23G 58G 29% /home //变小了 [root@localhost ~]# lvreduce -L 85G /dev/mapper/VolGroup-lv_home //减小home分区 WARNING: Reducing active and open logical volume to 85.00 GiB THIS MAY DESTROY YOUR DATA (filesystem etc.) Do you really want to reduce lv_home? [y/n]: y Reducing logical volume lv_home to 85.00 GiB Logical volume lv_home successfully resized [root@localhost ~]# vgdisplay //查看一下逻辑卷组的情况 --- Volume group --- VG Name VolGroup System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 7 VG Access read/write VG Status resizable MAX LV 0 Cur LV 3 Open LV 3 Max PV 0 Cur PV 1 Act PV 1 VG Size 465.27 GiB PE Size 4.00 MiB Total PE 119109 Alloc PE / Size 115269 / 450.27 GiB Free PE / Size 3840 / 15.00 GiB //有可用空间3840个PE,15GB VG UUID Vt2V4t-Byxs-tQqk-cY0h-IDE3-pabX-LUfkRS //用VolGroup卷组中所有可用空间,创建逻辑卷tanktest卷,下午列举几个常用的 [root@localhost ~]# lvcreate --name tanktest -l 100%FREE VolGroup Logical volume "tanktest" created //在VolGroup卷组中创建一个200M逻辑卷tanktest1 [root@localhost ~]# lvcreate -L 200 -n tanktest1 VolGroup //在VolGroup卷组中创建一个20G逻辑卷tanktest2 [root@localhost ~]# lvcreate -L 20G -n tanktest2 VolGroup //用VolGroup卷组中50%的可用空间,创建逻辑卷tanktest3 [root@localhost ~]# lvcreate -l 50%VG -n tanktest3 VolGroup [root@localhost ~]# mkdir /mnt/tanktest //创建挂载目录 [root@localhost ~]# mkfs.ext4 /dev/VolGroup/tanktest //格式化新建的逻辑卷tanktest mke2fs 1.41.12 (17-May-2010) 文件系统标签= 操作系统:Linux 块大小=4096 (log=2) 分块大小=4096 (log=2) Stride=1 blocks, Stripe width=0 blocks 983040 inodes, 3932160 blocks 196608 blocks (5.00%) reserved for the super user 第一个数据块=0 Maximum filesystem blocks=4026531840 120 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208 正在写入inode表: 完成 Creating journal (32768 blocks): 完成 Writing superblocks and filesystem accounting information: 完成 This filesystem will be automatically checked every 27 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@localhost ~]# echo '/dev/VolGroup/tanktest /mnt/tanktest ext4 defaults 0 0' >> /etc/fstab //自动挂载 [root@localhost ~]# reboot //重启,检测一下是不是能自动挂载 [root@localhost ~]# df -h //查看分区情况,新逻辑卷已正确挂载 Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root 356G 40G 298G 12% / tmpfs 3.9G 0 3.9G 0% /dev/shm /dev/sda1 485M 40M 420M 9% /boot /dev/mapper/VolGroup-lv_home 84G 23G 58G 29% /home /dev/mapper/VolGroup-tanktest 15G 166M 14G 2% /mnt/tanktest
转载请注明
作者:海底苍鹰
地址:http://blog.51yip.com/linux/1780.html