Linux/LVM: Difference between revisions
< Linux
No edit summary |
No edit summary |
||
(15 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== Installation == | |||
<blockquote> | <blockquote> | ||
<pre> | <pre> | ||
apt-get install lvm2 | |||
apt-get install system-config-lvm | apt-get install system-config-lvm | ||
</pre> | </pre> | ||
</blockquote> | </blockquote> | ||
== Volumes == | |||
* physical volume - pv | |||
<blockquote> | <blockquote> | ||
<pre> | <pre> | ||
pvs | |||
pvdisplay | |||
pvcreate /dev/<Partition> | |||
</pre> | </pre> | ||
</blockquote> | </blockquote> | ||
* volume group - vg | |||
<blockquote> | <blockquote> | ||
<pre> | <pre> | ||
vgs | |||
vgdisplay | |||
vgcreate <group> /dev/<Partition1> (/dev/<Partition2> /dev/<P3>...) | |||
</pre> | </pre> | ||
</blockquote> | </blockquote> | ||
* logical volume - lv | |||
<blockquote> | <blockquote> | ||
<pre> | <pre> | ||
lvs | |||
lvdisplay | |||
lvcreate -L 2G -n <volume> <group> | |||
lvextend -L 5G /dev/<group>/<volume> | |||
</pre> | </pre> | ||
</blockquote> | </blockquote> | ||
* /dev/$vg/$lv | |||
== snapshots == | |||
<blockquote> | <blockquote> | ||
<pre> | <pre> | ||
lvcreate --size 100M --snapshot --name <snapshot_name> /dev/<group>/<volume> (size = max changed size) | |||
mkdir /mnt/snapshot | |||
mount /dev/$vg/$snapshot_name /mnt/snapshot | |||
or | |||
dd if=/dev/$vg/$snapshot_name of=/mnt/backup/snapshot.img | |||
umount /mnt/snapshot | |||
lvremove /dev/$vg/$snapshot_name | |||
</pre> | </pre> | ||
</blockquote> | </blockquote> | ||
== Resize == | |||
<blockquote> | <blockquote> | ||
<pre> | <pre> | ||
lvextend -L+1000M /dev/$vg/$vol | |||
umount /lvm-test | |||
e2fsck -f /dev/$vg/$vol | |||
resize2fs /dev/$vg/$vol | |||
mount -t ext2 /dev/$vg/$vol /lvm-test | |||
</pre> | </pre> | ||
</blockquote> | </blockquote> | ||
[[Category:Linux/System]] | |||
[[Category:Linux]] |
Latest revision as of 13:58, 1 April 2017
Installation
apt-get install lvm2 apt-get install system-config-lvm
Volumes
- physical volume - pv
pvs pvdisplay pvcreate /dev/<Partition>
- volume group - vg
vgs vgdisplay vgcreate <group> /dev/<Partition1> (/dev/<Partition2> /dev/<P3>...)
- logical volume - lv
lvs lvdisplay lvcreate -L 2G -n <volume> <group> lvextend -L 5G /dev/<group>/<volume>
- /dev/$vg/$lv
snapshots
lvcreate --size 100M --snapshot --name <snapshot_name> /dev/<group>/<volume> (size = max changed size) mkdir /mnt/snapshot mount /dev/$vg/$snapshot_name /mnt/snapshot or dd if=/dev/$vg/$snapshot_name of=/mnt/backup/snapshot.img umount /mnt/snapshot lvremove /dev/$vg/$snapshot_name
Resize
lvextend -L+1000M /dev/$vg/$vol umount /lvm-test e2fsck -f /dev/$vg/$vol resize2fs /dev/$vg/$vol mount -t ext2 /dev/$vg/$vol /lvm-test