Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Linux \ LVM Disk Manager Application     - The user of fedora is not in the sudoers file method to solve (Linux)

- Configure shared library PCRE (Linux)

- GoldenGate for Oracle data consistency initializing (Database)

- Digital jQuery scrolling effect (Programming)

- MySQL display operation control tips (Database)

- Debugging with GDB tool Go (Programming)

- The Samba service does not have permission to access (Server)

- Summarize small problems encountered in the use Lua (Programming)

- Gitolite how to import other Git repositories (Server)

- Linux network security probing tools Hping2 (Linux)

- Compile and install GCC 4.8.1 + GDB 7.6.1 + Eclipse in CentOS 6.4 in (Linux)

- Ordinary users how to use the firewall software (Linux)

- Lua and C ++ (Programming)

- How to interactively create a Docker container (Server)

- MySQL event table to achieve timing build a small note (Database)

- MySQL partition summary (Database)

- C # how to generate a folder or file automatically rename (Programming)

- MySQL monitoring tools -orzdba (Database)

- KVM QEMU virtual machine installation configuration under CentOS (Linux)

- Linux iptables firewall settings to use (Linux)

  LVM Disk Manager Application
  Add Date : 2018-11-21      
  1, LVM Introduction
LVM (LogicalVolume Manager), Chinese translation is called logical volume manager, translation on some Taiwanese textbooks into logical scrollbar administrator. AIX initially implemented by IBM, and later by the Mauelshagen implemented on Linux, it is now part of Linux.

LVM provides a more flexible solution for large-capacity system partition. Generally speaking, when we installed the system, will be in accordance with a certain proportion, combined with their own experience, to partitions dividing the appropriate capacity. However, as the system continues to run in the actual production environment, we found that some of the capacity of the partition and can not meet our needs. Although we can solve these problems by certain methods (such as creating a connection), but these methods are not enough elegance. So LVM appeared. LVM is an abstraction of storage technology, which on the hard disk partition, and create a logical layer to gain access to the system hard disk partition management.

2, LVM often encounter the term
PV: physical volume, it may be a separate disk partition or RAID system to be. Physical volume can not rely on LVM systems exist independently.
VG: Volume Group, LVM device upper treat it as a physical device to use, is actually a logical abstraction layer, is responsible for coordinating the physical blocks of the upper and lower logical volume.
LV: logical, similar to the concept of non-LVM system partition, in LVM system is treated as a separate partition to use.
PE: physical block is the basic unit of each logical volume is divided, and also the smallest addressable unit LVM system.

3, how LVM function
Step 1: Create pv, using the pvcreate command. Prepare a hard disk, and any type of adjustment is divided into several independent partitions, and partition is 8e. I have divided on the physical disk size is 1G of three partitions, the effect is as follows (PS: As to how the zoning, I will not repeat them here):
[Root @ localhost ~] # fdisk -l / dev / hda
Disk / dev / hda: 21.4 GB, 21474836480 bytes
15 heads, 63 sectors / track, 44384 cylinders
Units = cylinders of 945 * 512 = 483840 bytes
  Device Boot Start End Blocks Id System
/ Dev / hda1 1 2068 977098+ 8e Linux LVM
/ Dev / hda2 2069 4136 977130 8e Linux LVM
/ Dev / hda3 4137 6204 977130 8e Linux LVM

Then you begin to create the physical volume:
[Root @ localhost ~] # pvcreate / dev / hda {1,2,3}
  Writing physical volume data to disk "/ dev / hda1"
  Physical volume "/ dev / hda1" successfully created
  Writing physical volume data to disk "/ dev / hda2"
  Physical volume "/ dev / hda2" successfully created
  Writing physical volume data to disk "/ dev / hda3"
  Physical volume "/ dev / hda3" successfully created

The pvs command to view the details of the physical volume of available space I have shown here does not meet the original size because of the need to preserve some of the LVM metadata:
  [Root @ localhost ~] # pvs
  PV VG Fmt Attr PSize PFree
  / Dev / hda1 lvm2 a-- 954.20M 954.20M
  / Dev / hda2 lvm2 a-- 954.23M 954.23M
  / Dev / hda3 lvm2 a-- 954.23M 954.23M
  / Dev / sda2 VolGroup00 lvm2 a-- 19.88G

In addition, the use of fear pvdisplay can view more detailed information about the physical volumes, use pvscan can view the total number of created pv.
Step 2: Create vg, use the vgcreate command.
l -s option to specify the size of the physical extents, the default is 4M
[Root @ localhost ~] # vgcreate myvg / dev / hda {1,2,3}
  Volume group "myvg" successfully created

Use vgremove command to remove vg:
  [Root @ localhost ~] # vgremove myvg
  Volume group "myvg" successfully removed

Extended vg, first prepare a pv Subdivision:
12345 [root @ localhost ~] # pvcreate / dev / hda5
  Writing physical volume data to disk "/ dev / hda5"
  Physical volume "/ dev / hda5" successfully created
  [Root @ localhost ~] # vgextend myvg / dev / hda5
  Volume group "myvg" successfully extended

Remove an underlying disk approach: first to use pvmove command for data transfer operation:
 [Root @ localhost ~] # pvmove / dev / hda3
  No data to move for myvg

Then use vgreduce command to remove logical volumes:
 [Root @ localhost ~] # vgreduce myvg / dev / hda3
  Removed "/ dev / hda3" from volume group "myvg"

Finally, use the pvremove command to remove the physical volume:
[Root @ localhost ~] # pvremove / dev / hda3
  Labels on physical volume "/ dev / hda3" successfully wiped

Step 3: Create lv, use the lvcreate command.
[Root @ localhost ~] # lvcreate -L 50M -n test0 myvg
  Rounding up size to full physical extent 56.00 MB
  Logical volume "test0" creat

You can use the lvs command to view performance or lvdisplay command:
[Root @ localhost ~] # lvs
  LV VG Attr LSize Origin Snap% Move Log Copy% Convert
  LogVol00 VolGroup00 -wi-ao 17.88G
  LogVol01 VolGroup00 -wi-ao 2.00G
  test0 myvg -wi-a- 56.00M

Use LVM method is also very simple, direct formatting, you can mount:
[Root @ localhost ~] # mke2fs -j / dev / myvg / test0
[Root @ localhost ~] # mount / dev / myvg / test0 / mnt / LVM

4, the logical volume expansion and shrink logical volumes
l Extension:
Extended logical volume lvextend command
[Root @ localhost ~] # lvextend -L + 50M / dev / myvg / test0
  Rounding up size to full physical extent 56.00 MB
  Extending logical volume test0 to 112.00 MB
  Logical volume test0 successfully resized
  [Root @ localhost ~] # resize2fs / dev / myvg / test0

l reduce the logical volume
i) Do not cut online, you must first uninstall the existing file system;
ii) to ensure the future of space reduction is still able to let go of all content data;
iii) should be reduced before the file system check to ensure that the file system in a consistent state.
Now demonstration as follows:
 [Root @ localhost ~] # e2fsck -f / dev / myvg / test0
 [Root @ localhost ~] # lvreduce -L 50M / dev / myvg / test0
 [Root @ localhost ~] # resize2fs / dev / myvg / test0

5, create a snapshot volume (snapshot)
First, the need to create a snapshot of the system partition is mounted to the appropriate directory:
[Root @ localhost mnt] # mount / dev / myvg / newlv / mnt / newlv /

Then run the command to create a snapshot volume:
[Root @ localhost /] # lvcreate -L 50M -s -n newlv_snap / dev / myvg / newlv
Rounding up size to full physical extent 56.00 MB
Logical volume "newlv_snap" created

Mount Snapshot:
[Root @ localhost /] # mount / dev / myvg / newlv / snap

View performance:
[Root @ localhost newlv] # touch a b c
[Root @ localhost newlv] # ls / snap
a b c lost + found
- Linux environment Duplex (multi-machine) automatic mutual backup scheme (Linux)
- Understanding the type in C ++ bitset (Programming)
- Linux system installation and usage instructions Wetty (Linux)
- Update GAMIT10.6 command (Linux)
- CentOS 6.4 of cron scheduled task configuration (Linux)
- Linux operating system ARP Spoofing Defense (Linux)
- Python objects (Programming)
- Advanced network security tips Linux backdoor Technology and Practice (Linux)
- Change all child files and subdirectories in the owner permissions Ubuntu (Linux)
- nginx.conf Optimization (Server)
- DB2 commonly used scripting sort out (Database)
- Let CentOS perform PPPoE dial-up, ADSL can be used in a network environment! (Linux)
- How to use static, class, abstract method in Python (Programming)
- C ++ implementation of the list of basic operations and test cases (Programming)
- Processor in protected mode of protection (Linux)
- Upgrading Oracle to (Database)
- Analysis of memory mapping process in Linux x86-64 mode (Linux)
- Timing task Crontab under Linux system (Linux)
- learning Linux ls command examples (Linux)
- Ubuntu 14.10 / 14.04 / 12.04 How to install Kodi 14.0 RC3 (Linux)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.