1. LVM is short for logical disk volume management (LogicalVolumeManager). It is a mechanism for managing disk partitions in Linux, LVM is a logical layer built on hard disks and partitions to improve disk management flexibility in the LVM area. As mentioned above, LVM is a logical layer added between the disk partition and the file system
1. Introduction
LVM is short for Logical volume management (Logical VolumeManager). It is a mechanism for managing disk partitions in Linux. LVM is a Logical layer built on hard disks and partitions, to improve the disk distribution by LVM
The flexibility of zone management. As mentioned above, LVM is a logical layer added between the disk partition and the file system to shield the file system from the underlying disk partition layout and provide an abstract disk volume, create a file system on the disk. A physical volume (physicalvolume) refers to a hardware partition or a device (such as RAID) with the same functions as a disk partition logically. it is the basic storage logical block of LVM, however, compared with basic physical storage media (such as partitions and disks), it contains management parameters related to LVM.
2. Create
[Root @ cn-iss-install-01 mapper] # fdisk-l
[Root @ cn-iss-install-01 mapper] # fdisk/dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier0x874c7742.
Changes will remain in memory only, until you decide to writethem.
After that, of course, the previous content won't berecoverable.
Warning: invalid flag 0x0000 of partition table 4 will becorrected by w (rite)
WARNING: DOS-compatible mode is deprecated. It's stronglyrecommended
Switch off themode (command 'C') and change display units
Sectors (command 'u ').
Command (m for help): m
Command action
A toggle a bootable flag
B edit bsd disklabel
C toggle the dos compatibility flag
D delete a partition
L list known partition types
M print this menu
N add a new partition
O create a new empty DOS partitiontable
P print the partition table
Q quit without saving changes
S create a new empty Sun disklabel
T change a partition's system id
U change display/entry units
V verify the partition table
W write table to disk and exit
X extra functionality (expertsonly)
Command (m for help): p
Disk/dev/sdb: 96.6 GB, 96636764160 bytes
255 heads, 63 sectors/track, 11748 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: 0x874c7742
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
E extended
P primary partition (1-4)
P
Partition number (1-4): 1
First cylinder (1-11748, default 1 ):
Using default value 1
Last cylinder, + cylinders or + size {K, M, G} (1-11748, default11748): + 80G
Command (m for help): p
Disk/dev/sdb: 96.6 GB, 96636764160 bytes
255 heads, 63 sectors/track, 11748 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: 0x874c7742
Device Boot Start End Blocks Id System
/Dev/sdb1 1 10444 83891398 + 5 Extended
Command (m for help): w
The partition table has been altered!
Calling ioctl () to re-read partition table.
Syncing disks.
[Root @ cn-iss-install-01 mapper] # reboot or
[Root @ cn-iss-install-01 Packages] # partprobe
[Root @ cn-iss-install-01 ~] # Fdisk-l
Disk/dev/sda: 17.2 GB, 17179869184 bytes
64 heads, 32 sectors/track, 16384 cylinders
Units = cylinders of 2048*512 = 1048576 bytes
Sector size (logical/physical): 512 bytes/512 bytes
I/O size (minimum/optimal): 512 bytes/512 bytes
Disk identifier: 0x0005b1c0
Device Boot Start End Blocks Id System
/Dev/sda1*2 251 256000 83 Linux
Partition 1 does not end on cylinder boundary.
/Dev/sda2 252 16384 16520192 8e Linux LVM
Partition 2 does not end on cylinder boundary.
Disk/dev/sdb: 96.6 GB, 96636764160 bytes
255 heads, 63 sectors/track, 11748 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: 0x874c7742
Device Boot Start End Blocks Id System
/Dev/sdb1 1 10444 83891398 + 5 Extended
Disk/dev/mapper/VG00-LV_rootfs: 16.4 GB, 16374562816 bytes
255 heads, 63 sectors/track, 1990 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: 0x00000000
Disk/dev/mapper/VG00-LV_swap: 536 MB, 536870912 bytes
255 heads, 63 sectors/track, 65 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: 0x00000000
[Root @ cn-iss-install-01 ~] #
[Root @ cn-iss-install-01 Packages] # pvcreate/dev/sdb1
Writing physical volume data to disk "/dev/sdb1"
Physical volume "/dev/sdb1" successfully created
[Root @ cn-iss-install-01 Packages] #
[Root @ cn-iss-install-01 Packages] # vgcreate vg03/dev/sdb1
Volume group "vg03" successfully created
[Root @ cn-iss-install-01 Packages] # lvcreate-L 83G-n vgdatavg03
[Root @ cn-iss-install-01 Packages] # mke2fs/dev/vg03/vgdata
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
5439488 inodes, 21757952 blocks
1087897 blocks (5.00%) reserved for the super user
First data block = 0
Maximum filesystem blocks = 4294967296
664 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768,983 04, 163840,229376, 294912,819 200, 884736,160 5632, 2654208,
4096000,796 20480000
Writing inode tables: done
Writing superblocks and filesystem accounting information:
Done
This filesystem will be automatically checked every 23 mountsor
180 days, whichever comes first. Use tune2fs-c or-I tooverride.
[Root @ cn-iss-install-01 Packages] #
[Root @ cn-iss-install-01 Packages] #
[Root @ cn-iss-install-01 Packages] # mkf
Mkfifo mkfs. cramfs mkfs. ext3 mkfs. ext4dev
Mkfs. ext2 mkfs. ext4
[Root @ cn-iss-install-01 Packages] # mkfs. ext4/dev/vg03/vgdata
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
5439488 inodes, 21757952 blocks
1087897 blocks (5.00%) reserved for the super user
First data block = 0
Maximum filesystem blocks = 4294967296
664 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768,983 04, 163840,229376, 294912,819 200, 884736,160 5632, 2654208,
4096000,796 20480000
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 37 mountsor
180 days, whichever comes first. Use tune2fs-c or-I tooverride.
[Root @ cn-iss-install-01 Packages] #
[Root @ cn-iss-install-01 spool] # mount/dev/vg03/vgdata/var/spool/repo/
[Root @ cn-iss-install-01 spool] # cd repo/
[Root @ cn-iss-install-01 repo] # ls
Lost + found
[Root @ cn-iss-install-01 repo] # pwd
/Var/spool/repo
[Root @ cn-iss-install-01 repo] #
3. common check commands:
[Root @ cn-iss-install-01/] # pvdisplay
[Root @ cn-iss-install-01/] # vgdisplay
[Root @ cn-iss-install-01/] # lvdisplay
[Root @ cn-iss-install-01/] # pvcreate
Please enter a physical volume path
Run 'pvcreate -- help' for more information.
[Root @ cn-iss-install-01/] # vgcreate
Please provide volume group name and physical volumes
Run 'vgcreate -- help' for more information.
[Root @ cn-iss-install-01/] # lvcreate
Please provide a volume group name
Run 'lvcreate -- help' for more information.
[Root @ cn-iss-install-01/] # vgextend
Please enter volume group name and physical volume (s)
Run 'vgextend -- help' for more information.
[Root @ cn-iss-install-01/] # lvextend
Please specify either size or extents but not both.
Run 'lvextend -- help' for more information.
[Root @ cn-iss-install-01/] #