标签:open 基本 mkdir logs 根据 常见 vgcreate write maximum
虚拟机里再添加两块硬盘,如下所示:
启动系统后,我们可以看到新添加的两块硬盘为/dev/sdb和/dev/sdc.每个2GB。
[root@lxjtest ~]# fdisk -l Disk /dev/sdb: 2147 MB, 2147483648 bytes, 4194304 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/sdc: 2147 MB, 2147483648 bytes, 4194304 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/sda: 5368 MB, 5368709120 bytes, 10485760 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x0006ae1e Device Boot Start End Blocks Id System /dev/sda1 * 2048 616447 307200 83 Linux /dev/sda2 616448 10485759 4934656 8e Linux LVM ----这个分区是安装系统过程中创建的逻辑卷 Disk /dev/mapper/rhel-root: 3976 MB, 3976200192 bytes, 7766016 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/mapper/rhel-swap: 1073 MB, 1073741824 bytes, 2097152 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes
下面我们将对这两块新的硬盘先进行创建物理卷操作,可以简单理解成让硬盘设备支持了LVM技术,然后对两块硬盘进行卷组合并,卷组的名称可以由您来自定义,接下来是把合并后的卷组根据需求再切割出一个约为150M的逻辑卷设备,最后把这个逻辑卷设备格式化成ext4文件系统后挂载使用。
第一步:让新添加的两块硬盘设备支持LVM逻辑卷管理器技术,并查看创建的物理卷信息
[root@lxjtest ~]# pvcreate /dev/sdb /dev/sdc Physical volume "/dev/sdb" successfully created Physical volume "/dev/sdc" successfully created
[root@lxjtest ~]# pvdisplay --- Physical volume --- PV Name /dev/sda2 VG Name rhel PV Size 4.71 GiB / not usable 3.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 1204 Free PE 0 Allocated PE 1204 PV UUID V3kA1X-l7dr-03p4-HZcu-Ebj3-FRvb-r5vGMd --- Physical volume --- 以下两个是刚创建的物理卷设备 PV Name /dev/sdb VG Name testVG PV Size 2.00 GiB / not usable 4.00 MiB Allocatable yes PE Size 4.00 MiB --默认情况下,PE大小都为4MB。 Total PE 511 ---PE基本单元的个数 Free PE 511 Allocated PE 0 PV UUID InfACr-fq1t-yi95-K1K3-dOHU-uezl-gfiPVa --- Physical volume --- PV Name /dev/sdc VG Name testVG PV Size 2.00 GiB / not usable 4.00 MiB Allocatable yes PE Size 4.00 MiB Total PE 511 Free PE 511 Allocated PE 0 PV UUID aOtJga-uWop-ldnv-xIcj-TcLE-aq18-SrJO3p
第二步:把两块硬盘加入到testVG卷组中,然后查看卷组信息
[root@lxjtest ~]# vgcreate testVG /dev/sdb /dev/sdc Volume group "testVG" successfully created [root@lxjtest ~]# vgdisplay --- Volume group --- 这个rhel的卷组是在安装系统的过程中自动创建的 VG Name rhel 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 4.70 GiB PE Size 4.00 MiB Total PE 1204 Alloc PE / Size 1204 / 4.70 GiB Free PE / Size 0 / 0 VG UUID LrU5p2-fp7C-B7cZ-LFxL-g35x-uxrY-W8w93C --- Volume group --- 刚创建的卷组testVG VG Name testVG System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 1 VG Access read/write VG Status resizable MAX LV 0 Cur LV 0 Open LV 0 Max PV 0 Cur PV 2 Act PV 2 VG Size 3.99 GiB PE Size 4.00 MiB Total PE 1022 --总的PE等于上一步中的物理卷/dev/sdb 和/dev/sdc的Total PE之和 Alloc PE / Size 0 / 0 Free PE / Size 1022 / 3.99 GiB VG UUID b3mykq-kcsp-Hdh4-rAos-vutt-ontI-6AWJ5K
第三步:从卷组testVG中分出一个200MB的逻辑卷设备
在LVM逻辑卷管理器对LV逻辑卷的切割上面有两种计量单位,第一种是常见以-L参数来以容量单位为对象,例如使用-L 200M来生成一个大小为200M的逻辑卷,还可以使用-l参数来指定要使用PE基本单元的个数,默认每个PE的大小为4M,因此允许使用-l 50来生成一个大小为50*4M=200M的逻辑卷:
[root@lxjtest ~]# lvcreate -n fuck_lv1 -L 200M testVG Logical volume "fuck_lv1" created. [root@lxjtest ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root rhel -wi-ao---- 3.70g swap rhel -wi-ao---- 1.00g fuck_lv1 testVG -wi-a----- 200.00m [root@lxjtest ~]# lvs testVG LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert fuck_lv1 testVG -wi-a----- 200.00m
[root@lxjtest ~]# lvdisplay testVG --- Logical volume --- 从下面的信息可以看出,卷组testVG目前只分了一个逻辑卷fuck_lv1 LV Path /dev/testVG/fuck_lv1 --系统会把逻辑卷设备放到/dev/目录下 LV Name fuck_lv1 VG Name testVG LV UUID RKzHdO-NX2i-Za40-kWNg-RIox-yi9j-z9251R LV Write Access read/write LV Creation host, time lxjtest.rusky.com, 2017-08-07 23:35:10 -0400 LV Status available # open 0 LV Size 200.00 MiB Current LE 50 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:2
第四步:把创建好的逻辑卷fuck_lv1格式化后挂载使用:
Linux系统会把LVM逻辑卷管理器中的逻辑卷设备存放在/dev设备目录中(实际上是做了一个符号链接,但读者们无需关心),同时会以卷组的名称来建立一个目录,其中保存有逻辑卷的设备映射文件(即/dev/卷组名称/逻辑卷名称)。
[root@lxjtest ~]# mkfs.ext4 /dev/testVG/fuck_lv1 mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) Stride=0 blocks, Stripe width=0 blocks 51200 inodes, 204800 blocks 10240 blocks (5.00%) reserved for the super user First data block=1 Maximum filesystem blocks=33816576 25 block groups 8192 blocks per group, 8192 fragments per group 2048 inodes per group Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729 Allocating group tables: done Writing inode tables: done Creating journal (4096 blocks): done Writing superblocks and filesystem accounting information: done [root@lxjtest ~]#
[root@lxjtest ~]# mkdir /testLVM [root@lxjtest ~]# mount /dev/testVG/fuck_lv1 /testLVM/ [root@lxjtest ~]# df -h
第5步:查看挂载状态,并写入到配置文件永久生效:
[root@lxjtest ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/rhel-root 3.7G 896M 2.9G 24% / devtmpfs 910M 0 910M 0% /dev tmpfs 920M 0 920M 0% /dev/shm tmpfs 920M 8.4M 912M 1% /run tmpfs 920M 0 920M 0% /sys/fs/cgroup /dev/sda1 297M 114M 184M 39% /boot tmpfs 184M 0 184M 0% /run/user/0 /dev/mapper/testVG-fuck_lv1 190M 1.6M 175M 1% /testLVM
修改/etc/fstab文件,增加如下一行:
/dev/testVG/fuck_lv1 /testLVM ext4 defaults 0 0
标签:open 基本 mkdir logs 根据 常见 vgcreate write maximum
原文地址:http://www.cnblogs.com/rusking/p/7306146.html