Lvm: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
Create partition. | ==Create partition.== | ||
fdisk /dev/sda1 | fdisk /dev/sda1 | ||
Create physiscal volume. | ==Create physiscal volume.== | ||
pvcreate /dev/sda3 | pvcreate /dev/sda3 | ||
pvdisplay | pvdisplay | ||
Create volume group. | ==Create volume group.== | ||
vgcreate VolGroup00 /dev/sda1 | vgcreate VolGroup00 /dev/sda1 | ||
vgdisplay | vgdisplay | ||
Create logical volume. Create a logic volume spanning 3 disks, each stripe 256kb, 1,5TB, called home, in Volume Group 00 | ==Create logical volume. Create a logic volume spanning 3 disks, each stripe 256kb, 1,5TB, called home, in Volume Group 00== | ||
The logical volume is being created under /dev/VolGroup00/LogVol00 | The logical volume is being created under /dev/VolGroup00/LogVol00 | ||
lvcreate i3 -I 256 L1500000 -n LOgVol00 VolGroup00 | lvcreate i3 -I 256 L1500000 -n LOgVol00 VolGroup00 | ||
Line 16: | Line 16: | ||
lvdisplay | lvdisplay | ||
Format logical volume. | ==Format logical volume.== | ||
mkfs.reiserfs /dev/VolGroup00/LogVol02 | mkfs.reiserfs /dev/VolGroup00/LogVol02 | ||
Extend a resizerfs logical volume. | ==Extend a resizerfs logical volume.== | ||
lvextend -L+70G /dev/VolGroup00/LogVol00 | lvextend -L+70G /dev/VolGroup00/LogVol00 | ||
resize_reiserfs -f /dev/VolGroup00/LogVol00 | resize_reiserfs -f /dev/VolGroup00/LogVol00 | ||
==Extent a ext3 partition.== | |||
lvextend -L +6g /dev/vgroot/root.fs | |||
resize2fs /dev/vgroot/root.fs | |||
==Shrink ext2/3 partition.== | |||
umount /data # umount /data | umount /data # umount /data | ||
resize2fs /dev/VolGroup00/LogVol00 10G # Resize file system to 10GB. | resize2fs /dev/VolGroup00/LogVol00 10G # Resize file system to 10GB. | ||
Line 31: | Line 34: | ||
mount /data # mount /data | mount /data # mount /data | ||
Shrink reizerfs volume. (not tested yet) | ==Shrink reizerfs volume. (not tested yet)== | ||
umount /data # unmount /data | umount /data # unmount /data | ||
resize_reiserfs -s 10G /dev/VolGroup00/LogVol00 # Resize file system to 10GB. | resize_reiserfs -s 10G /dev/VolGroup00/LogVol00 # Resize file system to 10GB. | ||
Line 40: | Line 43: | ||
lvreduce -L-150M /dev/VolGroup00/LogVol00 | lvreduce -L-150M /dev/VolGroup00/LogVol00 | ||
Create device-mapper in /proc/misc | ==Create device-mapper in /proc/misc== | ||
modprobe dm-mod | modprobe dm-mod | ||
Activate Volume Group. | ==Activate Volume Group.== | ||
lvm vgchange -a y VolGroup00 | lvm vgchange -a y VolGroup00 | ||
Create a snapshot volume. | ==Create a snapshot volume.== | ||
modprobe dm-snapshot | modprobe dm-snapshot | ||
lvcreate --snapshot --size 128M --name LogVol02snap /dev/VolGroup00/LogVol02 | lvcreate --snapshot --size 128M --name LogVol02snap /dev/VolGroup00/LogVol02 | ||
Create device maps from partition tables | ==Create device maps from partition tables== | ||
kpartx -av /dev/VolGroup00/LogVol02 | kpartx -av /dev/VolGroup00/LogVol02 | ||
Copy logical volume. | ==Copy logical volume.== | ||
dd if=/dev/VolGroup00/LogVol02 of=/dev/VolGroup00/LogVol03 bs=64M | dd if=/dev/VolGroup00/LogVol02 of=/dev/VolGroup00/LogVol03 bs=64M | ||
Extend logical volume with disk. | ==Extend logical volume with disk.== | ||
vgextend vgroot /dev/sdb | vgextend vgroot /dev/sdb | ||
Check for Free PE / Size. First we need to enlarge the logical volume. | ==Check for Free PE / Size. First we need to enlarge the logical volume.== | ||
vgdisplay | vgdisplay | ||
Now we enlarged the volume but not the filesystem. | ==Now we enlarged the volume but not the filesystem.== | ||
lvextend -l +<number of extents> /dev/<volume group>/<logical volume> | lvextend -l +<number of extents> /dev/<volume group>/<logical volume> | ||
This will grow the filesystem on-line. | ==This will grow the filesystem on-line.== | ||
resize2fs /dev/<volume group>/<logical volume> | resize2fs /dev/<volume group>/<logical volume> | ||
When extending partition by deleting and adding partition. | ==When extending partition by deleting and adding partition.== | ||
pvchange -x /dec/sda | pvchange -x /dec/sda | ||
[[Category:Applications]] | [[Category:Applications]] | ||
[[Category:Unix]] | [[Category:Unix]] | ||
[[Category:Storage]] | [[Category:Storage]] |
Revision as of 09:10, 8 October 2009
Create partition.
fdisk /dev/sda1
Create physiscal volume.
pvcreate /dev/sda3 pvdisplay
Create volume group.
vgcreate VolGroup00 /dev/sda1 vgdisplay
Create logical volume. Create a logic volume spanning 3 disks, each stripe 256kb, 1,5TB, called home, in Volume Group 00
The logical volume is being created under /dev/VolGroup00/LogVol00
lvcreate i3 -I 256 L1500000 -n LOgVol00 VolGroup00 lvcreate -L 5.12G -n LogVol02 VolGroup00 # Create logical volume of 5.12G on Volume group VolGroup00. lvdisplay
Format logical volume.
mkfs.reiserfs /dev/VolGroup00/LogVol02
Extend a resizerfs logical volume.
lvextend -L+70G /dev/VolGroup00/LogVol00 resize_reiserfs -f /dev/VolGroup00/LogVol00
Extent a ext3 partition.
lvextend -L +6g /dev/vgroot/root.fs resize2fs /dev/vgroot/root.fs
Shrink ext2/3 partition.
umount /data # umount /data resize2fs /dev/VolGroup00/LogVol00 10G # Resize file system to 10GB. lvreduce -L 10G /dev/VolGroup00/LogVol00 # Resize logical volume to 1GB. e2fsck -f /dev/VolGroup00/LogVol00 # Check filesystem. mount /data # mount /data
Shrink reizerfs volume. (not tested yet)
umount /data # unmount /data resize_reiserfs -s 10G /dev/VolGroup00/LogVol00 # Resize file system to 10GB. lvreduce -L 10G /dev/VolGroup00/LogVol00 # Resize logical volume to 1GB. mount -t reiserfs /data
resize_reiserfs -s-150M /dev/VolGroup/LogVol00 lvreduce -L-150M /dev/VolGroup00/LogVol00
Create device-mapper in /proc/misc
modprobe dm-mod
Activate Volume Group.
lvm vgchange -a y VolGroup00
Create a snapshot volume.
modprobe dm-snapshot lvcreate --snapshot --size 128M --name LogVol02snap /dev/VolGroup00/LogVol02
Create device maps from partition tables
kpartx -av /dev/VolGroup00/LogVol02
Copy logical volume.
dd if=/dev/VolGroup00/LogVol02 of=/dev/VolGroup00/LogVol03 bs=64M
Extend logical volume with disk.
vgextend vgroot /dev/sdb
Check for Free PE / Size. First we need to enlarge the logical volume.
vgdisplay
Now we enlarged the volume but not the filesystem.
lvextend -l +<number of extents> /dev/<volume group>/<logical volume>
This will grow the filesystem on-line.
resize2fs /dev/<volume group>/<logical volume>
When extending partition by deleting and adding partition.
pvchange -x /dec/sda