LINUX LVM和快照卷配置和管理
具体参考这个文章把: http://www.cnblogs.com/zhaojiedi1992/p/zhaojiedi_linux_042_lvm.html
1.LVM是什么
逻辑卷管理LVM是一个多才多艺的硬盘系统工具。无论在Linux或者其他类似的系统,都是非常的好用。传统分区使用固定大小分区,重新调整大小十分麻烦。但是,LVM可以创建和管理“逻辑”卷,而不是直接使用物理硬盘。可以让管理员弹性的管理逻辑卷的扩大缩小,操作简单,而不损坏已存储的数据。可以随意将新的硬盘添加到LVM,以直接扩展已经存在的逻辑卷。LVM并不需要重启就可以让内核知道分区的存在。
2准备磁盘分区
2.1添加2块磁盘
2.2给/dev/sdb创建分区并调整类型为8e
[root@localhost ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable. The number of cylinders for this disk is set to .
There is nothing wrong with that, but this is larger than ,
and could in certain setups cause problems with:
) software that runs at boot time (e.g., old versions of LILO)
) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/ FDISK)
Warning: invalid flag 0x0000 of partition table will be corrected by w(rite) Command (m for help): n
Command action
e extended
p primary partition (-)
p
Partition number (-):
First cylinder (-, default ):
Using default value
Last cylinder or +size or +sizeM or +sizeK (-, default ): +1G Command (m for help): n
Command action
e extended
p primary partition (-)
p
Partition number (-):
First cylinder (-, default ):
Using default value
Last cylinder or +size or +sizeM or +sizeK (-, default ): +1G Command (m for help): n
Command action
e extended
p primary partition (-)
p
Partition number (-):
First cylinder (-, default ):
Using default value
Last cylinder or +size or +sizeM or +sizeK (-, default ): +1G Command (m for help): p Disk /dev/sdb: 21.4 GB, bytes
heads, sectors/track, cylinders
Units = cylinders of * = bytes Device Boot Start End Blocks Id System
/dev/sdb1 Linux
/dev/sdb2 + Linux
/dev/sdb3 + Linux Command (m for help): t
Partition number (-):
Hex code (type L to list codes): L Empty 1e Hidden W95 FAT1 Old Minix bf Solaris
FAT12 NEC DOS Minix / old Lin c1 DRDOS/sec (FAT-
XENIX root Plan Linux swap / So c4 DRDOS/sec (FAT-
XENIX usr 3c PartitionMagic Linux c6 DRDOS/sec (FAT-
FAT16 <32M Venix OS/ hidden C: c7 Syrinx
Extended PPC PReP Boot Linux extended da Non-FS data
FAT16 SFS NTFS volume set db CP/M / CTOS / .
HPFS/NTFS 4d QNX4.x NTFS volume set de Dell Utility
AIX 4e QNX4.x 2nd part Linux plaintext df BootIt
AIX bootable 4f QNX4.x 3rd part 8e Linux LVM e1 DOS access
a OS/ Boot Manag OnTrack DM Amoeba e3 DOS R/O
b W95 FAT32 OnTrack DM6 Aux Amoeba BBT e4 SpeedStor
c W95 FAT32 (LBA) CP/M 9f BSD/OS eb BeOS fs
e W95 FAT16 (LBA) OnTrack DM6 Aux a0 IBM Thinkpad hi ee EFI GPT
f W95 Ext'd (LBA) 54 OnTrackDM6 a5 FreeBSD ef EFI (FAT-12/16/
OPUS EZ-Drive a6 OpenBSD f0 Linux/PA-RISC b
Hidden FAT12 Golden Bow a7 NeXTSTEP f1 SpeedStor
Compaq diagnost 5c Priam Edisk a8 Darwin UFS f4 SpeedStor
Hidden FAT16 < SpeedStor a9 NetBSD f2 DOS secondary
Hidden FAT16 GNU HURD or Sys ab Darwin boot fb VMware VMFS
Hidden HPFS/NTF Novell Netware b7 BSDI fs fc VMware VMKCORE
AST SmartSleep Novell Netware b8 BSDI swap fd Linux raid auto
1b Hidden W95 FAT3 DiskSecure Mult bb Boot Wizard hid fe LANstep
1c Hidden W95 FAT3 PC/IX be Solaris boot ff BBT
Hex code (type L to list codes): 8e
Changed system type of partition to 8e (Linux LVM) Command (m for help): t
Partition number (-):
Hex code (type L to list codes): 8e
Changed system type of partition to 8e (Linux LVM) Command (m for help): t
Partition number (-):
Hex code (type L to list codes): 8e
Changed system type of partition to 8e (Linux LVM) Command (m for help): p Disk /dev/sdb: 21.4 GB, bytes
heads, sectors/track, cylinders
Units = cylinders of * = bytes Device Boot Start End Blocks Id System
/dev/sdb1 8e Linux LVM
/dev/sdb2 + 8e Linux LVM
/dev/sdb3 + 8e Linux LVM Command (m for help): w
The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error : Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
2.3同样给、dev/sdc创建分区并调整类型为8e
[root@localhost ~]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable. The number of cylinders for this disk is set to .
There is nothing wrong with that, but this is larger than ,
and could in certain setups cause problems with:
) software that runs at boot time (e.g., old versions of LILO)
) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/ FDISK)
Warning: invalid flag 0x0000 of partition table will be corrected by w(rite) Command (m for help): n
Command action
e extended
p primary partition (-)
p
Partition number (-):
First cylinder (-, default ):
Using default value
Last cylinder or +size or +sizeM or +sizeK (-, default ): +1g Command (m for help): n
Command action
e extended
p primary partition (-)
p
Partition number (-):
First cylinder (-, default ):
Using default value
Last cylinder or +size or +sizeM or +sizeK (-, default ): +1g Command (m for help): n
Command action
e extended
p primary partition (-)
p
Partition number (-):
First cylinder (-, default ):
Using default value
Last cylinder or +size or +sizeM or +sizeK (-, default ): +1g Command (m for help): p Disk /dev/sdc: 10.7 GB, bytes
heads, sectors/track, cylinders
Units = cylinders of * = bytes Device Boot Start End Blocks Id System
/dev/sdc1 Linux
/dev/sdc2 + Linux
/dev/sdc3 + Linux Command (m for help): t
Partition number (-):
Hex code (type L to list codes): 8e
Changed system type of partition to 8e (Linux LVM) Command (m for help): t
Partition number (-):
Hex code (type L to list codes): 8e
Changed system type of partition to 8e (Linux LVM) Command (m for help): t
Partition number (-):
Hex code (type L to list codes): 8e
Changed system type of partition to 8e (Linux LVM) Command (m for help): p Disk /dev/sdc: 10.7 GB, bytes
heads, sectors/track, cylinders
Units = cylinders of * = bytes Device Boot Start End Blocks Id System
/dev/sdc1 8e Linux LVM
/dev/sdc2 + 8e Linux LVM
/dev/sdc3 + 8e Linux LVM Command (m for help): w
The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error : Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
2.4查看上面2步骤的信息
[root@localhost ~]# fdisk -l Disk /dev/sda: 21.4 GB, bytes
heads, sectors/track, cylinders
Units = cylinders of * = bytes Device Boot Start End Blocks Id System
/dev/sda1 * Linux
/dev/sda2 + 8e Linux LVM Disk /dev/sdb: 21.4 GB, bytes
heads, sectors/track, cylinders
Units = cylinders of * = bytes Device Boot Start End Blocks Id System
/dev/sdb1 8e Linux LVM
/dev/sdb2 + 8e Linux LVM
/dev/sdb3 + 8e Linux LVM Disk /dev/sdc: 10.7 GB, bytes
heads, sectors/track, cylinders
Units = cylinders of * = bytes Device Boot Start End Blocks Id System
/dev/sdc1 8e Linux LVM
/dev/sdc2 + 8e Linux LVM
/dev/sdc3 + 8e Linux LVM
3.准备物理卷(PV)
3.1确保分区已经被系统识别
[root@localhost ~]# partprobe
[root@localhost ~]# cat /proc/partitions
major minor #blocks name sda
sda1
sda2
sdb
sdb1
sdb2
sdb3
sdc
sdc1
sdc2
sdc3
dm-
dm-
注:上面创建的6个分区都已经被系统读取到了。
3.2创建PV
[root@localhost ~]# pvcreate /dev/sdb{,,} /dev/sdc{,,}
Writing physical volume data to disk "/dev/sdb1"
Physical volume "/dev/sdb1" successfully created
Writing physical volume data to disk "/dev/sdb2"
Physical volume "/dev/sdb2" successfully created
Writing physical volume data to disk "/dev/sdb3"
Physical volume "/dev/sdb3" successfully created
Writing physical volume data to disk "/dev/sdc1"
Physical volume "/dev/sdc1" successfully created
Writing physical volume data to disk "/dev/sdc2"
Physical volume "/dev/sdc2" successfully created
Writing physical volume data to disk "/dev/sdc3"
Physical volume "/dev/sdc3" successfully created
3.3使用pvdisplay查看各个pv详细信息
[root@localhost ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name VolGroup00
PV Size 19.89 GB / not usable 19.49 MB
Allocatable yes (but full)
PE Size (KByte)
Total PE
Free PE
Allocated PE
PV UUID 0Z3ac4-OGzp-8Aop-Pz1t-KEtL-lgWk-iWjU5y "/dev/sdb1" is a new physical volume of "964.81 MB"
--- NEW Physical volume ---
PV Name /dev/sdb1
VG Name
PV Size 964.81 MB
Allocatable NO
PE Size (KByte)
Total PE
Free PE
Allocated PE
PV UUID gd7wHw-e4Hx-Sq3R-Y1ls-8emn-LT57-jrgGc8 "/dev/sdb2" is a new physical volume of "964.84 MB"
--- NEW Physical volume ---
PV Name /dev/sdb2
VG Name
PV Size 964.84 MB
Allocatable NO
PE Size (KByte)
Total PE
Free PE
Allocated PE
PV UUID J00YwU-AG77-lXDD-bZuf-jmni-5Mpj-0EOIGs "/dev/sdb3" is a new physical volume of "964.84 MB"
--- NEW Physical volume ---
PV Name /dev/sdb3
VG Name
PV Size 964.84 MB
Allocatable NO
PE Size (KByte)
Total PE
Free PE
Allocated PE
PV UUID BcPaAb-kyr1-uzMC-VV1D-M2Rr-mFh0-k7qD4L "/dev/sdc1" is a new physical volume of "964.81 MB"
--- NEW Physical volume ---
PV Name /dev/sdc1
VG Name
PV Size 964.81 MB
Allocatable NO
PE Size (KByte)
Total PE
Free PE
Allocated PE
PV UUID 7pxh1W-9bXB-VFyi-Ccwn-ol7z-tkbW-xyW1js "/dev/sdc2" is a new physical volume of "964.84 MB"
--- NEW Physical volume ---
PV Name /dev/sdc2
VG Name
PV Size 964.84 MB
Allocatable NO
PE Size (KByte)
Total PE
Free PE
Allocated PE
PV UUID mN7ZbA-XZtH-V0lq-TDSO-jcXW-W3yt-bIaTIy "/dev/sdc3" is a new physical volume of "964.84 MB"
--- NEW Physical volume ---
PV Name /dev/sdc3
VG Name
PV Size 964.84 MB
Allocatable NO
PE Size (KByte)
Total PE
Free PE
Allocated PE
PV UUID PuBFaL-En9g-vlFh-Zn2F-0NYZ-OgbH-78lHf9
3.4 删除pv
[root@localhost ~]# pvremove /dev/sdb1 #删除创建好的pv
Labels on physical volume "/dev/sdb1" successfully wiped
[root@localhost ~]# pvcreate /dev/sdb1 #为了后续的实验,这里创建创建一次
Writing physical volume data to disk "/dev/sdb1"
Physical volume "/dev/sdb1" successfully created
4 准备卷组(VG)
4.1创建vg
[root@localhost ~]# vgcreate vg-zhaojiedi /dev/sdb{,} /dev/sdc{,}
Volume group "vg-zhaojiedi" successfully created
4.2查看vg信息
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name vg-zhaojiedi
System ID
Format lvm2
Metadata Areas
Metadata Sequence No
VG Access read/write
VG Status resizable
MAX LV
Cur LV
Open LV
Max PV
Cur PV
Act PV
VG Size 3.77 GB
PE Size 4.00 MB
Total PE
Alloc PE / Size /
Free PE / Size / 3.77 GB
VG UUID tLoxsN-ZISg-Ebdf-7OIk-i5gz-73iN-RWjtoU --- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas
Metadata Sequence No
VG Access read/write
VG Status resizable
MAX LV
Cur LV
Open LV
Max PV
Cur PV
Act PV
VG Size 19.88 GB
PE Size 32.00 MB
Total PE
Alloc PE / Size / 19.88 GB
Free PE / Size /
VG UUID pL0fvM-64mT-Vu4Y-2hUA-hyvj-FHMK-NF2t5m
4.3删除vg
[root@localhost ~]# vgremove vg-zhaojiedi #删除vg
Volume group "vg-zhaojiedi" successfully removed
[root@localhost ~]# vgcreate vg-zhaojiedi /dev/sdb{,} /dev/sdc{,} #再次创建,用于后续测试
Volume group "vg-zhaojiedi" successfully created
5.创建逻辑卷(LV)
5.1创建逻辑卷
[root@localhost ~]# lvcreate -L 1G -n lv-zhaojiedi vg-zhaojiedi
Logical volume "lv-zhaojiedi" created
- -L:指定逻辑卷的大小
- -n:指定逻辑卷的名字
5.2 查看逻辑卷
[root@localhost ~]# lvdisplay
--- Logical volume ---
LV Name /dev/vg-zhaojiedi/lv-zhaojiedi
VG Name vg-zhaojiedi
LV UUID qyvrpi-TV4Q-1U3h-0UXJ-6c8N-bds5-kapP11
LV Write Access read/write
LV Status available
# open
LV Size 1.00 GB
Current LE
Segments
Allocation inherit
Read ahead sectors auto
- currently set to
Block device : --- Logical volume ---
LV Name /dev/VolGroup00/LogVol00
VG Name VolGroup00
LV UUID YQ5wpv-9bjK-WAOG-03lr-dsHD-hMBJ-Wcj22F
LV Write Access read/write
LV Status available
# open
LV Size 15.00 GB
Current LE
Segments
Allocation inherit
Read ahead sectors auto
- currently set to
Block device : --- Logical volume ---
LV Name /dev/VolGroup00/LogVol01
VG Name VolGroup00
LV UUID h2xJcZ-Aszi-u2aa-Mi5i-U8cP-R6V2-5KrI2H
LV Write Access read/write
LV Status available
# open
LV Size 4.88 GB
Current LE
Segments
Allocation inherit
Read ahead sectors auto
- currently set to
Block device :
5.3 挂载逻辑卷
[root@localhost ~]# mkfs.ext3 /dev/vg-zhaojiedi/lv-zhaojiedi #格式化文件系统
mke2fs 1.39 (-May-)
Filesystem label=
OS type: Linux
Block size= (log=)
Fragment size= (log=)
inodes, blocks
blocks (5.00%) reserved for the super user
First data block=
Maximum filesystem blocks=
block groups
blocks per group, fragments per group
inodes per group
Superblock backups stored on blocks:
, , , Writing inode tables: done
Creating journal ( blocks): done
Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every mounts or
days, whichever comes first. Use tune2fs -c or -i to override.
[root@localhost ~]# mkdir /mnt/lvm #创建挂载点目录
[root@localhost ~]# mount /dev/vg-zhaojiedi/lv-zhaojiedi /mnt/lvm #挂载
5.4删除逻辑卷
[root@localhost ~]# umount /dev/vg-zhaojiedi/lv-zhaojiedi #先卸载
[root@localhost ~]# lvremove /dev/vg-zhaojiedi/lv-zhaojiedi #在移除
Do you really want to remove active logical volume lv-zhaojiedi? [y/n]: y
Logical volume "lv-zhaojiedi" successfully removed
[root@localhost ~]# lvcreate -L 1G -n lv-zhaojiedi vg-zhaojiedi #这里为了接下来的测试,重新创建
Logical volume "lv-zhaojiedi" created
[root@localhost ~]# mount /dev/vg-zhaojiedi/lv-zhaojiedi /mnt/lvm #重新挂载
mount: you must specify the filesystem type
6扩展一个逻辑卷
6.1 卸载逻辑卷
[root@localhost ~]# umount /dev/vg-zhaojiedi/lv-zhaojiedi
6.2查看vg,lv空间情况
[root@localhost ~]# lvdisplay /dev/vg-zhaojiedi/lv-zhaojiedi
--- Logical volume ---
LV Name /dev/vg-zhaojiedi/lv-zhaojiedi
VG Name vg-zhaojiedi
LV UUID x1Oru1-0khT-xbmW-qk0R-lVEW-UIGf-bakDcl
LV Write Access read/write
LV Status available
# open
LV Size 1.00 GB
Current LE
Segments
Allocation inherit
Read ahead sectors auto
- currently set to
Block device : [root@localhost ~]# vgdisplay vg-zhaojiedi
--- Volume group ---
VG Name vg-zhaojiedi
System ID
Format lvm2
Metadata Areas
Metadata Sequence No
VG Access read/write
VG Status resizable
MAX LV
Cur LV
Open LV
Max PV
Cur PV
Act PV
VG Size 3.77 GB
PE Size 4.00 MB
Total PE
Alloc PE / Size / 1.00 GB
Free PE / Size / 2.77 GB
VG UUID pp8kaf-FQH6-kFfj-kxmb-OrfU-K5IE-34QjNR
注: 从上图中可以发现, 我们的vg是4G的, lv的空间是1G的, 还有3G可用的空间
6.3 我们扩容的大小还在vg的空间范围内的话
[root@localhost ~]# lvextend -L +1G /dev/vg-zhaojiedi/lv-zhaojiedi #扩展1G
Extending logical volume lv-zhaojiedi to 2.00 GB
Logical volume lv-zhaojiedi successfully resized
[root@localhost ~]# resize2fs /dev/vg-zhaojiedi/lv-zhaojiedi #重新定义文件大小
resize2fs 1.39 (-May-)
resize2fs: Bad magic number in super-block while trying to open /dev/vg-zhaojiedi/lv-zhaojiedi
Couldn't find valid filesystem superblock.
[root@localhost ~]# e2fsck -f /dev/vg-zhaojiedi/lv-zhaojiedi #检查磁盘错误
e2fsck 1.39 (-May-)
Couldn't find ext2 superblock, trying backup blocks...
Pass : Checking inodes, blocks, and sizes
Pass : Checking directory structure
Pass : Checking directory connectivity
Pass : Checking reference counts
Pass : Checking group summary information /dev/vg-zhaojiedi/lv-zhaojiedi: ***** FILE SYSTEM WAS MODIFIED *****
/dev/vg-zhaojiedi/lv-zhaojiedi: / files (9.1% non-contiguous), / blocks
[root@localhost ~]# resize2fs /dev/vg-zhaojiedi/lv-zhaojiedi #重新定义文件系统大小
resize2fs 1.39 (-May-)
Resizing the filesystem on /dev/vg-zhaojiedi/lv-zhaojiedi to (4k) blocks.
The filesystem on /dev/vg-zhaojiedi/lv-zhaojiedi is now blocks long.
6.4卷组的大小不够我们扩容的需求的话
上面我们已经扩容1G,逻辑卷就是2G的带下了。 vg的大小是4G,如果我们还要扩容3G的话, VG的大小是不够的。
[root@localhost ~]# vgextend vg-zhaojiedi /dev/sdb3 /dev/sdc3 #上面创建的那个pv没有使用呢。 这里添加到vg中,扩展vg
Volume group "vg-zhaojiedi" successfully extended
[root@localhost ~]# vgdisplay #查看vg
--- Volume group ---
VG Name vg-zhaojiedi
System ID
Format lvm2
Metadata Areas
Metadata Sequence No
VG Access read/write
VG Status resizable
MAX LV
Cur LV
Open LV
Max PV
Cur PV
Act PV
VG Size 5.65 GB
PE Size 4.00 MB
Total PE
Alloc PE / Size / 2.00 GB
Free PE / Size / 3.65 GB
VG UUID pp8kaf-FQH6-kFfj-kxmb-OrfU-K5IE-34QjNR --- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas
Metadata Sequence No
VG Access read/write
VG Status resizable
MAX LV
Cur LV
Open LV
Max PV
Cur PV
Act PV
VG Size 19.88 GB
PE Size 32.00 MB
Total PE
Alloc PE / Size / 19.88 GB
Free PE / Size /
VG UUID pL0fvM-64mT-Vu4Y-2hUA-hyvj-FHMK-NF2t5m [root@localhost ~]# lvextend -L +3G /dev/vg-zhaojiedi/lv-zhaojiedi #扩展lv
Extending logical volume lv-zhaojiedi to 5.00 GB
Logical volume lv-zhaojiedi successfully resized
[root@localhost ~]# resize2fs /dev/vg-zhaojiedi/lv-zhaojiedi #文件系统大小
resize2fs 1.39 (-May-)
Resizing the filesystem on /dev/vg-zhaojiedi/lv-zhaojiedi to (4k) blocks.
The filesystem on /dev/vg-zhaojiedi/lv-zhaojiedi is now blocks long.
7缩减逻辑卷
[root@localhost ~]# mount /dev/vg-zhaojiedi/lv-zhaojiedi /mnt/lvm #挂载
[root@localhost ~]# df -lh #查看使用情况
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
15G .2G .6G % /
/dev/sda1 99M 13M 82M % /boot
tmpfs 252M 252M % /dev/shm
/dev/mapper/vg--zhaojiedi-lv--zhaojiedi
.0G 35M .7G % /mnt/lvm
[root@localhost ~]# umount /mnt/lvm #卸载
[root@localhost ~]# resize2fs /dev/vg-zhaojiedi/lv-zhaojiedi 2G
resize2fs 1.39 (-May-)
Please run 'e2fsck -f /dev/vg-zhaojiedi/lv-zhaojiedi' first.
[root@localhost ~]# e2fsck -f /dev/vg-zhaojiedi/lv-zhaojiedi #检查
e2fsck 1.39 (-May-)
Pass : Checking inodes, blocks, and sizes
Pass : Checking directory structure
Pass : Checking directory connectivity
Pass : Checking reference counts
Pass : Checking group summary information
/dev/vg-zhaojiedi/lv-zhaojiedi: / files (9.1% non-contiguous), / blocks
[root@localhost ~]# resize2fs /dev/vg-zhaojiedi/lv-zhaojiedi 2G
resize2fs 1.39 (-May-)
Resizing the filesystem on /dev/vg-zhaojiedi/lv-zhaojiedi to (4k) blocks.
The filesystem on /dev/vg-zhaojiedi/lv-zhaojiedi is now blocks long.
[root@localhost ~]# lvreduce -L 2G /dev/vg-zhaojiedi/lv-zhaojiedi #减少到2G,注意减少逻辑卷的大小值若小于储存的数据大小,存储在后面的数据会丢失。
WARNING: Reducing active logical volume to 2.00 GB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv-zhaojiedi? [y/n]: y
Reducing logical volume lv-zhaojiedi to 2.00 GB
Logical volume lv-zhaojiedi successfully resized
8 创建快照卷
#下面我们在/mnt/lvm目录挂载逻辑卷,在/mnt/lvm-snap目录挂载快照卷,然后需要lvm目录的文件, 在查看lvm目录的文件和lvm-snap的文件。
[root@localhost cron]# mount /dev/vg-zhaojiedi/lv-zhaojiedi /mnt/lvm #挂载逻辑卷
[root@localhost cron]# cd /mnt/lvm #进入挂载目录
[root@localhost lvm]# cp /etc/fstab . #copy一些文件进入逻辑卷挂载目录
[root@localhost lvm]# cp /etc/sysctl.conf .
[root@localhost lvm]# ls
fstab lost+found sysctl.conf
[root@localhost lvm]# mkdir /mnt/lvm-snap #提前创建快照卷挂载目录
[root@localhost lvm]# lvcreate -L 100M -s -n "lvm-snap" /dev/vg-zhaojiedi/lv-zhaojiedi #创建快照卷
Logical volume "lvm-snap" created
[root@localhost lvm]# mount /dev/vg-zhaojiedi/lvm-snap /mnt/lvm-snap/ #挂载快照卷
[root@localhost lvm]# ls ../lvm-snap/ #查看快照卷, 此时已经有文件显示出来了
fstab lost+found sysctl.conf
[root@localhost lvm]# echo " hello " >> /mnt/lvm/fstab #修改lvm目录的文件内容
[root@localhost lvm]# cat /mnt/lvm/fstab #查看逻辑卷的内容
/dev/VolGroup00/LogVol00 / ext3 defaults
LABEL=/boot /boot ext3 defaults
tmpfs /dev/shm tmpfs defaults
devpts /dev/pts devpts gid=,mode=
sysfs /sys sysfs defaults
proc /proc proc defaults
/dev/VolGroup00/LogVol01 swap swap defaults
/dev/sdb1 /test/project ext3 rw
LABEL="MYDATA" /mnt/mydata ext3 rw
hello
[root@localhost lvm]# cat /mnt/lvm-snap/fstab #查看快照卷的内容
/dev/VolGroup00/LogVol00 / ext3 defaults
LABEL=/boot /boot ext3 defaults
tmpfs /dev/shm tmpfs defaults
devpts /dev/pts devpts gid=,mode=
sysfs /sys sysfs defaults
proc /proc proc defaults
/dev/VolGroup00/LogVol01 swap swap defaults
/dev/sdb1 /test/project ext3 rw
LABEL="MYDATA" /mnt/mydata ext3 rw
LINUX LVM和快照卷配置和管理的更多相关文章
- 分享:linux下apache服务器的配置和管理
linux下apache服务器的配置和管理. 一.两个重要目录: Apache有两个重要的目录:1.配置目录/etc/httpd/conf:2.文档目录/var/www: 二.两种配置模式: Apac ...
- Linux LVM(逻辑卷管理)
Lvm基本应用 什么是LVM? LVM 的全称是 Logical Volume Manager.中文为逻辑卷管理.它是Linux对磁盘分区的一种管理机制.它在传统的硬盘(或硬盘分区)和文件系统之间建立 ...
- Linux基础五:网络配置与管理
五.网络配置与管理 1.网络知识 2.命令 ifconfig命令 <=> ip addr show 命令--查看本地所有网卡配置信息 ens32:本地以太网网卡,lo:本地回环网卡 ...
- linux LVM:物理卷逻辑卷
逻辑卷管理器,当分区不够用的时候,可以新建一个更大的分区再复制进去,但是浪费时间.Lvm可以弹性调整分区大小,可以动态组合分区.分区大小固定了就无法调整, apt-get update & a ...
- (0.2)linux下Mysql的安装配置与管理入门(目录篇)
本章学习内容: 1.基于Linux平台的Mysql项目场景介绍 1.1.互联网各类网站.购物网站.门户网站.博客系统.IDC,云平台,VPS,虚拟主机空间,论坛,嵌入式. 2.mysql数据库运行环境 ...
- Linux 上SSH 服务的配置和管理
0.前期准备:清空防火墙,关闭SELinux. [root@localhost ~]# iptables -F #清空防火墙 [root@localhost ~]# /etc/init.d/iptab ...
- LINUX服务器搭建和常用配置介绍
服务器搭建 : 搭建私有CA服务器 : http://www.cnblogs.com/zhaojiedi1992/p/zhaojiedi_linux_011_ca.html搭建samba服务器 : h ...
- Linux LVM简明教程
逻辑卷管理LVM是一个多才多艺的硬盘系统工具.无论在Linux或者其他类似的系统,都是非常的好用.传统分区使用固定大小分区,重新调整大小十分麻烦.但是,LVM可以创建和管理“逻辑”卷,而不是直接使用物 ...
- [翻译]LVM中逻辑卷的最大大小限制
前言: 本文是对这篇博客Maximum Size Of A Logical Volume In LVM的翻译,敬请尊重原创和翻译劳动成果,那些随意转载的大爷们,好歹也自觉注明出处.谢谢! 英文原文地址 ...
随机推荐
- Day08 (黑客成长日记) 命名空间和作用域
Day08:命名空间和作用域: 1.命名空间: (1)内置命名空间(python解释器): 就是python解释器一旦启动就可以使用的名字储存在内置命名空间中: eg: len() print() a ...
- rest_framework登录组件,权限组件
昨日回顾: -HyperlinkedIdentityField(用来生成url),传三个参数 -实例化序列化类的时候,BookSerializer(ret, many=True, context={' ...
- python data science handbook1
import numpy as np import matplotlib.pyplot as plt import seaborn; seaborn.set() rand = np.random.Ra ...
- 基于fpga的vga学习(2)
本次学习主要向配合basys2实行. 上次学习vga的rgb三个output都是1位的,但是我看了basys2的rgb分别是332位,这里让我卡顿了很久, 之后通过查资料才知道,rgb的不同大小表示的 ...
- ubuntu16 mysql在线安装
输入"sudo apt-get update"-->回车-->"输入root用户的密码"-->回车: 输入"sudo apt-get ...
- 2018/9/6 spring框架的整理
spring知识的巩固整理AOP和ioc概念,以及了解到了为何要使用spring框架的目的,作用:变换资源获取的方向.更像是按需所求.配置bean的方式:利用XML的方式,基于注解的方式两种.1通过全 ...
- chat.css
*, *:before, *:after { box-sizing: border-box;}body, html { height: 100%; overflow: hidden;}body, ul ...
- 微软SSAS 错误 Internal error: Invalid enumeration value. Please call customer support! 不是此元素的有效值。
错误 118 Internal error: Invalid enumeration value. Please call customer support! 不是此元素的有效值. 错误 119 分析 ...
- 全国计算机等级考试二级Python语言程序设计考试大纲
全国计算机等级考试二级Python语言程序设计考试大纲(2018年版) 基本要求 掌握Python语言的基本语法规则. 掌握不少于2个基本的Python标准库. 掌握不少于2个Python第三方库,掌 ...
- Spark 介绍
MapReduce给用户提供了简单的编程接口,用户只需要按照接口编写串行版本的代码,Hadoop框架会自动把程序运行到很多机器组成的集群上,并能处理某些机器在运行过程中出现故障的情况.然而,在MapR ...