xen虚拟的一个系统,作备份用。新加硬盘操作过程,有什么不当的地方请指教,
操作系统root var使用ext3文件系统,其余的用xfs,可以方便的使用lvm在线括容量
流程是fdisk分区-->pvcreate-->vgcreate-->lvcreate-->mkfs-->mount
[root@vpn2 ~]# more /etc/redhat-release
CentOS release 5.3 (Final)
[root@vpn2 ~]# mount
/dev/xvda3 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/xvda2 on /var type ext3 (rw)
/dev/xvda1 on /boot type ext2 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/mapper/centos-home on /home type xfs (rw)
[root@vpn2 ~]# pvdisplay
--- Physical volume ---
PV Name /dev/xvda5
VG Name centos
PV Size 12.22 GB / not usable 31.53 MB
Allocatable yes
PE Size (KByte) 32768
Total PE 390
Free PE 106
Allocated PE 284
PV UUID PVuNfm-R7SA-RGgS-1Z7n-D6L9-CeSe-U8zIJA
#分区类型使用lvm必须是8e
[root@vpn2 ~]# fdisk -l
Disk /dev/xvda: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/xvda1 * 1 12 96358+ 83 Linux
/dev/xvda2 13 649 5116702+ 83 Linux
/dev/xvda3 650 1668 8185117+ 83 Linux
/dev/xvda4 1669 3263 12811837+ 5 Extended
/dev/xvda5 1669 3263 12811806 8e Linux LVM
Disk /dev/xvdb: 193.2 GB, 193273528320 bytes
255 heads, 63 sectors/track, 23497 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/xvdb1 1 23497 188739621 8e Linux LVM
[root@vpn2 ~]# pvcreate -t /dev/xvdb1
Test mode: Metadata will NOT be updated.
Physical volume "/dev/xvdb1" successfully created
[root@vpn2 ~]# pvcreate /dev/xvdb1
Physical volume "/dev/xvdb1" successfully created
[root@vpn2 ~]# vgcreate -t -s32M backup /dev/xvdb1
Test mode: Metadata will NOT be updated.
Volume group "backup" successfully created
[root@vpn2 ~]# vgcreate -s32M backup /dev/xvdb1
Volume group "backup" successfully created
#-s可加可不加,取决于你的磁盘有多大。默认的4m应该可以满足大部分需求了
[root@vpn2 ~]# vgdisplay
--- Volume group ---
VG Name backup
System ID
Format lvm2
Metadata Areas 1
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 1
Act PV 1
VG Size 179.97 GB
PE Size 32.00 MB
Total PE 5759
Alloc PE / Size 0 / 0
Free PE / Size 5759 / 179.97 GB
VG UUID sk8GM4-3OID-J77p-XyAM-hhNc-Ptrr-zCiaz1
--- Volume group ---
VG Name centos
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 12.19 GB
PE Size 32.00 MB
Total PE 390
Alloc PE / Size 284 / 8.88 GB
Free PE / Size 106 / 3.31 GB
VG UUID vZ8Rss-3KPu-5xZW-rNcO-aX2R-styn-pgad4q
[root@vpn2 ~]# lvdisplay
--- Logical volume ---
LV Name /dev/centos/home
VG Name centos
LV UUID ZPOx3D-a2In-t1Jd-AoUG-DSw3-vsqY-K2Uhe5
LV Write Access read/write
LV Status available
# open 1
LV Size 4.88 GB
Current LE 156
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Name /dev/centos/swap
VG Name centos
LV UUID jmX8TM-Rv1X-lLsB-arR3-1z2K-bxHp-mHZSPh
LV Write Access read/write
LV Status available
# open 1
LV Size 4.00 GB
Current LE 128
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
[root@vpn2 ~]# pvdisplay
--- Physical volume ---
PV Name /dev/xvdb1
VG Name backup
PV Size 180.00 GB / not usable 28.04 MB
Allocatable yes
PE Size (KByte) 32768
Total PE 5759
Free PE 5759
Allocated PE 0
PV UUID mI1kqZ-ijT2-dZzR-ohqR-zqsn-kku8-2Jjca9
--- Physical volume ---
PV Name /dev/xvda5
VG Name centos
PV Size 12.22 GB / not usable 31.53 MB
Allocatable yes
PE Size (KByte) 32768
Total PE 390
Free PE 106
Allocated PE 284
PV UUID PVuNfm-R7SA-RGgS-1Z7n-D6L9-CeSe-U8zIJA
[root@vpn2 ~]# lvcreate -L20G -nsysbak backup
Logical volume "sysbak" created
[root@vpn2 ~]# lvdisplay
--- Logical volume ---
LV Name /dev/backup/sysbak
VG Name backup
LV UUID oY0Da0-YEAE-B24N-PAeF-CnC3-9VSi-k1v8cG
LV Write Access read/write
LV Status available
# open 0
LV Size 20.00 GB
Current LE 640
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
--- Logical volume ---
LV Name /dev/centos/home
VG Name centos
LV UUID ZPOx3D-a2In-t1Jd-AoUG-DSw3-vsqY-K2Uhe5
LV Write Access read/write
LV Status available
# open 1
LV Size 4.88 GB
Current LE 156
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Name /dev/centos/swap
VG Name centos
LV UUID jmX8TM-Rv1X-lLsB-arR3-1z2K-bxHp-mHZSPh
LV Write Access read/write
LV Status available
# open 1
LV Size 4.00 GB
Current LE 128
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
[root@vpn2 ~]# mkfs.xfs /dev/backup/sysbak
meta-data=/dev/backup/sysbak isize=256 agcount=16, agsize=327680 blks
= sectsz=512 attr=0
data = bsize=4096 blocks=5242880, imaxpct=25
= sunit=0 swidth=0 blks, unwritten=1
naming =version 2 bsize=4096
log =internal log bsize=4096 blocks=2560, version=1
= sectsz=512 sunit=0 blks, lazy-count=0
realtime =none extsz=4096 blocks=0, rtextents=0
#mkfs.xfs时可以根据自己的机器平均负载、cpu性能等作些优化,备份用不追求速度。所以用默认的参数
[root@vpn2 /]# mkdir /bak
[root@vpn2 /]# mount /dev/backup/sysbak /bak
[root@vpn2 /]# mount
/dev/xvda3 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/xvda2 on /var type ext3 (rw)
/dev/xvda1 on /boot type ext2 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/mapper/centos-home on /home type xfs (rw)
/dev/mapper/backup-sysbak on /bak type xfs (rw)
vi /etc/fstab
/dev/backup/sysbak /bak xfs defaults 1 2