2 unit 5

###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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值