如何理解linux中的lvm
这篇文章给大家介绍如何理解linux中的lvm,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。
创新互联公司专注于中大型企业的成都做网站、成都网站设计、成都外贸网站建设和网站改版、网站营销服务,追求商业策划与数据分析、创意艺术与技术开发的融合,累计客户超过千家,服务满意度达97%。帮助广大客户顺利对接上互联网浪潮,准确优选出符合自己需要的互联网运用,我们将一直专注品牌网站设计和互联网程序开发,在前进的路上,与客户一起成长!
[root@ndb ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
122G 93G 23G 81% /
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 506M 0 506M 0% /dev/shm
/dev/sdc1 155G 100G 48G 68% /opt/oracle/oradata
[root@ndb ~]# rpm -aq|grep lvm
lvm2-2.02.74-5.el5
system-config-lvm-1.1.5-8.el5
[root@ndb ~]# fdisk -l
Disk /dev/sda: 137.4 GB, 137438953472 bytes
255 heads, 63 sectors/track, 16709 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 16709 134110620 8e Linux LVM
Disk /dev/sdb: 137.4 GB, 137438953472 bytes
255 heads, 63 sectors/track, 16709 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 12000 96389999+ 83 Linux
Disk /dev/sdc: 171.3 GB, 171375067136 bytes
255 heads, 63 sectors/track, 20835 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 20500 164666218+ 83 Linux
[root@ndb ~]# fdisk /dev/sdb
The number of cylinders for this disk is set to 16709.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
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 partition table
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 (experts only)
Command (m for help): p
Disk /dev/sdb: 137.4 GB, 137438953472 bytes
255 heads, 63 sectors/track, 16709 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 12000 96389999+ 83 Linux
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (12001-16709, default 12001):
Using default value 12001
Last cylinder or +size or +sizeM or +sizeK (12001-16709, default 16709):
Using default value 16709
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@ndb ~]# fdisk -l
Disk /dev/sda: 137.4 GB, 137438953472 bytes
255 heads, 63 sectors/track, 16709 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 16709 134110620 8e Linux LVM
Disk /dev/sdb: 137.4 GB, 137438953472 bytes
255 heads, 63 sectors/track, 16709 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 12000 96389999+ 83 Linux
/dev/sdb2 12001 16709 37825042+ 83 Linux
Disk /dev/sdc: 171.3 GB, 171375067136 bytes
255 heads, 63 sectors/track, 20835 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 20500 164666218+ 83 Linux
[root@ndb ~]# fdisk /dev/sdb
The number of cylinders for this disk is set to 16709.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 8e
Changed system type of partition 2 to 8e (Linux LVM)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@ndb ~]# fdisk -l
Disk /dev/sda: 137.4 GB, 137438953472 bytes
255 heads, 63 sectors/track, 16709 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 16709 134110620 8e Linux LVM
Disk /dev/sdb: 137.4 GB, 137438953472 bytes
255 heads, 63 sectors/track, 16709 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 12000 96389999+ 8e Linux LVM
/dev/sdb2 12001 16709 37825042+ 8e Linux LVM
Disk /dev/sdc: 171.3 GB, 171375067136 bytes
255 heads, 63 sectors/track, 20835 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 20500 164666218+ 83 Linux
[root@ndb ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
122G 93G 23G 81% /
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 506M 0 506M 0% /dev/shm
/dev/sdc1 155G 100G 48G 68% /opt/oracle/oradata
[root@ndb ~]# pvs
/dev/hdc: open failed: No medium found
PV VG Fmt Attr PSize PFree
/dev/sda2 VolGroup00 lvm2 a- 127.88G 0
[root@ndb ~]# lvs
/dev/hdc: open failed: No medium found
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
LogVol00 VolGroup00 -wi-ao 125.88G
LogVol01 VolGroup00 -wi-ao 2.00G
[root@ndb ~]# pvcreate /dev/sdb2
Physical volume "/dev/sdb2" successfully created
[root@ndb ~]# pvs
/dev/hdc: open failed: No medium found
PV VG Fmt Attr PSize PFree
/dev/sda2 VolGroup00 lvm2 a- 127.88G 0
/dev/sdb2 lvm2 a- 36.07G 36.07G
[root@ndb ~]# vgextend VolGroup00 /dev/sdb2
Volume group "VolGroup00" successfully extended
[root@ndb ~]# vgs
VG #PV #LV #SN Attr VSize VFree
VolGroup00 2 2 0 wz--n- 163.94G 36.06G
[root@ndb ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
LogVol00 VolGroup00 -wi-ao 125.88G
LogVol01 VolGroup00 -wi-ao 2.00G
[root@ndb ~]# cd /dev
[root@ndb dev]# ls
adsp dvd-hdc loop1 mixer ptmx ram2 root sequencer2 tty tty18 tty28 tty38 tty48 tty58 ttyS1 vcs5 VolGroup00
audio fd loop2 net pts ram3 rtc sg0 tty0 tty19 tty29 tty39 tty49 tty59 ttyS2 vcs6 X0R
autofs full loop3 null ram ram4 sda sg1 tty1 tty2 tty3 tty4 tty5 tty6 ttyS3 vcs7 zero
bus gpmctl loop4 nvram ram0 ram5 sda1 sg2 tty10 tty20 tty30 tty40 tty50 tty60 urandom vcsa
cdrom hdc loop5 oldmem ram1 ram6 sda2 shm tty11 tty21 tty31 tty41 tty51 tty61 usbdev1.1_ep00 vcsa1
cdrom-hdc hpet loop6 parport0 ram10 ram7 sdb snapshot tty12 tty22 tty32 tty42 tty52 tty62 usbdev1.1_ep81 vcsa2
console initctl loop7 parport1 ram11 ram8 sdb1 snd tty13 tty23 tty33 tty43 tty53 tty63 vcs vcsa3
core input MAKEDEV parport2 ram12 ram9 sdb2 stderr tty14 tty24 tty34 tty44 tty54 tty7 vcs1 vcsa4
disk kmsg mapper parport3 ram13 ramdisk sdc stdin tty15 tty25 tty35 tty45 tty55 tty8 vcs2 vcsa5
dsp log md0 port ram14 random sdc1 stdout tty16 tty26 tty36 tty46 tty56 tty9 vcs3 vcsa6
dvd loop0 mem ppp ram15 rawctl sequencer systty tty17 tty27 tty37 tty47 tty57 ttyS0 vcs4 vcsa7
[root@ndb dev]# cd VolGroup
-bash: cd: VolGroup: No such file or directory
[root@ndb dev]# cd VolGroup00
[root@ndb VolGroup00]# ls
LogVol00 LogVol01
[root@ndb VolGroup00]# ll
total 0
lrwxrwxrwx 1 root root 31 Sep 22 09:26 LogVol00 -> /dev/mapper/VolGroup00-LogVol00
lrwxrwxrwx 1 root root 31 Sep 22 09:26 LogVol01 -> /dev/mapper/VolGroup00-LogVol01
[root@ndb VolGroup00]# cd /dev/mapper
[root@ndb mapper]# ll
total 0
crw------- 1 root root 10, 63 Sep 22 09:26 control
brw-rw---- 1 root disk 253, 0 Sep 22 09:27 VolGroup00-LogVol00
brw-rw---- 1 root disk 253, 1 Sep 22 09:26 VolGroup00-LogVol01
[root@ndb mapper]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
LogVol00 VolGroup00 -wi-ao 125.88G
LogVol01 VolGroup00 -wi-ao 2.00G
[root@ndb mapper]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
122G 93G 23G 81% /
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 506M 0 506M 0% /dev/shm
/dev/sdc1 155G 100G 48G 68% /opt/oracle/oradata
[root@ndb mapper]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
LogVol00 VolGroup00 -wi-ao 125.88G
LogVol01 VolGroup00 -wi-ao 2.00G
[root@ndb mapper]# lvextend -L 5000 /dev/VolGroup00/LogVol00 /dev/sdb2
Rounding up size to full physical extent 4.91 GB
New size given (157 extents) not larger than existing size (4028 extents)
Run `lvextend --help' for more information.
[root@ndb mapper]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
122G 93G 23G 81% /
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 506M 0 506M 0% /dev/shm
/dev/sdc1 155G 100G 48G 68% /opt/oracle/oradata
[root@ndb mapper]# lvextend -L +5000 /dev/VolGroup00/LogVol00 /dev/sdb2
Rounding up size to full physical extent 4.91 GB
Extending logical volume LogVol00 to 130.78 GB
Logical volume LogVol00 successfully resized
[root@ndb mapper]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
122G 93G 23G 81% /
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 506M 0 506M 0% /dev/shm
/dev/sdc1 155G 100G 48G 68% /opt/oracle/oradata
[root@ndb mapper]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
LogVol00 VolGroup00 -wi-ao 130.78G
LogVol01 VolGroup00 -wi-ao 2.00G
[root@ndb mapper]#
Sistina Software UK LVM TOOLS 2.02.74(2)-RHEL5 (2010-12-03) LVEXTEND(8)
[root@ndb mapper]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
122G 93G 23G 81% /
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 506M 0 506M 0% /dev/shm
/dev/sdc1 155G 100G 48G 68% /opt/oracle/oradata
[root@ndb mapper]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
LogVol00 VolGroup00 -wi-ao 125.88G
LogVol01 VolGroup00 -wi-ao 2.00G
[root@ndb mapper]# lvextend -L +5000 /dev/VolGroup00/LogVol00 /dev/sdb2
Rounding up size to full physical extent 4.91 GB
Extending logical volume LogVol00 to 130.78 GB
Logical volume LogVol00 successfully resized
[root@ndb mapper]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
122G 93G 23G 81% /
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 506M 0 506M 0% /dev/shm
/dev/sdc1 155G 100G 48G 68% /opt/oracle/oradata
[root@ndb mapper]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
LogVol00 VolGroup00 -wi-ao 130.78G
LogVol01 VolGroup00 -wi-ao 2.00G
[root@ndb mapper]#
[root@ndb mapper]#
[root@ndb mapper]#
[root@ndb mapper]# reboot
Broadcast message from root (pts/1) (Sat Sep 22 10:00:20 2018):
The system is going down for reboot NOW!
[root@ndb mapper]#
Last login: Sat Sep 22 09:29:33 2018 from 10.0.2.100
[root@ndb ~]#
[root@ndb ~]#
[root@ndb ~]#
[root@ndb ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
122G 93G 23G 81% /
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 506M 0 506M 0% /dev/shm
/dev/sdc1 155G 100G 48G 68% /opt/oracle/oradata
[root@ndb ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
LogVol00 VolGroup00 -wi-ao 130.78G
LogVol01 VolGroup00 -wi-ao 2.00G
[root@ndb ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 VolGroup00 lvm2 a- 127.88G 0
/dev/sdb2 VolGroup00 lvm2 a- 36.06G 31.16G
[root@ndb ~]# cd /etc
[root@ndb etc]# vgdisplay
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 163.94 GB
PE Size 32.00 MB
Total PE 5246
Alloc PE / Size 4249 / 132.78 GB
Free PE / Size 997 / 31.16 GB
VG UUID Jtp0HE-dpyh-SDNg-3a6r-n02D-HuGd-Ps11FV
[root@ndb etc]# lvdisplay
--- Logical volume ---
LV Name /dev/VolGroup00/LogVol00
VG Name VolGroup00
LV UUID VbwdC0-RAvt-q0JN-w9A2-TI9g-oNSu-B5qED2
LV Write Access read/write
LV Status available
# open 1
LV Size 130.78 GB
Current LE 4185
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Name /dev/VolGroup00/LogVol01
VG Name VolGroup00
LV UUID WLbiHK-mTHG-uXTh-1U0y-xDjW-cdjR-3t0YjH
LV Write Access read/write
LV Status available
# open 1
LV Size 2.00 GB
Current LE 64
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
[root@ndb etc]# e2fsck -f /dev/VolGroup00/LogVol00
e2fsck 1.39 (29-May-2006)
/dev/VolGroup00/LogVol00 is mounted.
WARNING!!! Running e2fsck on a mounted filesystem may cause
SEVERE filesystem damage.
Do you really want to continue (y/n)? yes
/dev/VolGroup00/LogVol00: recovering journal
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/VolGroup00/LogVol00: ***** FILE SYSTEM WAS MODIFIED *****
/dev/VolGroup00/LogVol00: ***** REBOOT LINUX *****
/dev/VolGroup00/LogVol00: 195488/32997376 files (0.4% non-contiguous), 25343398/32997376 blocks
[root@ndb etc]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
122G 93G 23G 81% /
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 506M 0 506M 0% /dev/shm
/dev/sdc1 155G 100G 48G 68% /opt/oracle/oradata
[root@ndb etc]# resize2fs /dev/VolGroup00/LogVol00
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/VolGroup00/LogVol00 to 34283520 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol00 is now 34283520 blocks long.
[root@ndb etc]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
127G 93G 28G 78% /
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 506M 0 506M 0% /dev/shm
/dev/sdc1 155G 100G 48G 68% /opt/oracle/oradata
[root@ndb etc]#
[root@ndb bdump]# fdisk -l
Disk /dev/sda: 137.4 GB, 137438953472 bytes
255 heads, 63 sectors/track, 16709 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 16709 134110620 8e Linux LVM
Disk /dev/sdb: 137.4 GB, 137438953472 bytes
255 heads, 63 sectors/track, 16709 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 12000 96389999+ 8e Linux LVM
/dev/sdb2 12001 16709 37825042+ 8e Linux LVM
Disk /dev/sdc: 171.3 GB, 171375067136 bytes
255 heads, 63 sectors/track, 20835 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 20500 164666218+ 83 Linux
[root@ndb bdump]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 VolGroup00 lvm2 a- 127.88G 0
/dev/sdb2 VolGroup00 lvm2 a- 36.06G 31.16G
[root@ndb bdump]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
[root@ndb bdump]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 VolGroup00 lvm2 a- 127.88G 0
/dev/sdb1 lvm2 a- 91.92G 91.92G
/dev/sdb2 VolGroup00 lvm2 a- 36.06G 31.16G
[root@ndb bdump]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
LogVol00 VolGroup00 -wi-ao 130.78G
LogVol01 VolGroup00 -wi-ao 2.00G
[root@ndb bdump]# lvcreate -L 30G -n lv_oracle VolGroup00
Logical volume "lv_oracle" created
[root@ndb bdump]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 VolGroup00 lvm2 a- 127.88G 0
/dev/sdb1 lvm2 a- 91.92G 91.92G
/dev/sdb2 VolGroup00 lvm2 a- 36.06G 1.16G
[root@ndb bdump]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
LogVol00 VolGroup00 -wi-ao 130.78G
LogVol01 VolGroup00 -wi-ao 2.00G
lv_oracle VolGroup00 -wi-a- 30.00G
[root@ndb bdump]# cd /
[root@ndb /]# mkdir oracle
[root@ndb /]# mount lv_oracle /oracle
mount: special device lv_oracle does not exist
[root@ndb /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
127G 93G 28G 78% /
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 506M 0 506M 0% /dev/shm
/dev/sdc1 155G 100G 48G 68% /opt/oracle/oradata
[root@ndb /]# cd /dev/mapper
[root@ndb mapper]# ls
control VolGroup00-LogVol00 VolGroup00-LogVol01 VolGroup00-lv_oracle
[root@ndb mapper]# mount /dev/mapper/VolGroup00-lv_oracle /oralce
mount: mount point /oralce does not exist
[root@ndb mapper]# mount /dev/mapper/VolGroup00-lv_oracle /oracle
mount: you must specify the filesystem type
[root@ndb mapper]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
127G 93G 28G 78% /
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 506M 0 506M 0% /dev/shm
/dev/sdc1 155G 100G 48G 68% /opt/oracle/oradata
[root@ndb mapper]# mkfs.ext4 /dev/mapper/VolGroup00-lv_oracle
-bash: mkfs.ext4: command not found
[root@ndb mapper]# mkfs.ext3 /dev/mapper/VolGroup00-lv_oracle
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
3932160 inodes, 7864320 blocks
393216 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
240 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@ndb mapper]# mount /dev/mapper/VolGroup00-lv_oracle /oracle
[root@ndb mapper]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
127G 93G 28G 78% /
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 506M 0 506M 0% /dev/shm
/dev/sdc1 155G 100G 48G 68% /opt/oracle/oradata
/dev/mapper/VolGroup00-lv_oracle
30G 173M 28G 1% /oracle
[root@ndb mapper]#
[root@ndb mapper]# vgs
VG #PV #LV #SN Attr VSize VFree
VolGroup00 2 3 0 wz--n- 163.94G 1.16G
[root@ndb mapper]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 VolGroup00 lvm2 a- 127.88G 0
/dev/sdb1 lvm2 a- 91.92G 91.92G
/dev/sdb2 VolGroup00 lvm2 a- 36.06G 1.16G
[root@ndb mapper]# vgcreate test_vg /dev/sdb1
Volume group "test_vg" successfully created
[root@ndb mapper]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 VolGroup00 lvm2 a- 127.88G 0
/dev/sdb1 test_vg lvm2 a- 91.92G 91.92G
/dev/sdb2 VolGroup00 lvm2 a- 36.06G 1.16G
[root@ndb mapper]# vgs
VG #PV #LV #SN Attr VSize VFree
VolGroup00 2 3 0 wz--n- 163.94G 1.16G
test_vg 1 0 0 wz--n- 91.92G 91.92G
[root@ndb mapper]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
LogVol00 VolGroup00 -wi-ao 130.78G
LogVol01 VolGroup00 -wi-ao 2.00G
lv_oracle VolGroup00 -wi-ao 30.00G
[root@ndb mapper]# lvcreate -L 50G lv_test test_vg
Volume group "lv_test" not found
[root@ndb mapper]# lvcreate -L 50G test_vg lv_test
Physical Volume "lv_test" not found in Volume Group "test_vg"
[root@ndb mapper]# lvcreate -L 50G test_vg
Logical volume "lvol0" created
[root@ndb mapper]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
LogVol00 VolGroup00 -wi-ao 130.78G
LogVol01 VolGroup00 -wi-ao 2.00G
lv_oracle VolGroup00 -wi-ao 30.00G
lvol0 test_vg -wi-a- 50.00G
[root@ndb mapper]# lvcreate -L 50G -n lv_test test_vg
Insufficient free extents (10732) in volume group test_vg: 12800 required
[root@ndb mapper]# lvcreate -L 40G -n lv_test test_vg
Logical volume "lv_test" created
[root@ndb mapper]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
LogVol00 VolGroup00 -wi-ao 130.78G
LogVol01 VolGroup00 -wi-ao 2.00G
lv_oracle VolGroup00 -wi-ao 30.00G
lv_test test_vg -wi-a- 40.00G
lvol0 test_vg -wi-a- 50.00G
[root@ndb mapper]# vgs
VG #PV #LV #SN Attr VSize VFree
VolGroup00 2 3 0 wz--n- 163.94G 1.16G
test_vg 1 2 0 wz--n- 91.92G 1.92G
[root@ndb mapper]# mkfs.ext3 /dev/mapper/test_vg-lv_test
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
5242880 inodes, 10485760 blocks
524288 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
320 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@ndb mapper]# cd /
[root@ndb /]# mkdir test
[root@ndb /]# mount /dev/mapper/test_vg-lv_test /test
[root@ndb /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
127G 93G 28G 78% /
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 506M 0 506M 0% /dev/shm
/dev/sdc1 155G 100G 48G 68% /opt/oracle/oradata
/dev/mapper/VolGroup00-lv_oracle
30G 173M 28G 1% /oracle
/dev/mapper/test_vg-lv_test
40G 177M 38G 1% /test
[root@ndb /]#
关于如何理解linux中的lvm就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。
当前标题:如何理解linux中的lvm
URL标题:http://myzitong.com/article/ghcgjj.html