四 逻辑卷相关操作
#创建逻辑卷
[root@serv01 ~]# lvcreate -L 500M -n mylv01myvg
Logical volume "mylv01" created
[root@serv01 ~]# lvdisplay
--- Logical volume ---
LVName /dev/myvg/mylv01
VGName myvg
LVUUID zjfjIV-S3Kv-dkHZ-xKOC-wPV7-nG3H-QuaKGU
LVWrite Access read/write
LVStatus available
#open 0
LVSize 500.00 MiB
Current LE 125
Segments 1
Allocation inherit
Read ahead sectors auto
-currently set to 256
Block device 253:0
五 LVM使用
#格式化
[root@serv01 ~]# mkfs.ext4 /dev/myvg/mylv01
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
128016 inodes, 512000 blocks
25600 blocks (5.00%) reserved for the superuser
First data block=1
Maximum filesystem blocks=67633152
63 block groups
8192 blocks per group, 8192 fragments pergroup
2032 inodes per group
Superblock backups stored on blocks:
8193,24577, 40961, 57345, 73729, 204801, 221185, 401409
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystemaccounting information: done
This filesystem will be automaticallychecked every 37 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
#挂载
[root@serv01 ~]# mount /dev/myvg/mylv01/web/
[root@serv01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 9.7G 1.1G 8.1G 12% /
tmpfs 188M 0 188M 0% /dev/shm
/dev/sda1 194M 25M 160M 14% /boot
/dev/sda5 4.0G 137M 3.7G 4% /opt
/dev/sr0 3.4G 3.4G 0 100% /iso
/dev/mapper/myvg-mylv01
485M 11M 449M 3% /web
[root@serv01 ~]# cd /boot
[root@serv01 boot]# cd /web/
[root@serv01 web]# ls
lost+found
#拷贝文件
[root@serv01 web]# cp /boot/* ./ -rf
[root@serv01 web]# ls
config-2.6.32-131.0.15.el6.x86_64 initramfs-2.6.32-131.0.15.el6.x86_64.img System.map-2.6.32-131.0.15.el6.x86_64
efi lost+found vmlinuz-2.6.32-131.0.15.el6.x86_64
grub symvers-2.6.32-131.0.15.el6.x86_64.gz
#追加文件到/etc/fstab
[root@serv01 web]# echo"/dev/myvg/mylv01 /web ext4 defaults 1 2" >> /etc/fstab
[root@serv01 web]# tail -n 1 /etc/fstab
/dev/myvg/mylv01 /web ext4 defaults 1 2
[root@serv01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 9.7G 1.1G 8.1G 12% /
tmpfs 188M 0 188M 0% /dev/shm
/dev/sda1 194M 25M 160M 14% /boot
/dev/sda5 4.0G 137M 3.7G 4% /opt
/dev/mapper/myvg-mylv01
485M 29M 431M 7% /web
/dev/sr0 3.4G 3.4G 0 100% /iso
#重启,到/web目录下查看文件
[root@serv01 web]# reboot
[root@larrywen disk]# ssh 192.168.1.11
root@192.168.1.11's password:
Last login: Thu Aug 1 21:48:24 2013 from 192.168.1.1
[root@larrywen disk]# cd /web
config-2.6.32-131.0.15.el6.x86_64 lost+found System.map-2.6.32-131.0.15.el6.x86_64
initramfs-2.6.32-131.0.15.el6.x86_64.img symvers-2.6.32-131.0.15.el6.x86_64.gz vmlinuz-2.6.32-131.0.15.el6.x86_64
[root@serv01 web]# lvextend —help
六 增加逻辑卷
[root@serv01 web]# lvextend -L +500M/dev/myvg/mylv01
Extending logical volume mylv01 to 1000.00 MiB
Logical volume mylv01 successfully resized
#lvdisplay
[root@serv01 web]# lvdisplay
---Logical volume ---
LVName /dev/myvg/mylv01
VGName myvg
LVUUID zjfjIV-S3Kv-dkHZ-xKOC-wPV7-nG3H-QuaKGU
LVWrite Access read/write
LVStatus available
#open 1
LVSize 1000.00 MiB
Current LE 250
Segments 1
Allocation inherit
Read ahead sectors auto
-currently set to 256
Block device 253:0
#查看磁盘发现大小没变
[root@serv01 web]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 9.7G 1.1G 8.1G 12% /
tmpfs 188M 0 188M 0% /dev/shm
/dev/sda1 194M 25M 160M 14% /boot
/dev/sda5 4.0G 137M 3.7G 4% /opt
/dev/mapper/myvg-mylv01
485M 29M 431M 7% /web
/dev/sr0 3.4G 3.4G 0 100% /iso
[root@serv01 web]# cd /
#卸载
[root@serv01 /]# umount /web
#执行resize2fs命令更新
[root@serv01 /]# resize2fs /dev/myvg/mylv01
resize2fs 1.41.12 (17-May-2010)
Please run 'e2fsck -f /dev/myvg/mylv01'first.
#发现有提示,先执行e2fsck -f/dev/myvg/mylv01
[root@serv01 /]# e2fsck -f /dev/myvg/mylv01
e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/myvg/mylv01: 16/128016 files (0.0%non-contiguous), 45237/512000 blocks
#再次执行上述命令,再次mount,再次查看磁盘空间,发现磁盘变大
[root@serv01 /]# resize2fs /dev/myvg/mylv01
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/myvg/mylv01to 1024000 (1k) blocks.
The filesystem on /dev/myvg/mylv01 is now1024000 blocks long.
[root@serv01 /]# mount /dev/myvg/mylv01/web
[root@serv01 /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 9.7G 1.1G 8.1G 12% /
tmpfs 188M 0 188M 0% /dev/shm
/dev/sda1 194M 25M 160M 14% /boot
/dev/sda5 4.0G 137M 3.7G 4% /opt
/dev/sr0 3.4G 3.4G 0 100% /iso
/dev/mapper/myvg-mylv01
969M 29M 891M 4% /web
