2、查看系统磁盘情况,/dev/sdb1是/dev/sdb的一块主分区(如何添加分区详见Linux服务器磁盘扩容博文): 3、激活刚创建好的sdb1分区: [root@FisheyeSVN-test /]#partprobe /dev/sdb1 4、创建物理卷:创建逻辑物理卷的命令为pvcreate,将指定的分区或磁盘创建为物理卷 [root@FisheyeSVN-test /]# pvcreate /dev/sdb1 返回结果:Physical volume "/dev/sdb1" successfully created 5、创建物理卷组: 创建卷组的命令为vgcreate,将使用pvcreate建立的物理卷创建为一个完整的卷组 [root@FisheyeSVN-test /]# vgcreate svn /dev/sdb1 返回结果:Volume group "vg0" successfully created
注:vgcreate 在创建卷组vg0以外,还设置使用大小为4MB的PE(默认为4MB),这表示卷组上创建的所有逻辑卷都以4MB为增量单位来进行扩充或缩减。由于内核原因,PE大小决定了逻辑卷的最大大小,4MB的PE决定了单个逻辑卷最大容量为256GB,若希望使用大于256G的逻辑卷则创建卷组 时指定更大的PE。PE大小范围为8KB到512MB,并且必须总是2的倍数(使用-s指定,具体请参考manvgcreate)。 6、激活卷组,不重启系统卷组立即生效的方法——vgchange: [root@FisheyeSVN-test /]# vgchange -ay svn 返回结果:1 logical volume(s) in volume group "svn" now active
7、此时可通过vgdisplay查看刚建立的逻辑卷组是否存在: [root@FisheyeSVN-test /]# vgdisplay --- Volume group --- VG Name svn System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 3 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 1 Act PV 1 VG Size 189.99 GB PE Size 4.00 MB Total PE 48638 Alloc PE / Size 46080 / 180.00 GB Free PE / Size 2558 / 9.99 GB VG UUID 0gSRNq-Mtae-KsNJ-zhcn-iEKh-sbh7-Vc7Wdf --- Volume group --- VG Name VolGroup00 System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 7 VG Access read/write VG Status resizable MAX LV 0 Cur LV 6 Open LV 6 Max PV 0 Cur PV 1 Act PV 1 VG Size 29.88 GB PE Size 32.00 MB Total PE 956 Alloc PE / Size 955 / 29.84 GB Free PE / Size 1 / 32.00 MB VG UUID x34k4R-8sAm-bOSc-iVAf-tpR0-Glej-3UZ2Sk
8、创建了逻辑卷组之后,还需要创建逻辑卷(svn-svndb;svn-fisheye),通过lvcreate方式创建 [root@FisheyeSVN-test/]# lvcreate -L 150G -nsvndb svndb 返回结果: Logical volume "svndb" created [root@FisheyeSVN-test/]# lvcreate -L 40G -nsvndb fisheye 返回结果: Logical volume "fisheye" created
9、此时可通过lvdisplay查看刚建立的逻辑卷是否存在: --- Logical volume --- LV Name /dev/svn/svndb VG Name svn LV UUID znzqb9-LEiz-zXvS-FmUJ-Zbif-cKlb-3lGGzs LV Write Access read/write LV Status available # open 1 LV Size 140.00 GB Current LE 35840 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:6 --- Logical volume --- LV Name /dev/svn/fisheye VG Name svn LV UUID MV0p39-zcoX-5GNW-2zRc-i5Ts-g6Yf-RFA60p LV Write Access read/write LV Status available # open 1 LV Size 40.00 GB Current LE 10240 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:7 --- Logical volume --- LV Name /dev/VolGroup00/LogVol00 VG Name VolGroup00 LV UUID WG7jRj-mi5l-Bzsm-TeFz-cNGX-bU5S-tWdLS2 LV Write Access read/write LV Status available # open 1 LV Size 5.00 GB Current LE 160 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0 --- Logical volume --- LV Name /dev/VolGroup00/LogVol05 VG Name VolGroup00 LV UUID dPi5As-0mfh-pm59-i3nQ-Y21e-xvzO-b14g8S LV Write Access read/write LV Status available # open 1 LV Size 3.84 GB Current LE 123 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:1 --- Logical volume --- LV Name /dev/VolGroup00/LogVol04 VG Name VolGroup00 LV UUID elf2NT-cpn9-kXPm-G7jU-4Y1L-fCve-z6vPX1 LV Write Access read/write LV Status available # open 1 LV Size 1.00 GB Current LE 32 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:2 --- Logical volume --- LV Name /dev/VolGroup00/LogVol03 VG Name VolGroup00 LV UUID Sry4c0-Z6fN-Dt37-8AfC-YWwT-v6Hh-W0OP7x LV Write Access read/write LV Status available # open 1 LV Size 3.00 GB Current LE 96 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:3 --- Logical volume --- LV Name /dev/VolGroup00/LogVol02 VG Name VolGroup00 LV UUID 0qyRH9-Q0ZQ-tJPx-7e9H-jfwP-h8mI-RAfD6U LV Write Access read/write LV Status available # open 1 LV Size 15.00 GB Current LE 480 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:4 --- Logical volume --- LV Name /dev/VolGroup00/LogVol01 VG Name VolGroup00 LV UUID 7krBTu-JKam-tx3X-1ZY9-6IEi-OqPr-q730ab LV Write Access read/write LV Status available # open 1 LV Size 2.00 GB Current LE 64 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:5 10、将刚创建的逻辑卷格式化并编辑格式为ext3 [root@FisheyeSVN-test/]# mkfs.ext3 /dev/svn/svndb [root@FisheyeSVN-test/]# mkfs.ext3 /dev/svn/fisheye
11、创建/svndb和/fisheye目录做挂载点 [root@FisheyeSVN-test/]# mkdir /svndb [root@FisheyeSVN-test/]# mkdir /fisheye
12、将文件系统挂载到所要挂载的挂载点 [root@FisheyeSVN-test/]# mount /dev/svn/svndb /svndb [root@FisheyeSVN-test/]# mount /dev/svn/fisheye /fisheye 13、最重要一点!将新创建的文件系统添加到/etc/fstab文件中,否则重启机器后不识别。/etc/fstab文件内写入的逻辑卷会在系统重启时自动挂载文件系统。 [root@FisheyeSVN-test/]# vi /etc/fstab
添加以下信息: /dev/svn/svndb /svndb ext3 defaults 0 0 /dev/svn/fisheye /fisheye ext3 defaults 0 0
14、使用df -h命令查看配置是否正确: