Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Detailed LVM2     - Quota for Vsftpd do use disk quotas (Server)

- JavaScript, some conclusions about the implicit conversion (Programming)

- Comparison of C # and Java (Programming)

- Construction LVM-based raw device Oracle10g Database on Oracle Linux 5.11 (Database)

- SecureCRT connect virtual machine Linux system (Ubuntu) (Linux)

- Five kinds of IO Model under Linux (Programming)

- To repair Shell script by default open in Ubuntu (Linux)

- Node.js simple interface server (Server)

- The first deployment of cross-platform operation Rafy record (Server)

- Linux platform to prevent hackers to share practical skills (Linux)

- To install and configure the Jetty server and JDK under Ubuntu 14.04.2 (Server)

- Access.log Apache access log analysis and how to import it into MySQL (Server)

- How to upgrade the kernel to 3.13.7 on Ubuntu / Linux Mint (Linux)

- Linux nice program origin of the name (Linux)

- CentOS installation Docker series (Linux)

- Linux command line ten magic usage (Linux)

- Adjust the size of the hard disk VirtualBox (Linux)

- Oracle Enterprise Linux 64-bit install apache-tomcat-7.0.53 step (Server)

- Proxmox VE implement KVM OpenVZ virtualization cloud computing (Server)

- Java development specifications summary (Programming)

 
         
  Detailed LVM2
     
  Add Date : 2017-01-08      
         
         
         
  Outline:

Brief introduction
version
LVM basic terminology
LVM module
Specific operation
To add a hard disk partition (fdisk / dev / [hs] d [a-z])
Partition created create a physical volume (pvcreate)
Logical to create a logical container (Volume Group)
Create different sizes of logical volumes (lvcreate) in the volume group
To the existing volume group to expand capacity
For online capacity expansion of LVM
LVM achieve reduced capacity (does not support online reduction)
Reducing the volume group capacity
Use LVM to create a snapshot, and complete backup and restore
Summary:

LVM is a Logical Volume Manager (Logical Volume Manager) shorthand, also translated logical file manager, a logical sector manager, Logical Disk Manager. Linux kernel is provided by the Logical Volume Manager (Logical Volume Management) function. It is on the hard disk partition, and create a logical layer management system to facilitate the system hard disk partition.

Was first developed by IBM, implemented on the AIX system, OS / 2 and HP-UX operating system also supports this feature;

In 1998, Heinz Mauelshagen according to the Logical Volume Manager on HP-UX, and writing the first version of the Linux Logical Volume Manager; and publish it to the Linux community, which allows users on a Linux system using simple commands management a complete logical volume management environment.

LVM advantages:

It is to create a layer of abstraction above the physical storage device, allows you to create logical storage volumes, as compared to using physical storage directly on the management, provide better flexibility;

LVM storage virtualization, logical volume, users are not limited by the size of the physical disk; In addition, hardware-related settings are stored hide, the user can not stop the application or unmount the file system to adjust the volume or size of data migration, operating costs can be reduced.

LVM as compared to using physical storage directly, has the following advantages:

1, flexible capacity

When using logical volumes, file systems can extend across multiple disks, you can aggregate multiple disks or partitions into a single logical volume.

2, scalable storage pool;

You can use a simple command to expand or shrink the size of the logical volume, or partition without reformatting the disk device.

3, online data redistribution

You can move data online, the data can be re-assigned in the case of the disk online. For example, you can replace the hot-swappable disk online.

4, convenient device naming;

Do you think the logical volume can be a convenient way to play any names.

5, disk striping

You can create a logical drive, and its data can be stored on the compartmentalization of two or more disks. This can significantly improve data throughput.

6, mirrored volumes

Logical volumes provide a convenient way to mirror your data.

7, volume snapshot

Using logical volumes, you can get a snapshot of the device used to effect consistent backup update or test data without affecting the real data.

2. Version:

LVM1 initial LVM and released in 1998, is only available on the Linux kernel version 2.4, which provides the basic logical volume manager.

LVM2 LVM-1 updated version of the Linux kernel 2.6 is available, it is in the standard LVM-1 function also provides additional functionality.

View Version:

[Root @ localhost ~] #uname -a
Linux localhost.localdomain2.6.32-504.el6.x86_64 # 1 SMP Wed Oct 15 04:27:16 UTC 2014 x86_64 x86_64 x86_64GNU / Linux
[Root @ localhost ~] #uname -r
2.6.32-504.el6.x86_64
[Root @ localhost ~] #rpm -qa | grep lvm
mesa-private-llvm-3.4-3.el6.x86_64
lvm2-libs-2.02.111-2.el6.x86_64
lvm2-2.02.111-2.el6.x86_64

3.LVM basic terms:

Physical storage media (The Physical Media):

This refers to the storage device system, such as: / dev / hda1, / dev / sda, etc., is the lowest level of the storage system storage unit.

Physical volume (PV, Physical Volume):

Physical volume refers to the disk, disk partition or device (such as RAID) from the logical disk partition has the same function, the basic memory logic block LVM, but and basic physical storage medium (such as a partition, disk, etc.) compare, but It contains management parameters associated with LVM. This allows you to save the current LVM physical volume on each physical volume of 0-2 parts by metadata copy. The default is 1 saved at the beginning of the device. 2, the second part to save the backup at the end of the device.

Volume Group (VG, Volume Group):

LVM volume group non-LVM system similar to the physical hard disk, which consists of physical volumes. You can create one or more "LVM partitions" (logical volume group on

Volume), LVM volume group by one or more physical volumes.

Logical Volume (LV, Logical Volume):

LVM logical volume is similar to non-LVM system hard disk partition, logical volume on the file system can be established (such as / home or / usr, etc.).

Linear logical volume (Linear Volumes):

A linear logical polymerization multiple physical volumes into a logical volume. For example, if you have two 60GB hard disk, you can create a 120GB logical volume.

Striping logical volumes (Striped Logical Volumes)

When you write data to this logical volume, the file system can drop the data onto multiple physical volumes. For the large number of connections read and write operations, the data can improve I / O efficiency.

Mirrored Logical Volumes (MirroredLogical Volumes)

Image stored on different devices consistent data. At the same time the data is written to the original equipment and mirror device. It provides fault-tolerant devices.

Snapshot volume (SnapshotVolumes)

In particular instant snapshot volume provides a virtual image device, when the snapshot was started, it changes to a copy of the current data range, since it takes precedence over the implementation of these changes, it is possible to reconstruct the current state of the device.

PE (physical extent)

Each physical volume is divided into basic units called PE (Physical Extents) of, PE has a unique number that can be the smallest addressable unit LVM. PE size is configurable, default is 4MB.

LE (logical extent)

Is divided into logical volumes is known as the basic unit LE (Logical Extents) it can be addressed. In the same volume group, LE and PE are the same size, and correspond.

Metadata and non-LVM system partition contains the information stored in the same starting position is located in the partition table partition, logical volume group and associated metadata is stored in the physical volume is located at the start of VGDA (volume group descriptor area). VGDA include the following: PV descriptor, VG descriptor, LV descriptors and several PE descriptors. VG activation system startup LVM, and VGDA loaded into memory to identify LV actual physical storage location. When the system I / O operations, will be based mapping mechanism VGDA established to access the actual physical location.

4.LVM module:

Physicalvolume (PV), Volume group (VG), Logicalvolume (LV), Physical extent (PE), we use the following simple

The diagram to illustrate the relationship between them in the physical volumes, volume groups, logical volumes

Create a logical volume, multiple hard drives is to create a physical volume, but will these physical volumes to form a container assembly logic, and then create different sized partitions files from inside the container, and this container is called volume group (VG ), and create different sized partitions files from this container, this file is called logical partitions.

5. Specific actions:

. A partition:

[Root @ localhost ~] #fdisk -l

Disk / dev / sda: 128.8 GB, 128849018880 bytes

255 heads, 63 sectors / track, 15665cylinders

Units = cylinders of 16065 * 512 = 8225280bytes

Sector size (logical / physical): 512 bytes / 512 bytes

I / O size (minimum / optimal): 512 bytes / 512bytes

Disk identifier: 0x00060f25

  Device Boot Start End Blocks Id System

/ Dev / sda1 * 1 26 204800 83 Linux

Partition 1 does not end on cylinderboundary.

/ Dev / sda2 26 7859 62914560 8e Linux LVM

/ Dev / sda3 7859 8512 5252256 83 Linux

/ Dev / sda4 8513 9166 5253255 5 Extended

/ Dev / sda5 8513 8644 1060258+ 82 Linux swap / Solaris

[Root @ localhost ~] # fdisk -l / dev / sdb # newly added hard disk sdb

Disk / dev / sdb: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors / track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280bytes

Sector size (logical / physical): 512 bytes / 512 bytes

I / O size (minimum / optimal): 512 bytes / 512bytes

Disk identifier: 0x00000000

 

[Root @ localhost ~] # fdisk / dev / sdb # partition of sdb

Command (m for help): n # Creates a new partition;

Command action

  e extended

  p primary partition (1-4)

p

Partition number (1-4): 3 # partition number;

First cylinder (1309-2610, default 1309): # start cylinder, direct default

Using default value 1309

Last cylinder, + cylinders or + size {K, M, G} (1309-2610, default 2610): + 5G # specify the partition size

Command (m for help): p # See all partitions

Disk / dev / sdb: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors / track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280bytes

Sector size (logical / physical): 512 bytes / 512 bytes

I / O size (minimum / optimal): 512 bytes / 512bytes

Disk identifier: 0x71f66aa7

Device Boot Start End Blocks Id System

/ Dev / sdb1 1 654 5253223+ 83 Linux #id field indicates the partition type;

/ Dev / sdb2 655 1308 5253255 83 Linux # need to change the partition type using the sub-command t

/ Dev / sdb3 1309 1962 5253255 83 Linux

Command (m for help): p

Disk / dev / sdb: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors / track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280bytes

Sector size (logical / physical): 512 bytes / 512 bytes

I / O size (minimum / optimal): 512 bytes / 512bytes

Disk identifier: 0x71f66aa7

# In this case the partition id has been modified to 8e, partition type is Linux LVM;

  Device Boot Start End Blocks Id System

/ Dev / sdb1 1 654 5253223+ 8e Linux LVM

/ Dev / sdb2 655 1308 5253255 8e Linux LVM

/ Dev / sdb3 1309 1962 5253255 8e Linux LVM

Command (m for help): w # Save Changes Exit

[Root @ localhost ~] # partx -a / dev / sdb # make kernel reread partition information of the hard disk sdb;

BLKPG: Device or resource busy

error adding partition 1

BLKPG: Device or resource busy

error adding partition 2

BLKPG: Device or resource busy

error adding partition 3

[Root @ localhost ~] # fdisk -l / dev / sdb # view the partition information of the hard disk sdb;

Disk / dev / sdb: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors / track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280bytes

Sector size (logical / physical): 512 bytes / 512 bytes

I / O size (minimum / optimal): 512 bytes / 512bytes

Disk identifier: 0x71f66aa7

  Device Boot Start End Blocks Id System

/ Dev / sdb1 1 654 5253223+ 8e Linux LVM

/ Dev / sdb2 655 1308 5253255 8e Linux LVM

/ Dev / sdb3 1309 1962 5253255 8e Linux LVM

[Root @ localhost ~] #


b, and will create a physical hard disk partitions as physical volumes (pvcreate)

[Root @ localhost ~] # pvcreate / dev / sdb [1-3] # three sdb create partitions on physical volumes;

 Physical volume "/ dev / sdb1" successfully created

 Physical volume "/ dev / sdb2" successfully created

 Physical volume "/ dev / sdb3" successfully created

[Root @ localhost ~] # pvcreate / dev / sdc # sdc to create a hard disk as a physical volume;

 Physical volume "/ dev / sdc" successfully created

[Root @ localhost ~] # pvs # view the physical volume created

 PV VG Fmt Attr PSize PFree

 / Dev / sda2 vg0 lvm2 a-- 59.99g 7.99g

 / Dev / sdb1 lvm2 --- 5.01g 5.01g

 / Dev / sdb2 lvm2 --- 5.01g 5.01g

 / Dev / sdb3 lvm2 --- 5.01g 5.01g

 / Dev / sdc lvm2 --- 20.00g 20.00g


Note: Use CentOS6.6 systems on VMwareWorkstations 11, the newly added hard disk requires a system restart in order to operate, such as sdc, need to continue to verify;

c, the physical volume (pv) to create a volume group (vgcreate), named myvg:

[Root @ localhost ~] # vgcreate myvg / dev / sdb [1-3] / dev / sdc # create a volume group (VG), the volume group named myvg, using the physical volume:

                                                                                                                                  # / Dev / sda [1-3] and / dev / sdc

 Volume group "myvg" successfully created

[Root @ localhost ~] # vgs # View creates a volume group;

 VG #PV #LV #SN Attr VSize VFree

 myvg 4 0 0wz - n- 35.02g 35.02g

 vg0 1 4 0wz - n- 59.99g 7.99g

[Root @ localhost ~] # vgdisplay # view detailed information about the volume group;

  --- Volume group ---

  VGName myvg # vgname

 System ID

 Format lvm2 # format

 Metadata Areas 4

 Metadata Sequence No 1

  VGAccess read / write

  VGStatus resizable

  MAXLV 0

  CurLV 0

 Open LV 0

  MaxPV 0

  CurPV 4

  ActPV 4

  Space VGSize 35.02 GiB # volume group, and is the all physical volumes;

  PESize 4.00 MiB # physical disk of the unit: Default 4MB;

 Total PE 8965

 Alloc PE / Size 0/0

 Free PE / Size 8965 / 35.02 GiB

d, create and format the logical volume group, use the mount;

[Root @ localhost ~] # lvcreate -L 5G -n mylv1myvg # create a logical volume, the volume name mylv1, volume size is 5G;

 Logical volume "mylv1" created

[Root @ localhost ~] # lvs # View the logical volume;

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

 mylv1 myvg -wi-a ----- 5.00g

 root vg0 -wi-ao ---- 20.00g

 swap vg0 -wi-ao ---- 2.00g

 usr vg0 -wi-ao ---- 10.00g

 var vg0 -wi-ao ---- 20.00g

[Root @ localhost ~] # mke2fs -j / dev / myvg / mylv1 # formatted logical volume, the file system is created ext series;

mke2fs 1.41.12 (17-May-2010)

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 superuser

First data block = 0

Maximum filesystem blocks = 1342177280

40 block groups

32768 blocks per group, 32768 fragments pergroup

8192 inodes per group

Superblock backups stored on blocks:

        32768,98304, 163840, 229376, 294912, 819200, 884736

 

Writing inode tables: done

Creating journal (32768 blocks): done

Writing superblocks and filesystemaccounting information: done

This filesystem will be automaticallychecked every 25 mounts or

180 days, whichever comes first. Use tune2fs -c or -i to override.

[Root @ localhost ~] # mkdir / mydata # create a mount directory;

[Root @ localhost ~] # mount / dev / myvg / mylv1 / mydata / # mount logical volumes;

[Root @ localhost ~] # mount # Check the mounted equipment;

/ Dev / mapper / vg0-root on / type ext4 (rw)

proc on / proc type proc (rw)

sysfs on / sys type sysfs (rw)

devpts on / dev / pts type devpts (rw, gid = 5, mode = 620)

tmpfs on / dev / shm type tmpfs (rw)

/ Dev / sda1 on / boot type ext4 (rw)

/ Dev / mapper / vg0-usr on / usr type ext4 (rw)

/ Dev / mapper / vg0-var on / var type ext4 (rw)

none on / proc / sys / fs / binfmt_misc typebinfmt_misc (rw)

/ Dev / mapper / myvg-mylv1 on / mydata type ext3 (rw) # mounted just the logical volume;

[Root @ localhost ~] # ls / mydata / # View mounted directories;

lost + found # heard after ext file system formatting is complete series will have this directory;

[Root @ localhost ~] # df -h # View Drive;

Filesystem Size Used Avail Use% Mounted on

/ Dev / mapper / vg0-root 20G 333M 19G 2% /

tmpfs 931M 0 931M 0% / dev / shm

/ Dev / sda1 190M 33M 148M 18% / boot

/ Dev / mapper / vg0-usr 9.8G 1.9G 7.4G 21% / usr

/ Dev / mapper / vg0-var 20G 200M 19G 2% / var

/ Dev / mapper / myvg-mylv1 5.0G 139M 4.6G 3% / mydata

e, if the volume group is not enough space to expand the volume group space;

Command (m for help): p

Disk / dev / sdb: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors / track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280bytes

Sector size (logical / physical): 512 bytes / 512 bytes

I / O size (minimum / optimal): 512 bytes / 512bytes

Disk identifier: 0x71f66aa7

# Created on an extended partition the hard disk sdb sdb4, in the extended partition to create logical partitions sdb5, and sdb5 the id that is 8e;

  Device Boot Start End Blocks Id System

/ Dev / sdb1 1 654 5253223+ 8e Linux LVM

/ Dev / sdb2 655 1308 5253255 8e Linux LVM

/ Dev / sdb3 1309 1962 5253255 8e Linux LVM

/ Dev / sdb4 1963 2485 4200997+ 5 Extended

/ Dev / sdb5 1963 2485 4200966 8e Linux LVM

[Root @ localhost ~] # partx -a / dev / sdb # sdb kernel re-read of the partition table;

[Root @ localhost ~] # pvcreate / dev / sdb5 # Create the physical volume / dev / sdb5

 Physical volume "/ dev / sdb5" successfully created

[Root @ localhost ~] # pvs # view the physical volume

 PV VG Fmt Attr PSize PFree

 / Dev / sda2 vg0 lvm2 a-- 59.99g 7.99g

 / Dev / sdb1 myvg lvm2 a-- 5.01g 8.00m

 / Dev / sdb2 myvg lvm2 a-- 5.01g 5.01g

 / Dev / sdb3 myvg lvm2 a-- 5.01g 5.01g

 / Dev / sdb5 lvm2 --- 4.01g 4.01g # new physical volume / dev / sdb5

 / Dev / sdc myvg lvm2 a-- 20.00g 20.00g

[Root @ localhost ~] # vgextend myvg / dev / sdb5 # expand volume group, use vgextend command;

 Volume group "myvg" successfully extended

[Root @ localhost ~] # vgs # Check the size of the extended volume group;

 VG #PV #LV #SN Attr VSize VFree

 myvg 5 1 0wz - n- 39.02g 34.02g

 vg0 1 4 0wz - n- 59.99g 7.99g


f, the logical volume expansion (support online expansion)

[Root @ localhost ~] # cd / mydata /

[Root @ localhost mydata] # touchkalaguiyin.html

[Root @ localhost mydata] # echo "This isKaLaguiyin's test blog."> Kalaguiyin.html

[Root @ localhost mydata] # catkalaguiyin.html

This is KaLaguiyin's test blog.

[Root @ localhost mydata] # vgs

  VG #PV #LV #SN Attr VSize VFree

  myvg 5 1 0 wz - n- 39.02g 34.02g # VG to view the information before expansion, compared with the post-expansion;

 vg0 1 4 0wz - n- 59.99g 7.99g

[Root @ localhost mydata] #

[Root @ localhost mydata] # lvextend -L + 4G / dev / myvg / mylv1 # extend the logical volume mylv1, space + 4G;

 Size of logical volume myvg / mylv1 changed from 5.00 GiB (1280 extents) to 9.00 GiB (2304 extents).

 Logical volume mylv1 successfully resized

 [Root @ localhostmydata] # resize2fs -p / dev / myvg / mylv1 # by resize2fs will indeed increase the capacity of the file system;

resize2fs 1.41.12 (17-May-2010)

Filesystem at / dev / myvg / mylv1 is mounted on / mydata; on-line resizing required

old desc_blocks = 1, new_desc_blocks = 1

Performing an on-line resize of / dev / myvg / mylv1 to 2359296 (4k) blocks.

The filesystem on / dev / myvg / mylv1 is now2359296 blocks long.

 

[Root @ localhost mydata] # lvs # View logical capacity;

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

 mylv1 myvg -wi-ao ---- 9.00g

 root vg0 -wi-ao ---- 20.00g

 swap vg0 -wi-ao ---- 2.00g

 usr vg0 -wi-ao ---- 10.00g

 var vg0 -wi-ao ---- 20.00g

[Root @ localhost mydata] # catkalaguiyin.html # view the file contents are complete

This is KaLaguiyin's test blog.

[Root @ localhost mydata] # df -h # see if the logical volume increase;

Filesystem Size Used Avail Use% Mounted on

/ Dev / mapper / vg0-root 20G 333M 19G 2% /

tmpfs 931M 0 931M 0% / dev / shm

/ Dev / sda1 190M 33M 148M 18% / boot

/ Dev / mapper / vg0-usr 9.8G 1.9G 7.4G 21% / usr

/ Dev / mapper / vg0-var 20G 200M 19G 2% / var

/ Dev / mapper / myvg-mylv1 8.9G 140M 8.3G 2% / mydata


g, reduce the logical volume

Reduced preparation:

See logical use of space conditions;

Can not cut online, you must first uninstall;

To ensure that the reduced size of the space is still capable of storing all the original data;

After the reduction should be forced to check the file to make sure that the file system in a consistent state;

The / dev / myvg / mylv1 reduced to 5G, and requires regular data can be accessed:

[Root @ localhost ~] # df -lh # view the used space;

Filesystem Size Used Avail Use% Mounted on

/ Dev / mapper / vg0-root 20G 333M 19G 2% /

tmpfs 931M 0 931M 0% / dev / shm

/ Dev / sda1 190M 33M 148M 18% / boot

/ Dev / mapper / vg0-usr 9.8G 1.9G 7.4G 21% / usr

/ Dev / mapper / vg0-var 20G 201M 19G 2% / var

/ Dev / mapper / myvg-mylv1

                      8.9G 140M 8.3G 2% / mydata

[Root @ localhost ~] # umount / dev / myvg / mylv1 # unmount the partition;

[Root @ localhost ~] # e2fsck -f / dev / myvg / mylv1 # mandatory check the file system;

e2fsck 1.41.12 (17-May-2010)

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 / myvg / mylv1: 12/589824 files (0.0% non-contiguous), 72705/2359296 blocks

[Root @ localhost ~] # resize2fs / dev / myvg / mylv1 5G # 5G to reduce the size of the logical volume

resize2fs 1.41.12 (17-May-2010)

Resizing the filesystem on / dev / myvg / mylv1to 1310720 (4k) blocks.

The filesystem on / dev / myvg / mylv1 is now1310720 blocks long.

 

[Root @ localhost ~] # lvreduce -L 5G / dev / myvg / mylv1 # reduce the physical size of the border;

 WARNING: Reducing active logical volume to 5.00 GiB

 THIS MAY DESTROY YOUR DATA (filesystem etc.)

Do you really want to reduce mylv1 [y / n]:? Y # need to confirm.

 Size of logical volume myvg / mylv1 changed from 9.00 GiB (2304 extents) to 5.00 GiB (1280 extents).

 Logical volume mylv1 successfully resized

[Root @ localhost ~] # lvs # View the logical volume;

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

 mylv1 myvg -wi-a ----- 5.00g

 root vg0 -wi-ao ---- 20.00g

 swap vg0 -wi-ao ---- 2.00g

 usr vg0 -wi-ao ---- 10.00g

 var vg0 -wi-ao ---- 20.00g

[Root @ localhost ~] # mount / dev / myvg / mylv1 / mydata / # remount;

[Root @ localhost ~] # ls / mydata /

kalaguiyin.html lost + found # file still exists;

[Root @ localhost ~] # cat / mydata / kalaguiyin.html

. This is KaLaguiyin's test blog # contents of the file is still intact;

[Root @ localhost ~] #

h, reducing disk space;

    Found insufficient physical disk space use, which will be a hard disk or partition removed;

    pvmove / dev / sdb5 # data will be stored on / dev / sdb5 moved to other physical volumes;

    vgreducemyvg / dev / sdb5 # to / dev / sdb5 myvg removed from the volume group;

    pvremove / dev / sdb5 # to / dev / sdb5 removed from the physical volume;

[Root @ localhost ~] # pvs # view the physical volume;

 PV VG Fmt Attr PSize PFree

 / Dev / sda2 vg0 lvm2 a-- 59.99g 7.99g

  / Dev / sdb1 myvg lvm2 a-- 5.01g 8.00m

 / Dev / sdb2 myvg lvm2 a-- 5.01g 5.01g

 / Dev / sdb3 myvg lvm2 a-- 5.01g 5.01g

 / Dev / sdb5 myvg lvm2 a-- 4.00g 4.00g

 / Dev / sdc myvg lvm2 a-- 20.00g 20.00g

[Root @ localhost ~] # pvmove / dev / sdb5 # data on / dev / sdb5 moved to another physical storage volume;

  Nodata to move for myvg

[Root @ localhost ~] # vgreduce myvg / dev / sdb5 # to / dev / sdb5 myvg removed from the volume group;

 Removed "/ dev / sdb5" from volume group "myvg"

[Root @ localhost ~] # pvremove / dev / sdb5 # to / dev / sdb5 removed from the physical volume;

 Labels on physical volume "/ dev / sdb5" successfully wiped

[Root @ localhost ~] # pvs # view the physical volume, / dev / sdb5 has been removed;

 PV VG Fmt Attr PSize PFree

 / Dev / sda2 vg0 lvm2 a-- 59.99g 7.99g

 / Dev / sdb1 myvg lvm2 a-- 5.01g 8.00m

 / Dev / sdb2 myvg lvm2 a-- 5.01g 5.01g

 / Dev / sdb3 myvg lvm2 a-- 5.01g 5.01g

 / Dev / sdc myvg lvm2 a-- 20.00g 20.00g

[Root @ localhost ~] #


i, snapshots, backup restore;

On / mnt / lvm directory, we will file the original directory snapshot, then / mydata directory contents emptied and restore;

[Root @ localhost ~] # cd / mydata /

[Root @ localhost mydata] # ls

kalaguiyin.html lost + found

[Root @ localhost mydata] # catkalaguiyin.html

This is KaLaguiyin's test blog.

[Root @ localhost mydata] # lvcreate -L 30M -nbackup -s -p r / dev / myvg / mylv1 # -L snapshot size; -n: snapshot name;

# -p Holding rights to read and write;

 Rounding up size to full physical extent 32.00 MiB

 Logical volume "backup" created

[Root @ localhost mydata] # ll

-rw-r - r-- 1 root root 32 Aug 26 17:14 kalaguiyin.html

drwx ------ 2 root root 16384 Aug 26 16: 42lost + found

[Root @ localhost mydata] # mkdir / tmp / backup # create a mount directory;

[Root @ localhost mydata] # mount / dev / myvg / backup / tmp / backup / # mount the snapshot logical;

mount: block device / dev / mapper / myvg-backupis write-protected, mounting read-only

[Root @ localhost mydata] # cd / tmp / backup /

[Root @ localhost backup] # ls

kalaguiyin.html lost + found

[Root @ localhost backup] # mkdir / tmp / lvmbackup # Create a backup directory;

[Root @ localhost backup] # tar jcf / tmp / lvmbackup / Sunday.tar.bz2 kalaguiyin.html # packaged and compressed files;

 [Root @ localhosttmp] # cd lvmbackup /

[Root @ localhost lvmbackup] # ls

Sunday.tar.bz2

[Root @ localhost ~] # cd / mydata / # mount into the original logical directory;

[Root @ localhost mydata] # ll

total 20

-rw-r - r-- 1 root root 32 Aug 26 17:14 kalaguiyin.html

drwx ------ 2 root root 16384 Aug 26 16: 42lost + found

[Root @ localhost mydata] # rm -rf * # delete all files;

[Root @ localhost mydata] # ll

total 0

[Root @ localhost mydata] # tar xvf / tmp / lvmbackup / Sunday.tar.bz2 # restore backup data;

kalaguiyin.html

[Root @ localhost mydata] # ll

total 4

-rw-r - r-- 1 root root 32 Aug 26 17: 14kalaguiyin.html

[Root @ localhost mydata] # catkalaguiyin.html # view the file contents;

This is KaLaguiyin's test blog.

[Root @ localhost mydata] # df -h

Filesystem Size Used Avail Use% Mounted on

/ Dev / mapper / vg0-root 20G 333M 19G 2% /

tmpfs 931M 0 931M 0% / dev / shm

/ Dev / sda1 190M 33M 148M 18% / boot

/ Dev / mapper / vg0-usr 9.8G 1.9G 7.4G 21% / usr

/ Dev / mapper / vg0-var 20G 201M 19G 2% / var

/ Dev / mapper / myvg-mylv1

                      5.0G 139M 4.6G 3% / mydata

/ Dev / mapper / myvg-backup

                      5.0G 139M 4.6G 3% / tmp / backup
     
         
         
         
  More:      
 
- Tune in high resolution to 1280x800 in Fedora 14 (Linux)
- Node.js development environment deployment (Server)
- Linux installation Jetty deployment under RedHat5 8 (Linux)
- Linux system monitoring tool set cpu (Linux)
- Linux operating system security settings initial understanding (Linux)
- C language Bubble Sort - integer sort (Programming)
- linux remote control software (Linux)
- Vim plugin installation YouCompleteMe (Linux)
- CentOS7 installation hardware monitoring for Zabbix enterprise applications (Server)
- Workspace Go language and environment variables GOPATH (Linux)
- CentOS card fails to start at boot progress bar certmonger solve (Linux)
- Linux at command (Linux)
- Linux PXE unattended installation PXE-E32: TFTP OPen timeout the solution (Linux)
- Zorin OS: Linux novice most personal desktop system should be used (Linux)
- Quickly locate the mistakes by gdb location (Programming)
- Intel Graphics Installer installation on Ubuntu 15.10 (Linux)
- How to clear the v $ archived_log view expiration information (Database)
- Writing Better Bash build script 8 (Programming)
- Git Installation and Configuration (Network Agent settings) (Linux)
- Linux how to view the graphics models notebook (Linux)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.