码迷,mamicode.com
首页 > 其他好文 > 详细

2 unit 5

时间:2016-11-10 21:43:54      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:linux

###unit.5 LVM###


###1.LVM建立

1.划分物理分区并把分区id修改为8e

[root@desktop18 ~]# fdisk /dev/vdb

Welcome to fdisk (util-linux 2.23.2).


Changes will remain in memory only, until you decide to write them.

Be careful before using the write command.


Device does not contain a recognized partition table

Building a new DOS disklabel with disk identifier 0x9546a42c.


Command (m for help): n

Partition type:

   p   primary (0 primary, 0 extended, 4 free)

   e   extended

Select (default p): 

Using default response p

Partition number (1-4, default 1): 1

First sector (2048-20971519, default 2048): 

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +500M

Partition 1 of type Linux and of size 500 MiB is set


Command (m for help): n

Partition type:

   p   primary (1 primary, 0 extended, 3 free)

   e   extended

Select (default p): 

Using default response p

Partition number (2-4, default 2): 2

First sector (1026048-20971519, default 1026048): 

Using default value 1026048

Last sector, +sectors or +size{K,M,G} (1026048-20971519, default 20971519): +500M

Partition 2 of type Linux and of size 500 MiB is set


Command (m for help): t

Partition number (1,2, default 2): 1

Hex code (type L to list all codes): 8e

Changed type of partition ‘Linux‘ to ‘Linux LVM‘


Command (m for help): t

Partition number (1,2, default 2): 2

Hex code (type L to list all codes): 8e

Changed type of partition ‘Linux‘ to ‘Linux LVM‘


Command (m for help): p


Disk /dev/vdb: 10.7 GB, 10737418240 bytes, 20971520 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: 0x9546a42c


   Device Boot      Start         End      Blocks   Id  System

/dev/vdb1            2048     1026047      512000   8e  Linux LVM

/dev/vdb2         1026048     2050047      512000   8e  Linux LVM


Command (m for help): wq

The partition table has been altered!


Calling ioctl() to re-read partition table.

Syncing disks.



pvs|pvdisplay

vgs|vgdisplay

lvs|lvdisplay


监控命令

watch -n 1 \

‘echo"===pvinfo==="\

;pvs\

;echo"===vginfo==="\

;vgs\

;echo"===lvinfo==="\

;lvs\

;df -h /mnt‘


===pvinfo===

  PV         VG   Fmt  Attr PSize   PFree

  /dev/vdb1  tbr  lvm2 a--  496.00m      0

  /dev/vdb2  tbr  lvm2 a--  496.00m 392.00m

===vginfo===

  VG   #PV #LV #SN Attr   VSize   VFree

  tbr    2   1   0 wz--n- 992.00m 392.00m

===lvinfo===

  LV   VG   Attr       LSize   Pool Origin Data%  Move Log Cpy%Sync Convert

  lv0  tbr  -wi-ao---- 600.00m


pvcreate /dev/vdb1

vgcreate westos /dev/vdb1

lvcreate -L 100M -n lv0 westos

mkfs.xfs /dev/westos/lv0

mount /dev/westos/lv0 /mnt


lvextend -L 200M /dev/westos/lv0

xfs_growfs /dev/westos/lv0


pvcreate /dev/vdb2

vgextend westos /dev/vdb2

lvextend -L 600M /dev/westos/lv0

xfs_growfs /dev/westos/lv0

fdisk /dev/sdb


umount /mnt/

mkfs.ext4 /dev/westos/lv0 

e2fsck -f /dev/westos/lv0

resize2fs /dev/westos/lv0 200M

mount /dev/westos/lv0 /mnt

lvreduce -L 200M /dev/westos/lv0

pvmove /dev/vdb1 /dev/vdb2

vgreduce westos /dev/vdb1



vgreduce --removemissing ##清除不知道的东西


lvcreate -L 10M -n lv0-backup -s /dev/westos/lv0 ##快照


umount /mnt

lvremove /dev/westos/lv0-backup 

lvremove /dev/westos/lv0

vgremove westos

pvremove /dev/vdb2

fdisk /dev/vdb


fdisk /dev/vdb

#!/bin/bash

fdisk /dev/vdb << end

n




+1G

wq

end

格式为file.sh 命令为sh file.sh


本文出自 “12115084” 博客,请务必保留此出处http://12125084.blog.51cto.com/12115084/1871583

2 unit 5

标签:linux

原文地址:http://12125084.blog.51cto.com/12115084/1871583

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!