Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Disk Management LVM     - How to set up HTTPS policies for older browsers (Server)

- Java learning problems encountered (Programming)

- Windows 8.1 hard drive to install Ubuntu 14.04 dual system reference tutorials and multi-drive Precautions (Linux)

- Linux 10 useful examples of command-line completion (Linux)

- Setting Squid successful anti-hotlinking (Linux)

- ARM assembler instruction debugging method (Programming)

- Articles do not resolve after opening under Ubuntu WordPress setting a fixed link (Server)

- Linux operation and maintenance engineers face questions Intermediate (Linux)

- Formatted output printf command (Programming)

- Log analysis is done with Grafana Elasticsearch (Server)

- Getting Started with Linux: Nginx Web Server How to Block Specific User Agents (UA) (Server)

- Installation image conversion tool on your Ubuntu Converseen 0.8.1 (Linux)

- HTTP Client Hints Introduction (Server)

- Oracle Execute to Parse perform analytical Ratio Analysis (Database)

- To share Linux script automatically change passwords (Linux)

- Make Linux more secure server tips (Linux)

- Linux usage in echo (Linux)

- C ++ free store and heap (Programming)

- printf PHP string operations () built-in function usage (Programming)

- Linux system crash (no such file or directory) How to rescue database (Linux)

 
         
  Disk Management LVM
     
  Add Date : 2018-11-21      
         
         
         
  LVM is the logical volume management (Logical Volume Manager) is short, it is the Linux environment on a disk partition management of a mechanism, LVM is built on the hard disk and partition on a logical layer, thereby increasing the flexibility of the disk partition management sex. The next experiments to learn more about LVM usage.

1. Prepare test environment. Adding an unused disk / dev / sdb, use fdisk from which separated two 5G partition, and it is the partition type 8e

[Root @ localhost ~] # fdisk -l / dev / sdb

Disk / dev / sdb: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors / track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

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

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

Disk identifier: 0x0f199ec4

  Device Boot Start End Blocks Id System

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

/ Dev / sdb2 655 1308 5253255 8e Linux LVM


2. Create a physical volume:

[Root @ localhost ~] # pvcreate / dev / sdb1

  Physical volume "/ dev / sdb1" successfully created

[Root @ localhost ~] # pvcreate / dev / sdb2

  dev_is_mpath: failed to get device for 8:18

  Physical volume "/ dev / sdb2" successfully created

[Root @ localhost ~] # pvscan

  PV / dev / sda2 VG vg0 lvm2 [59.99 GiB / 7.99 GiB free]

  PV / dev / sdb1 lvm2 [5.01 GiB]

  PV / dev / sdb2 lvm2 [5.01 GiB]

  Total: 3 [70.01 GiB] / in use: 1 [59.99 GiB] / in no VG: 2 [10.02 GiB]


3. Create a volume group on the basis of physical volume on the / dev / sdb1 added volume group

[Root @ localhost ~] # vgcreate test / dev / sdb1

  Volume group "test" successfully create

[Root @ localhost ~] # vgscan # can see the volume group has been created successfully test

  Reading all physical volumes. This may take a while ...

  Found volume group "test" using metadata type lvm2

  Found volume group "vg0" using metadata type lvm2


4. Create a 4G size for the logical volume in the volume group test in test1

[Root @ localhost ~] # lvcreate -L 4G -n test1 test

  Logical volume "test1" created

[Root @ localhost ~] # lvscan

  ACTIVE '/ dev / test / test1' [4.00 GiB] inherit # test1 has successfully created

  ACTIVE '/ dev / vg0 / root' [20.00 GiB] inherit

  ACTIVE '/ dev / vg0 / swap' [2.00 GiB] inherit

  ACTIVE '/ dev / vg0 / usr' [10.00 GiB] inherit

  ACTIVE '/ dev / vg0 / var' [20.00 GiB] inherit


5. Then you can follow the ordinary partitions formatted for test1, and use the mount

[Root @ localhost ~] # mkfs.ext4 / dev / test / test1

mke2fs 1.41.12 (17-May-2010)

......

This filesystem will be automatically checked every 34 mounts or

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

[Root @ localhost ~] # mkdir / test

[Root @ localhost ~] # mount / dev / test / test1 / test /

[Root @ localhost ~] # df -h

Filesystem Size Used Avail Use% Mounted on

/ Dev / mapper / vg0-root 20G 428M 19G 3% /

tmpfs 246M 0 246M 0% / dev / shm

/ Dev / sda1 194M 30M 155M 16% / boot

/ Dev / mapper / vg0-usr 9.9G 2.3G 7.2G 24% / usr

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

/ Dev / mapper / test-test1 4.0G 136M 3.7G 4% / test # logical successfully created


6. Under / test into a file, use test

[Root @ localhost test] # echo "lv test"> a.txt

[Root @ localhost test] # cat a.txt

lv test

7. When you are finished using a period of time we might 4G space is not enough, this time, we can extend the flexibility of test1 .LVM would show out. For example, we want to extend to 7G, but after viewing, volume the group has enough space to use, you need to expand the volume group

[Root @ localhost test] # vgs test

VG #PV #LV #SN Attr VSize VFree

test 1 1 0 wz - n- 5.01g 1.01g

[Root @ localhost test] # vgextend test / dev / sdb2

Volume group "test" successfully extended

[Root @ localhost test] # vgs test

VG #PV #LV #SN Attr VSize VFree

test 2 1 0 wz - n- 10.02g 6.02g


8. Extending a Logical Volume test1 (first extended physical boundaries, and then extended file system boundaries)

[Root @ localhost test] # vgextend test / dev / sdb2

Volume group "test" successfully extended

[Root @ localhost test] # vgs test

VG #PV #LV #SN Attr VSize VFree

test 2 1 0 wz - n- 10.02g 6.02g

[Root @ localhost test] # lvextend -L 7G / dev / test / test1 # Extended physical boundaries

Extending logical volume test1 to 7.00 GiB

Logical volume test1 successfully resized

[Root @ localhost test] # resize2fs / dev / test / test1 # extended file system boundaries

resize2fs 1.41.12 (17-May-2010)

Filesystem at / dev / test / test1 is mounted on / test; on-line resizing required

old desc_blocks = 1, new_desc_blocks = 1

Performing an on-line resize of / dev / test / test1 to 1835008 (4k) blocks.

The filesystem on / dev / test / test1 is now 1835008 blocks long.

[Root @ localhost test] # df -h # test1 successfully expanded to 7G size

Filesystem Size Used Avail Use% Mounted on

/ Dev / mapper / vg0-root 20G 428M 19G 3% /

tmpfs 246M 0 246M 0% / dev / shm

/ Dev / sda1 194M 30M 155M 16% / boot

/ Dev / mapper / vg0-usr 9.9G 2.3G 7.2G 24% / usr

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

/ Dev / mapper / test-test1 6.9G 137M 6.5G 3% / test


9. test1 access after testing to see whether the file is damaged

[Root @ localhost test] # cat a.txt # file is not damaged

lv test


10. Create a snapshot volume (for file system backup scenario uses)

[Root @ localhost test] # lvcreate -n snap-test1 -L 2G -s / dev / test / test1 -p r

Logical volume "snap-test1" created

[Root @ localhost test] # mkdir /test.bak

[Root @ localhost test] # mount / dev / test / snap-test1 /test.bak/

mount: block device / dev / mapper / test-snap - test1 is write-protected, mounting read-only


11. See test1 file content and the file list and the snapshot volume of a.txt

[Root @ localhost /] # ls / test

a.txt lost + found

[Root @ localhost /] # ls /test.bak/

a.txt lost + found

[Root @ localhost test] # cat /test/a.txt /test.bak/a.txt

lv test

lv test


12. Modify the test1 file, view its snapshot volume if the changes are made

[Root @ localhost test] # echo "This is a new line" >> / test / a.txt

[Root @ localhost test] # cat /test/a.txt

lv test

This is a new line

[Root @ localhost test] # cat /test.bak/a.txt # snapshot volume of the contents of the file has not changed

lv test
     
         
         
         
  More:      
 
- Kickstart automated installation and deployment RHEL 7.0 (Linux)
- When Linux Detailed time zone and common function of time (Linux)
- Linux Command - ps: a snapshot of the current process (Linux)
- Installation image conversion tool on your Ubuntu Converseen 0.8.1 (Linux)
- DVD production using CentOS installation source within the company Yum (Linux)
- How to install Ubuntu California - the calendar application (Linux)
- C ++ Supplements - References (Lvalue Reference, Rvalue Reference) (Linux)
- DRBD rapid installation and deployment (Server)
- Haproxy multi-domain certificate HTTPS (Server)
- Thinking in Java study notes - everything is an object (Programming)
- Ubuntu 14.04.02 LTS startup items erroneous writing / dev / sda1 (win 7 loader) Repair (Linux)
- awk variables (Linux)
- Manager Docker browser (Server)
- Linux argument references and command substitution (Linux)
- Linux script to copy the folder to all folders with the same name (Linux)
- Guide: Trickle restrict application bandwidth usage (Linux)
- Sublime Text 3 practical functions and shortcut keys used to collect (Linux)
- How to set the default Fedora from the command line (Linux)
- To restore the last time applications running when Ubuntu user log in again (Linux)
- MySQL appears data too long for column 'name' at row 1 to solve (Database)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.