# LVM initialization if [ -f /etc/lvmtab ]; then [ -e /proc/lvm ] || modprobe lvm-mod > /dev/null 2>&1 if [ -e /proc/lvm -a -x /sbin/vgchange ]; then action $"Setting up Logical Volume Management:" /sbin/vgscan && /sbin/vgchange -a y fi fi
其中关键是两个命令,vgscan命令实现扫描所有磁盘得到卷组信息,并创建文件卷组数据文件/etc/lvmtab和/etc/lvmtab.d/*;vgchange -a y命令激活系统所有卷组。
The number of cylinders for this disk is set to 4427. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only)
输入m打印命令行帮助。 输入n增加一个新分区。 输入l查看分区类型列表(82 Linux swa ;83 Linux ;8e Linux LVM ;a5 FreeBSD )。 输入p打印分区信息。 输入t改变一个分区的分区类型。 输入d删除一个分区。 输入w保存分区表并退出。 输入q放弃分区表修改并退出。
创建完物理卷后,可以使用 pvscan 命令扫描查看当前系统的物理卷情况: # pvscan pvscan -- reading all physical volumes (this may take a while...) pvscan -- inactive PV "/dev/sdc1" is in no VG [7.64 GB] pvscan -- total: 1 [7.64 GB] / in use: 0 [0] / in no VG: 1 [7.64 GB]
使用 pvdisplay 查看单个物理卷的信息: # pvdisplay /dev/sdc1 pvdisplay -- "/dev/sdc1" is a new physical volume of 7.64 GB
逻辑卷扩容后,再使用 resize2fs 等工具重新对该逻辑卷上的文件系统进行扩容 # resize2fs -f /dev/vg_test/lv_test resize2fs 1.32 (09-Nov-2002) The filesystem on /dev/vg_test/lv_test is now 262144 blocks long.
操作完后,重新mount上即可 # mount /dev/vg_test/lv_test /home/zjw/lvmtest