逻辑卷的创建
 
  1. 新建分区
[root@wangfc ~]# fdisk /dev/sdb
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1          14      112423+   5  Extended
/dev/sdb5               1           2       16002   83  Linux
 
Command (m for help): w
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
Syncing disks.
[root@wangfc ~]# partx -a /dev/sdb        切勿忘记
BLKPG: Device or resource busy
error adding partition 1
BLKPG: Device or resource busy
error adding partition 5
  1. 先转成物理卷
[root@wangfc ~]# pvcreate /dev/sdb5
 Physical volume "/dev/sdb5" successfully created
 可以指定多个磁盘
  1. 组成一个大的卷组,一个逻辑的大硬盘
[root@wangfc ~]# vgcreate   vg0  /dev/sdb5  -s  4
  Volume group "vg0" successfully created
                                                                        [ -s 是制定pe的大小]
                                                                    pe就是物理存储的最小单元
 
[root@wangfc ~]# lvcreate -L 10M -n lv0 vg0
  Rounding up size to full physical extent 12.00 MiB
  Logical volume "lv0" created
  1. 格式化lV0
[root@wangfc ~]# mkfs.ext4 /dev/vg0/lv0
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
3072 inodes, 12288 blocks
614 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=12582912
2 block groups
8192 blocks per group, 8192 fragments per group
1536 inodes per group
Superblock backups stored on blocks:
        8193
 
Writing inode tables: done                           
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done
 
This filesystem will be automatically checked every 22 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
 
[root@wangfc ~]# blkid   【查看所属的文件系统的UUIID
/dev/sda1: UUID="d5b0378a-608e-416d-b865-493f97f359fc" TYPE="ext4"
/dev/sda2: UUID="8b08564a-71b6-4d44-a102-dea5ec8ded61" TYPE="ext4"
/dev/sda3: UUID="dea6d68a-4ae0-4f6f-a8d4-1641d354da38" TYPE="swap"
/dev/sdb5: UUID="y5cQXn-Jllq-1XdQ-RSQm-dxIs-wILO-0JMWoP" TYPE="LVM2_member"
/dev/mapper/vg0-lv0: UUID="c4505955-3978-4854-96be-16291cc5bc2b" TYPE="ext4"
  1. 创建挂载点
[root@wangfc ~]# mkdir  /mnt/lvm0
 
[root@wangfc ~]# mount  /dev/mapper/vg0-lv0 /mnt/lvm0
 
[root@wangfc ~]# df -TH
Filesystem    Type     Size   Used  Avail Use% Mounted on
/dev/sda2     ext4      49G   4.4G    42G  10% /
tmpfs        tmpfs     1.1G    91k   1.1G   1% /dev/shm
/dev/sda1     ext4     305M    32M   258M  11% /boot
/dev/mapper/vg0-lv0
              ext4      13M   1.2M    11M  11% /mnt/lvm0
  1. 开机自动挂载
[root@wangfc ~]# vim /etc/fstab
 
UUID=c4505955-3978-4854-96be-16291cc5bc2b /mnt/lvm0 ext4 defaults        0 0
                             
[root@wangfc ~]# umount /mnt/lvm0/
[root@wangfc ~]# df -TH
Filesystem    Type     Size   Used  Avail Use% Mounted on
/dev/sda2     ext4      49G   4.4G    42G  10% /
tmpfs        tmpfs     1.1G    91k   1.1G   1% /dev/shm
/dev/sda1     ext4     305M    32M   258M  11% /boot
[root@wangfc ~]# mount
/dev/sda2 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
/etc/named on /var/named/chroot/etc/named type none (rw,bind)
/var/named on /var/named/chroot/var/named type none (rw,bind)
/etc/named.conf on /var/named/chroot/etc/named.conf type none (rw,bind)
/etc/named.rfc1912.zones on /var/named/chroot/etc/named.rfc1912.zones type none (rw,bind)
/etc/rndc.key on /var/named/chroot/etc/rndc.key type none (rw,bind)
/usr/lib64/bind on /var/named/chroot/usr/lib64/bind type none (rw,bind)
/etc/named.iscdlv.key on /var/named/chroot/etc/named.iscdlv.key type none (rw,bind)
[root@wangfc ~]# mount -a
mount: no medium found on /dev/sr0
[root@wangfc ~]# mount
/dev/sda2 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
/etc/named on /var/named/chroot/etc/named type none (rw,bind)
/var/named on /var/named/chroot/var/named type none (rw,bind)
/etc/named.conf on /var/named/chroot/etc/named.conf type none (rw,bind)
/etc/named.rfc1912.zones on /var/named/chroot/etc/named.rfc1912.zones type none (rw,bind)
/etc/rndc.key on /var/named/chroot/etc/rndc.key type none (rw,bind)
/usr/lib64/bind on /var/named/chroot/usr/lib64/bind type none (rw,bind)
/etc/named.iscdlv.key on /var/named/chroot/etc/named.iscdlv.key type none (rw,bind)
/dev/mapper/vg0-lv0 on /mnt/lvm0 type ext4 (rw)