LVM创建、管理、快照

创建分区

[[email protected] ~]# echo -e "n\n\n\n\n+10G\nt\n8e\nw\n" | fdisk /dev/sdd &> /dev/null
[[email protected] ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
fd0      2:0    1    4K  0 disk
sda      8:0    0   50G  0 disk
├─sda1   8:1    0  200M  0 part /boot
├─sda2   8:2    0  4.9G  0 part [SWAP]
└─sda3   8:3    0   30G  0 part /
sdb      8:16   0   20G  0 disk
└─sdb1   8:17   0   10G  0 part
sdc      8:32   0   30G  0 disk
└─sdc1   8:33   0   10G  0 part
sdd      8:48   0   40G  0 disk
└─sdd1   8:49   0   10G  0 part
sr0     11:0    1    4G  0 rom  

创建物理卷

[[email protected] ~]# pvcreate /dev/sd{b,c,d}1
  Physical volume "/dev/sdb1" successfully created.
  Physical volume "/dev/sdc1" successfully created.
  Physical volume "/dev/sdd1" successfully created.
[[email protected] ~]# pvs
  PV         VG Fmt  Attr PSize  PFree
  /dev/sdb1     lvm2 ---  10.00g 10.00g
  /dev/sdc1     lvm2 ---  10.00g 10.00g
  /dev/sdd1     lvm2 ---  10.00g 10.00g

创建逻辑卷

[[email protected] ~]# vgcreate vg01 -s 16M  /dev/sd{b,c,d}1
  Volume group "vg01" successfully created
[[email protected] ~]# vgdisplay
  --- Volume group ---
  VG Name               vg01
  System ID
  Format                lvm2
  Metadata Areas        3
  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                3
  Act PV                3
  VG Size               29.95 GiB
  PE Size               16.00 MiB
  Total PE              1917
  Alloc PE / Size       0 / 0
  Free  PE / Size       1917 / 29.95 GiB
  VG UUID               d4S78Z-00S8-cnoN-2VPb-usOw-mXIn-WdEELS
[[email protected] ~]# lvcreate -n lvm01 vg01 -l 100
  Logical volume "lvm01" created.
[[email protected] ~]# lvcreate -L 5G -n lvm02 vg01
  Logical volume "lvm02" created.
[[email protected] ~]# lvs
  LV    VG   Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lvm01 vg01 -wi-a----- 1.56g
  lvm02 vg01 -wi-a----- 5.00g

创建文件系统

[[email protected] ~]# mkfs.ext4 /dev/vg/lvm01
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
327680 inodes, 1310720 blocks
65536 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1342177280
40 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
    32768, 98304, 163840, 229376, 294912, 819200, 884736

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done 

[[email protected] ~]# mkfs.xfs /dev/vg/lvm02
meta-data=/dev/vg/lvm02          isize=256    agcount=4, agsize=102400 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0
data     =                       bsize=4096   blocks=409600, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

挂载文件

[[email protected] ~]# mount /dev/vg/lvm01 /opt/lvm01
[[email protected] ~]# mount /dev/vg/lvm02 /opt/lvm02
[[email protected] ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3              30G  1.2G   29G   4% /
devtmpfs              1.9G     0  1.9G   0% /dev
tmpfs                 1.9G     0  1.9G   0% /dev/shm
tmpfs                 1.9G  8.5M  1.9G   1% /run
tmpfs                 1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/sda1             197M  103M   94M  53% /boot
tmpfs                 379M     0  379M   0% /run/user/0
/dev/mapper/vg-lvm01  4.8G   20M  4.6G   1% /opt/lvm01
/dev/mapper/vg-lvm02  1.6G   33M  1.6G   3% /opt/lvm02

自动挂载

[[email protected] ~]# blkid | grep lvm01
/dev/mapper/vg-lvm01: UUID="e3af4ba6-a917-4905-ae03-7e2356de6107" TYPE="ext4"
[[email protected] ~]# sed -i "11a UUID=e3af4ba6-a917-4905-ae03-7e2356de6107 /opt/lvm01              ext4     defaults        0 0" /etc/fstab
[[email protected] ~]# mount -a
[[email protected] ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3              30G  1.2G   29G   4% /
devtmpfs              1.9G     0  1.9G   0% /dev
tmpfs                 1.9G     0  1.9G   0% /dev/shm
tmpfs                 1.9G  8.5M  1.9G   1% /run
tmpfs                 1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/sda1             197M  103M   94M  53% /boot
tmpfs                 379M     0  379M   0% /run/user/0
/dev/mapper/vg-lvm01  2.9G  2.9G     0 100% /opt/lvm01
/dev/mapper/vg-lvm02  3.0G  3.0G   20K 100% /opt/lvm02

在线扩容

[[email protected] ~]# lvs
  LV    VG Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lvm01 vg -wi-ao---- 5.00g
  lvm02 vg -wi-ao---- 1.56g
[[email protected] ~]# lvextend -L +1G /dev/vg/lvm01
  Size of logical volume vg/lvm01 changed from 5.00 GiB (320 extents) to 6.00 GiB (384 extents).
  Logical volume vg/lvm01 successfully resized.
[[email protected] ~]# lvs
  LV    VG Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lvm01 vg -wi-ao---- 6.00g
  lvm02 vg -wi-ao---- 1.56g
[[email protected] ~]# df -h                       容量没有增加到
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3              30G  1.2G   29G   4% /
devtmpfs              1.9G     0  1.9G   0% /dev
tmpfs                 1.9G     0  1.9G   0% /dev/shm
tmpfs                 1.9G  8.5M  1.9G   1% /run
tmpfs                 1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/sda1             197M  103M   94M  53% /boot
tmpfs                 379M     0  379M   0% /run/user/0
/dev/mapper/vg-lvm01  4.8G   20M  4.6G   1% /opt/lvm01
/dev/mapper/vg-lvm02  1.6G   33M  1.6G   3% /opt/lvm02
[[email protected] ~]# resize2fs /dev/vg/lvm01                 #调整ext文件系统的大小
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/vg/lvm01 is mounted on /opt/lvm01; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/vg/lvm01 is now 1572864 blocks long.
[[email protected] ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3              30G  1.2G   29G   4% /
devtmpfs              1.9G     0  1.9G   0% /dev
tmpfs                 1.9G     0  1.9G   0% /dev/shm
tmpfs                 1.9G  8.5M  1.9G   1% /run
tmpfs                 1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/sda1             197M  103M   94M  53% /boot
tmpfs                 379M     0  379M   0% /run/user/0
/dev/mapper/vg-lvm01  5.8G   20M  5.5G   1% /opt/lvm01
/dev/mapper/vg-lvm02  1.6G   33M  1.6G   3% /opt/lvm02
[[email protected] ~]# lvextend -L +1G /dev/vg/lvm02
  Size of logical volume vg/lvm02 changed from 1.56 GiB (100 extents) to 2.56 GiB (164 extents).
  Logical volume vg/lvm02 successfully resized.
[[email protected] ~]# xfs_growfs /dev/vg/lvm02        调整xfs文件系统的大小
meta-data=/dev/mapper/vg-lvm02   isize=256    agcount=4, agsize=102400 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0
data     =                       bsize=4096   blocks=409600, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal               bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 409600 to 671744
[[email protected] ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3              30G  1.2G   29G   4% /
devtmpfs              1.9G     0  1.9G   0% /dev
tmpfs                 1.9G     0  1.9G   0% /dev/shm
tmpfs                 1.9G  8.5M  1.9G   1% /run
tmpfs                 1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/sda1             197M  103M   94M  53% /boot
tmpfs                 379M     0  379M   0% /run/user/0
/dev/mapper/vg-lvm01  5.8G   20M  5.5G   1% /opt/lvm01
/dev/mapper/vg-lvm02  2.6G   33M  2.6G   2% /opt/lvm02

或者
lvextend -L +1G -r /dev/vg/lvm01    #加了-r自动调整文件系统大小

压缩逻辑卷(危险) xfs不能压缩

[[email protected] ~]# umount /opt/lvm01
[[email protected] ~]# e2fsck -f /dev/vg/lvm01
e2fsck 1.42.9 (28-Dec-2013)
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/vg/lvm01: 11/393216 files (0.0% non-contiguous), 63598/1572864 blocks
[[email protected] ~]# resize2fs /dev/vg/lvm01 3G
resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on /dev/vg/lvm01 to 786432 (4k) blocks.
The filesystem on /dev/vg/lvm01 is now 786432 blocks long.

[[email protected] ~]# mount /dev/vg/lvm01 /opt/lvm01
[[email protected] ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3              30G  1.2G   29G   4% /
devtmpfs              1.9G     0  1.9G   0% /dev
tmpfs                 1.9G     0  1.9G   0% /dev/shm
tmpfs                 1.9G  8.5M  1.9G   1% /run
tmpfs                 1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/sda1             197M  103M   94M  53% /boot
tmpfs                 379M     0  379M   0% /run/user/0
/dev/mapper/vg-lvm02  3.0G   33M  3.0G   2% /opt/lvm02
/dev/mapper/vg-lvm01  2.9G   18M  2.7G   1% /opt/lvm01

速度比较

[[email protected] ~]# dd if=/dev/zero of=/root/f1 bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 2.76954 s, 388 MB/s
[[email protected] ~]# dd if=/dev/zero of=/opt/lvm02/f1 bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 0.611213 s, 1.8 GB/s

卷组扩展

[[email protected] lvm02]# vgextend vg /dev/sdc1
  Volume group "vg" successfully extended
[[email protected] lvm02]# vgextend vg /dev/sdd1
  Volume group "vg" successfully extended
[[email protected] lvm02]# vgdisplay
  --- Volume group ---
  VG Name               vg
  System ID
  Format                lvm2
  Metadata Areas        3
  Metadata Sequence No  24
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               2
  Max PV                0
  Cur PV                3
  Act PV                3
  VG Size               29.95 GiB
  PE Size               16.00 MiB
  Total PE              1917
  Alloc PE / Size       608 / 9.50 GiB
  Free  PE / Size       1309 / 20.45 GiB
  VG UUID               CSCN9I-Y7q9-KoN9-xiWK-htU6-XOd4-M2JjEe

卷组压缩

情况一:没有数据
    [[email protected] ~]# pvdisplay
      --- Physical volume ---
      PV Name               /dev/sdb1
      VG Name               vg
      PV Size               10.00 GiB / not usable 16.00 MiB
      Allocatable           yes
      PE Size               16.00 MiB
      Total PE              639
      Free PE               63
      Allocated PE          576
      PV UUID               5IwieR-HXxC-6txr-hUOo-zSUE-vela-Rg5ZSJ

      --- Physical volume ---
      PV Name               /dev/sdc1
      VG Name               vg
      PV Size               10.00 GiB / not usable 16.00 MiB
      Allocatable           yes
      PE Size               16.00 MiB
      Total PE              639
      Free PE               639
      Allocated PE          0
      PV UUID               7nleyP-4EUB-7FME-2sDo-75Fr-YPfV-3wp9vM

      --- Physical volume ---
      PV Name               /dev/sdd1
      VG Name               vg
      PV Size               10.00 GiB / not usable 16.00 MiB
      Allocatable           yes
      PE Size               16.00 MiB
      Total PE              639
      Free PE               639
      Allocated PE          0
      PV UUID               EcEfTe-Eaxq-X8GU-qiXe-3YuS-gxwI-ln6Clb
    [[email protected] ~]# vgreduce vg /dev/sdd1
      Removed "/dev/sdd1" from volume group "vg"
    [[email protected] ~]# pvdisplay /dev/sdd1
      "/dev/sdd1" is a new physical volume of "10.00 GiB"
      --- NEW Physical volume ---
      PV Name               /dev/sdd1
      VG Name
      PV Size               10.00 GiB
      Allocatable           NO
      PE Size               0
      Total PE              0
      Free PE               0
      Allocated PE          0
      PV UUID               EcEfTe-Eaxq-X8GU-qiXe-3YuS-gxwI-ln6Clb

    [[email protected] ~]# pvremove /dev/sdd1
      Labels on physical volume "/dev/sdd1" successfully wiped.
    [[email protected] ~]# pvdisplay
      --- Physical volume ---
      PV Name               /dev/sdb1
      VG Name               vg
      PV Size               10.00 GiB / not usable 16.00 MiB
      Allocatable           yes
      PE Size               16.00 MiB
      Total PE              639
      Free PE               63
      Allocated PE          576
      PV UUID               5IwieR-HXxC-6txr-hUOo-zSUE-vela-Rg5ZSJ

      --- Physical volume ---
      PV Name               /dev/sdc1
      VG Name               vg
      PV Size               10.00 GiB / not usable 16.00 MiB
      Allocatable           yes
      PE Size               16.00 MiB
      Total PE              639
      Free PE               639
      Allocated PE          0
      PV UUID               7nleyP-4EUB-7FME-2sDo-75Fr-YPfV-3wp9vM

    [[email protected] ~]# vgdisplay
      --- Volume group ---
      VG Name               vg
      System ID
      Format                lvm2
      Metadata Areas        2
      Metadata Sequence No  8
      VG Access             read/write
      VG Status             resizable
      MAX LV                0
      Cur LV                2
      Open LV               2
      Max PV                0
      Cur PV                2
      Act PV                2
      VG Size               <19.97 GiB
      PE Size               16.00 MiB
      Total PE              1278
      Alloc PE / Size       576 / 9.00 GiB
      Free  PE / Size       702 / <10.97 GiB
      VG UUID               CSCN9I-Y7q9-KoN9-xiWK-htU6-XOd4-M2JjEe
情况二:有数据,但是硬盘快坏了
    [[email protected] lvm02]# pvdisplay
      --- Physical volume ---
      PV Name               /dev/sdb1
      VG Name               vg
      PV Size               10.00 GiB / not usable 16.00 MiB
      Allocatable           yes
      PE Size               16.00 MiB
      Total PE              639
      Free PE               607
      Allocated PE          32
      PV UUID               5IwieR-HXxC-6txr-hUOo-zSUE-vela-Rg5ZSJ

      --- Physical volume ---
      PV Name               /dev/sdc1
      VG Name               vg
      PV Size               10.00 GiB / not usable 16.00 MiB
      Allocatable           yes
      PE Size               16.00 MiB
      Total PE              639
      Free PE               63
      Allocated PE          576
      PV UUID               7nleyP-4EUB-7FME-2sDo-75Fr-YPfV-3wp9vM

    [[email protected] lvm02]# pvmove /dev/sdc1
      /dev/sdc1: Moved: 0.00%
      /dev/sdc1: Moved: 66.67%
      /dev/sdc1: Moved: 100.00%
    [[email protected] lvm02]# pvdisplay
      --- Physical volume ---
      PV Name               /dev/sdb1
      VG Name               vg
      PV Size               10.00 GiB / not usable 16.00 MiB
      Allocatable           yes
      PE Size               16.00 MiB
      Total PE              639
      Free PE               31
      Allocated PE          608
      PV UUID               5IwieR-HXxC-6txr-hUOo-zSUE-vela-Rg5ZSJ

      --- Physical volume ---
      PV Name               /dev/sdc1
      VG Name               vg
      PV Size               10.00 GiB / not usable 16.00 MiB
      Allocatable           yes
      PE Size               16.00 MiB
      Total PE              639
      Free PE               639
      Allocated PE          0
      PV UUID               7nleyP-4EUB-7FME-2sDo-75Fr-YPfV-3wp9vM

    [[email protected] lvm02]# vgreduce vg /dev/sdc1
      Removed "/dev/sdc1" from volume group "vg"
    [[email protected] lvm02]# pvremove /dev/sdc1
      Labels on physical volume "/dev/sdc1" successfully wiped.
    [[email protected] lvm02]# vgdisplay
      --- Volume group ---
      VG Name               vg
      System ID
      Format                lvm2
      Metadata Areas        1
      Metadata Sequence No  22
      VG Access             read/write
      VG Status             resizable
      MAX LV                0
      Cur LV                3
      Open LV               2
      Max PV                0
      Cur PV                1
      Act PV                1
      VG Size               9.98 GiB
      PE Size               16.00 MiB
      Total PE              639
      Alloc PE / Size       608 / 9.50 GiB
      Free  PE / Size       31 / 496.00 MiB
      VG UUID               CSCN9I-Y7q9-KoN9-xiWK-htU6-XOd4-M2JjEe

lvm创建快照

[[email protected] lvm02]# ll /opt/lvm02
total 3102540
-rw-r--r-- 1 root root 1073741824 Aug 21 00:18 f1
-rw-r--r-- 1 root root 1073741824 Aug 21 00:19 f2
-rw-r--r-- 1 root root 1029517312 Aug 21 00:19 f3
-rw-r--r-- 1 root root          0 Aug 21 00:19 f4
[[email protected] lvm02]# lvcreate -n lvm_snap02 -L 1.5G -s /
[[email protected] lvm02]# lvcreate -n lvm_snap02 -L 1.5G -s /dev/vg/lvm02
  Logical volume "lvm_snap02" created.
[[email protected] lvm02]# lvs
  LV         VG Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lvm01      vg -wi-ao----   6.00g
  lvm02      vg owi-aos---   3.00g
  lvm03      vg -wi-a----- 512.00m
  lvm_snap02 vg swi-a-s---   1.50g      lvm02  0.00
[[email protected] lvm02]# \rm f1
[[email protected] lvm02]# > f2
[[email protected] lvm02]# ll
total 1005388
-rw-r--r-- 1 root root          0 Aug 21 00:48 f2
-rw-r--r-- 1 root root 1029517312 Aug 21 00:19 f3
-rw-r--r-- 1 root root          0 Aug 21 00:19 f4
[[email protected] ~]# lvconvert --merge /dev/vg/lvm_snap02
  Merging of volume vg/lvm_snap02 started.
  vg/lvm02: Merged: 99.87%
  vg/lvm02: Merged: 100.00%
[[email protected] ~]# lvs
  LV    VG Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lvm01 vg -wi-ao----   6.00g
  lvm02 vg -wi-ao----   3.00g
  lvm03 vg -wi-a----- 512.00m
[[email protected] ~]# mount /dev/vg/lvm02 /opt/lvm02
[[email protected] ~]# ll /opt/lvm02
total 3102540
-rw-r--r-- 1 root root 1073741824 Aug 21 00:18 f1
-rw-r--r-- 1 root root 1073741824 Aug 21 00:19 f2
-rw-r--r-- 1 root root 1029517312 Aug 21 00:19 f3
-rw-r--r-- 1 root root          0 Aug 21 00:19 f4

原文地址:https://blog.51cto.com/14192118/2431155

时间: 2024-10-11 00:22:50

LVM创建、管理、快照的相关文章

lvm创建管理加实验

安装一块硬盘. fdisk /dev/sdbyum provides pvcreateyum install lvm2pvcreate /dev/sdb1vgcreate vg01 /dev/sdb1最后俩行加入/dev/vg01/lv1 /mnt1 ext4 defaults 0 0和/dev/vg01/lv2 /mnt2 xfs defaults 0 0保存退出yum install quota -yumount /mnt2mount -o usrquota,grpquota /dev/vg

LVM 创建,管理(初级)

linux下创建和管理LVM(初级) 一.LVM简介,命令介绍,PV, VG, PE, LV简介. 1.) LVM简介:逻辑卷管理器,通过底层磁盘设备创建逻辑卷,可以在线对分区进行扩展,缩减,可跨分区扩展.解决服务器使用时间过长,磁盘空间不足.也可逻辑卷进行快照,备份. 2.) PV, VG, PE, LV简介: PV Physical Volume,物理卷: 底层磁盘,通过磁盘分区命令对其进行分区,并且需要转换成8e(LVM)格式. VG Volume Group, 卷组 将几个磁盘分区进行组

GNU/Linux下LVM配置管理以及快照卷、物理卷、卷组、逻辑卷的创建和删除

LVM是Linux环境中对磁盘分区进行管理的一种机制,是建立在硬盘和分区之上.文件系统之下的一个逻辑层,可提高磁盘分区管理的灵活性.最大的优点是在不损伤数据的前提下调整存储空间的大小. 本篇主要讲述LVM的创建.LVM的扩展与缩减和快照卷的使用三部分 第一部分:LVM的创建 LVM创建的大致步骤为 1.将多个分区转化为多个物理卷PV(Physical Vomule)    一个分区可以创建一个物理卷,可以在多块磁盘上创建物理卷.也可以做raid10磁盘阵列以后在做物理卷, 以    便有更快的读

LVM创建,缩减及快照备份

管理逻辑卷工具:LVM 逻辑卷:灵活可动态存储的一种逻辑上的存储 最底层需要通过工具变成"物理卷":存储设备,Raid ,分区等 VG:(1)底层设备容量之和.(2)PE大小*数量 卷组上面一个块叫PE.默认每个块为4M,可更改. 一.首先创建分区 # fdisk /dev/sdb 二. 查看系统内是否已经安装LVM [[email protected] share]# rpm -qa |grep lvm lvm2-libs-2.02.98-9.el6.x86_64 lvm2-2.02

Linux磁盘管理之LVM逻辑卷快照

一.快照的工作原理 所谓快照就是将当时的系统数据记录下来,在未来若有数据变动,则会将变更前的数据放入快照区进行保存.我们可理解为快照就是给系统拍了一张照片,记录当时系统在拍快照的状态.只不过现实生活中的照片是没有办法将现在的生活还原到照片的时候,而Linux系统里LVM快照是可以的.从上面的阐述可以了解到,被做快照的逻辑卷是分成了两个部分,一部分是数据没有改动前的和数据变更后的.它是怎么工作的呢?在我们给系统做快照的前提是,系统上基于LVM管理的,且快照和逻辑卷必须是在同一卷组上:在我们给LVM

LVM逻辑卷创建管理

一.简介 LVM是逻辑盘卷管理(Logical Volume Manager)的简称,它是Linux环境下对磁盘分区进行管理的一种机制,LVM是建立在硬盘和分区之上的一个逻辑层,来提高磁盘分区管理的灵活性. LVM的工作原理其实很简单,它就是通过将底层的物理硬盘抽象的封装起来,然后以逻辑卷的方式呈现给上层应用.在传统的磁盘管理机制中,我们的上层应用是直接访问文件系统,从而对底层的物理硬盘进行读取,而在LVM中,其通过对底层的硬盘进行封装,当我们对底层的物理硬盘进行操作时,其不再是针对于分区进行操

Linux下的LVM创建以及Linux快照卷

通过最的学习,我加深了对LVM的理解,在这里,我将它写成博客,一是方便自己记忆,二是让Linux的入门学习者一起学习一下. 首先我们引入LVM的概念,并展开详细的说明,主要是近期学习的看法,我们先看一个图 我们将会提到的名词有:PV.VG.LV.PE 在图中,最下面的,我们可以理解为物理存储介质,硬盘或是分区 PV:称为物理卷,是LVM的基本存储块. VG:称为卷组,我们可以看卷组是由物理卷组合而成的. LV:称为逻辑卷,是从卷组中划分出来的. PE:physical extent,我就称为物理

LVM高级管理

#LVM回滚技术 [[email protected] /]# umount /home #卸载/home分区 [[email protected] /]# lvreduce -L 200M /dev/vg01/lvhome #不扫描文件系统,直接减掉文件系统 [[email protected] /]# mount /dev/vg01/lvhome #这个时候挂载就会报错,文件系统就损坏了 [[email protected] /]# cd /etc/lvm #进入lvm主配置文件 [[ema

Openstack liberty 创建实例快照源码分析2

这是创建云主机实例快照源码分析系列的最后一篇,在第一篇文章中分析了从镜像启动云主机,创建在线/离线快照的过程:本篇将分析从启动盘启动的云主机创建快照的过程,下面请看正文: 磁盘启动云主机,离线(在线)快照 nova-api处理过程 函数入口和前述一样,还是 nova/api/openstack/compute/servers.py/ServersController._action_create_image,下面一起来看看: def _action_create_image(self, req,