LVM PDF
LVM PDF
LVM PDF
php/LVM
LVM
De Deister KB
The notion that a partition was a sequential series of blocks on a physical disc has since evolved. Most Unix-like systems now have the ability
to break up physical discs into some number of units. Storage units from multiple drives can be pooled into a "logical volume", where they
can be allocated to partitions. Additionally, units can be added or removed from partitions as space requirements change.
For example, say that you have a 1GB disc and you create the "/home" partition using 600MB. Imagine that you run out of space and decide
that you need 1GB in "/home". Using the old notion of partitions, you'd have to have another drive at least 1GB in size. You could then add
the disc, create a new /home, and copy the existing data over.
However, with an LVM setup, you could simply add a 400MB (or larger) disc, and add it's storage units to the "/home" partition. Other tools
allow you to resize an existing file-system, so you simply resize it to take advantage of the larger partition size and you're back in business.
Contenido
1 Linux distributions administration tools
2 Basic principles
2.1 The physical media
2.2 Physical Volume (PV)
2.3 Physical Extents (PE)
2.4 Volume Group
2.5 Logical Volume (LV)
2.6 Filesystem
3 Show and Tell
4 Growing your filesystem
4.1 With e2fsadm
4.2 Growing your Logical Volume
4.3 Growing your Volume Group
4.4 Growing your filesystem
5 Informix Dbspaces creation script
6 Correspondencia entre /dev/dm y el logical volumen
Basic principles
LVM comes with a lot of jargon which you should understand lest you endanger your filesystems.
You should take the word 'physical' with a grain of salt, though we will initially assume it to be a simple hard disk, or a partition. Examples,
/dev/hda, /dev/hda6, /dev/sda. You can turn any consecutive number of blocks on a block device into a ...
A PV is nothing more than a physical medium with some administrative data added to it - once you have added this, LVM will recognise it as
a holder of ...
1 de 6 21/06/2018 14:15
LVM - Deister KB http://kb.deister.net/index.php/LVM
Physical Extents are like really big blocks, often with a size of megabytes. PEs can be assigned to a...
Volume Group
A VG is made up of a number of Physical Extents (which may have come from multiple Physical Volumes or hard drives). While it may be
tempting to think of a VG as being made up of several hard drives (/dev/hda and /dev/sda for example), it's more accurate to say that it
contains PEs which are provided by these hard drives.
Yes, we're finally getting somewhere. A Logical Volume is the end result of our work, and it's there that we store our information. This is
equivalent to the historic idea of partitions.
As with a regular partition, on this Logical Volume you would typically build a ...
Filesystem
This filesystem is whatever you want it to be: the standard ext2, ReiserFS, NWFS, XFS, JFX, NTFS, etc... To the linux kernel, there is no
difference between a regular partition and a Logical Volume.
You should first set the partition types of /dev/hda3 and /dev/hdb2 to 0x8e, which is 'Linux LVM'. Please note that your version of fdisk may
not yet know this type, so it will be listed as 'Unknown':
# fdisk /dev/hda
We do the same for /dev/hdb2, but we don't display it here. This is needed so that LVM is able to reconstruct things should you lose your
configuration.
Now, this shouldn't be necessary, but some computers require a reboot at this point. So if the following examples don't work, try rebooting.
# pvcreate /dev/hda3
2 de 6 21/06/2018 14:15
LVM - Deister KB http://kb.deister.net/index.php/LVM
# vgdisplay -v test
--- Volume group ---
VG Name test
VG Access read/write
VG Status available/resizable
VG # 0
MAX LV 256
Cur LV 0
Open LV 0
MAX LV Size 255.99 GB
Max PV 256
Cur PV 2
Act PV 2
VG Size 184 MB
PE Size 4 MB
Total PE 46
Alloc PE / Size 0 / 0
Free PE / Size 46 / 184 MB
Lots of data here - most of it should be understandable by now. We see that there are no Logical Volumes defined, so we should work to
remedy that. We try to generate a 50 megabyte volume called 'HOWTO' in the Volume Group 'test':
# mke2fs /dev/test/HOWTO
mke2fs 1.18, 11-Nov-1999 for EXT2 FS 0.5b, 95/08/09
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
13328 inodes, 53248 blocks
2662 blocks (5.00%) reserved for the super user
First data block=1
7 block groups
8192 blocks per group, 8192 fragments per group
1904 inodes per group
Superblock backups stored on blocks:
3 de 6 21/06/2018 14:15
LVM - Deister KB http://kb.deister.net/index.php/LVM
And we're done! Let's review our Volume Group, because it should be filled up a bit by now:
# vgdisplay test -v
--- Volume group ---
VG Name test
VG Access read/write
VG Status available/resizable
VG # 0
MAX LV 256
Cur LV 1
Open LV 1
MAX LV Size 255.99 GB
Max PV 256
Cur PV 2
Act PV 2
VG Size 184 MB
PE Size 4 MB
Total PE 46
Alloc PE / Size 13 / 52 MB
Free PE / Size 33 / 132 MB
Well, it is. /dev/hda3 is completely unused, but /dev/hdb2 has 13 Physical Extents in use.
With e2fsadm
If there is room within your volume group, and you use the ext2 filesystem (most people do), you can use this handy tool.
The e2fsadm command uses the commercial resize2fs tool. While people feel that this is good software, it is not very widely installed.
If you want to use the FSF's ext2resize command, you need to inform e2fsadm of this:
# export E2FSADM_RESIZE_CMD=ext2resize
# export E2FSADM_RESIZE_OPTS=""
4 de 6 21/06/2018 14:15
LVM - Deister KB http://kb.deister.net/index.php/LVM
The rest is easy, e2fsadm is a lot like the other LVM commands:
ext2_resize_fs
ext2_grow_fs
ext2_block_relocate
ext2_block_relocate_grow
ext2_grow_group
ext2_add_group
ext2_add_group
ext2_add_group
ext2_add_group
ext2_add_group
ext2_add_group
direct hits 4096 indirect hits 0 misses 1
e2fsadm -- ext2fs in logical volume "/dev/test/HOWTO" successfully extended to 104 MB
If you have room within your Volume Group, this is a one liner:
This is done with the vgextend utility, and is easy as pie. You first need to create a physical volume. This is done with the pvcreate utility.
With this tool, you convert any block device into a physical volume.
# pvcreate /dev/sda1
pvcreate -- physical volume "/dev/sda1" successfully created
# vgextend webgroup /dev/sda1
vgextend -- INFO: maximum logical volume size is 255.99 Gigabyte
vgextend -- doing automatic backup of volume group "webgroup"
vgextend -- volume group "webgroup" successfully extended
Please note that in order to do this, your Volume Group needs to be active. You can make it by executing 'vgchange -a y webgroup'.
By off-line, we mean that you have to unmount the file-system to make these changes. The file-system and it's data will be unavailable while
doing this. Note this means you must use other boot media if extending the size of the root or other important partitions.
The ext2resize tool is available on the GNU ftp size, but most distributions carry it as a package. The syntax is very straightforward:
5 de 6 21/06/2018 14:15
LVM - Deister KB http://kb.deister.net/index.php/LVM
Where 40000 is the number of blocks the filesystem should have after growing or shrinking.
pvcreate /dev/scsi/host0/bus0/target1/lun0/part1
vgcreate ifmx /dev/scsi/host0/bus0/target1/lun0/part1
vgdisplay -v ifmx
lvcreate --contiguous y -L 2000M -n rootdbs ifmx
lvcreate --contiguous y -L 2000M -n wic_dat_00 ifmx
lvcreate --contiguous y -L 2000M -n blobdbs_00 ifmx
lvcreate --contiguous y -L 2000M -n sb_dbs_00 ifmx
lvcreate --contiguous y -L 2000M -n tmp_dbs_00 ifmx
lvcreate --contiguous y -L 2000M -n aux_dat_00 ifmx
lvcreate --contiguous y -L 2000M -n aux_dat_01 ifmx
lvcreate --contiguous y -L 2000M -n aux_dat_02 ifmx
lvcreate --contiguous y -L 2000M -n aux_idx_00 ifmx
lvcreate --contiguous y -L 2000M -n aux_idx_01 ifmx
Obtenido de «http://kb.deister.net/index.php?title=LVM&oldid=4231»
Esta página fue modificada por última vez el 9 nov 2012, a las 17:01.
Esta página ha sido visitada 14.136 veces.
Política de protección de datos
Acerca de Deister KB
Aviso legal
6 de 6 21/06/2018 14:15