Linux Add new Hard disk LVM operation (function: new HDD volume management) __linux

Source: Internet
Author: User
1

View current system hard disk and partition conditions

(Note: SCSI 1th hard drive/DEV/SDA in Linux, 2nd hard drive/dev/sdb, and so on) 2

Initialize partition SDB to physical volume PV

PVCREATE/DEV/SDB//initialization

Pvdisplay//Display physical Volume Information 3

Create Logical Volume group VG, add/dev/sdb physical volumes to this volume group (VolGroup00 name for yourself)

Vgcreate VOLGROUP00/DEV/SDB//Create Logical Volume group

Vgdisplay//Display volume Group information 4

Create logical Volume LV, name LogVol00, provide space by volume group VolGroup00, and give him 700M space to specify

Lvcreate-l 700m-n LogVol00 VolGroup00//Create logical volumes

Lvdisplay//Display Logical Volume information

Format logical partitions, format EXT4

Note: The same place that/dev/mapper and/dev/volgroup00/logvol00 point to

Mkfs.ext4/dev/mapper/volgroup00-logvol00

Or

Mkfs.ext4/dev/volgroup00/logvol00 the results are the same.

Test: Hang/dev/mapper/volgroup00-logvol00 This logical volume under/data2 file

Mount/dev/mapper/volgroup00-logvol00/data2

To this step, the physical volume pv--> logical Volume Group vg--> logical Volume LV creation completes, and can mount the file system. As the title, the goal is to expand the original file system/data size. The following completes this operation,

Uninstall the logical volumes that are mounted in the/DATA2 directory first

Uninstall/data mounted Partitions,

Before unloading data backup go, blood lesson ah.

Initialize partition/dev/sda5 Physical volume PV

PVCREATE/DEV/SDA5//initialization

Pvdisplay//Display Physical Volume information

/dev/sda5 added to VolGroup00 volume group, VolGroup00 volume group was created in the previous step

Vgextend Volgroup00/dev/sda5

To mount a/dev/mapper/volgroup00-logvol00 logical volume to the/data file system

Mount/dev/mapper/volgroup00-logvol00/data

Increase volgroup00-logvol00 Logical Volume 500M

Lvextend-l +500m/dev/mapper/volgroup00-logvol00

The previous operation is to increase the size of the logical volume,/data file system size has not changed, using the RESIZE2FS command, to redefine the file system size

Resize2fs/dev/volgroup00/logvol00

This is the end.

Report

Uninstall mounted File System

Umount/dev/volgroup00/logvol00

Delete Logical Volume

Lvdisplay View

LVREMOVE/DEV/VOLGROUP00/LOGVOL00//Logical Volume physical path

Delete Logical Volume Group

Vgdisplay View

Vgremove VolGroup00//Logical Volume group name

Delete Physical Volume

Pvdisplay View

PVREMOVE/DEV/SDB2//Physical volume name

Attached LVM schematic diagram

File system: Linux system files

Logical volumes: As the name suggests,

Physical Volume: Touch disk partition or RAID

Logical Volume LV Logical volume LV

\           /

\         /

\       /

Logical Volume Group VG

/    | \

/     | \

/      | \

Physical volume PV Physical Volume PV physical volume PV

Report

Common commands

1. Physical Volume command

General Maintenance Commands:

#pvscan//Search for existing physical volumes on all disks in the system

#pvdisplay the physical volume full path name//is used to display the properties of the specified physical volume.

#pvdata the physical volume full path name//volume Group description area information used to display the physical volume for debugging purposes.

#pvchange –x|--allocation {y|n} full pathname of physical volume///To change allocation permissions for physical volumes set up physical volumes create and delete commands

#pvcreate Device Full path name//is used to create physical volume initialization information on a disk or partition for logical volume management of the physical volume.

#pvmove Source Physical Volume full path I [Destination physical volume full path name]//is used to transfer data from a physical volume to another special issue volume in the same volume group.

2. Volume Group command

General Maintenance Commands

#vgscan//Detect all disks in the system

#vgck [Volume group name]//is used to check the consistency of the volume group description area information in the volume group.

#vgdisplay [Volume group name]//Display property information for a volume group

#vgrename the original volume group name New Volume group name

#vgchange-a Y|n [volume group name]//change the corresponding properties of the volume group. Whether to allocate

#vgchange-L maximum Logical volume//volume group can hold the maximum number of logical volumes

#vgchange-X y|n [Volume Group Name]//volume is valid

#vgmknodes [Volume Group name | Volume group path]//To establish (re-establish) an existing volume group directory and the device files therein

Backup and Restore commands for volume group configuration

#vgcfgbackup [Volume group name]//VGDA information in a volume group to a file in the "/etc/lvmconf" directory

#vgcfgrestore-N Volume group name physical volume full path name//The physical volume information must be specified from the backup file

Set up and Delete commands for volume groups

#vgcreate Volume group name physical volume full path name [physical volume full path name]

#vgmove Volume Group Name

Expansion and reduction commands for volume groups

#vgextend Volume group name physical volume full path name [physical volume full path name]

#vgreduce Volume group name physical volume full path name [physical volume full path name]

Merge and split of volume groups

#vgmerge Destination Volume group name Source Volume group name//merge two existing volume groups, requiring two volume groups for equal physical area size and source volume group inactive.

#vgsplit existing Volume group New Volume Group physical volume full path name [physical volume full path name] input and Output command for volume group

#vgexport Volume Group Name

#vgimport Volume group name Physical volumes in volume group [physical volumes in volume groups]

3. Logical Volume command

General commands

#lvscan

#lvdisplay Logical Volume full path name [logical volume full path name]

#lvrename old Logical Volume full path name new Logical volume full path name

#lvrename Volume group name Old logical volume name new Logical volume name

#lvchange

#e2fsadm-L +|-Logical Volume increment logical volume full path name

Logical volume creation and deletion commands

#lvcreate

#lvremove

Extensions and narrowing commands for logical volumes

#lvextend-l|--size + Logical Volume size increment logical volume full path name

#lvreduce q-l|--size + Logical Volume decrement logical volume full path name

4. Logical Volume Management Command

#lvmdiskscan//Detect all SCSI, IDE and other storage devices

#lvmchange-r|--reset//Reset Logical Volume Manager

#lvmsadc [log file full path name]//Receipt Logical Volume Manager read and write statistics, save to log text//parts.

Read and report logical volumes from the log file generated by the LVMSADC command #lvmsar log file full path name//

Add disk space does not recognize the solution:

The RESIZE2FS command is used to increase or decrease the size of the Ext2/ext3 file system that is not loaded. If the file system is in the Mount state, then it can only be expanded, provided that the kernel supports online resize. Linux kernel 2.6 supports expansion in Mount State but limited to ext3 file system

#umount-L/dev/mapper/ycgsstore_sdb-wmy

#e2fsck-F/dev/mapper/ycgsstore_sdb-wmy

#resize2fs/dev/mapper/ Ycgsstore_sdb-wmy

#mount/dev/mapper/ycgsstore_sdb-wmy

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.