| | 1 | [[PageOutline]] |
| | 2 | == Working With Logical Volumes == |
| | 3 | |
| | 4 | You can increase the size of a logical volume on a virtual server without taking the server off line. If a server's drive space fills up or you simply want to increase disk size, take the following steps. |
| | 5 | |
| | 6 | === Logical Volume Manager Commands === |
| | 7 | |
| | 8 | Each virtual server uses [https://secure.wikimedia.org/wikipedia/en/wiki/Logical_Volume_Manager_%28Linux%29 LVM] to manage disk allocation. There exist both physical and logical volumes in this setup. |
| | 9 | |
| | 10 | ==== Physical Volumes ==== |
| | 11 | |
| | 12 | '''Physical volumes''' represent the 'actual' disk space being used. They feed into '''volume groups''' which represent the total allocated disk space for a given virtual server. In order to determine physical volumes and volume groups issue the command: |
| | 13 | |
| | 14 | {{{ |
| | 15 | pvs |
| | 16 | }}} |
| | 17 | |
| | 18 | You should see output that looks like this: |
| | 19 | |
| | 20 | {{{ |
| | 21 | 0 daza:~# pvs |
| | 22 | PV VG Fmt Attr PSize PFree |
| | 23 | /dev/hda2 vg_daza0 lvm2 a- 49.52G 4.14G |
| | 24 | 0 daza:~# |
| | 25 | }}} |
| | 26 | |
| | 27 | '''PV''' = Physical Volume and '''VG''' = Volume Group |
| | 28 | |
| | 29 | ==== Volume Groups ==== |
| | 30 | |
| | 31 | In order to extend a logical volume, you will need to know how much space is available in the volume group. Issue the following command: |
| | 32 | |
| | 33 | {{{ |
| | 34 | vgs |
| | 35 | }}} |
| | 36 | |
| | 37 | You should see output similar to this: |
| | 38 | |
| | 39 | {{{ |
| | 40 | 0 daza:~# vgs |
| | 41 | VG #PV #LV #SN Attr VSize VFree |
| | 42 | vg_daza0 1 5 0 wz--n- 49.52G 7.14G |
| | 43 | 0 daza:~# lvs |
| | 44 | }}} |
| | 45 | |
| | 46 | Notice that VFree describes how much free space you have in the volume group. |
| | 47 | |
| | 48 | ==== Logical Volumes ==== |
| | 49 | |
| | 50 | To acquire the logical volume information do: |
| | 51 | |
| | 52 | {{{ |
| | 53 | lvs |
| | 54 | }}} |
| | 55 | |
| | 56 | The command output should look like this: |
| | 57 | |
| | 58 | {{{ |
| | 59 | 1 daza:~# lvs |
| | 60 | LV VG Attr LSize Origin Snap% Move Log Copy% Convert |
| | 61 | home.members vg_daza0 -wi-ao 35.59G |
| | 62 | root vg_daza0 -wi-ao 1.86G |
| | 63 | swap vg_daza0 -wi-ao 488.00M |
| | 64 | usr vg_daza0 -wi-ao 2.79G |
| | 65 | var vg_daza0 -wi-ao 4.66G |
| | 66 | 0 daza:~# |
| | 67 | }}} |
| | 68 | |
| | 69 | Each of the above lines represents a logical volume assigned to a volume group. In this case, we have logical volumes '''home.members''', '''root''', '''swap''', '''usr''', and '''var''', all inside the volume group '''vg_daza0'''. |
| | 70 | |
| | 71 | ==== Increasing Logical Volume Size ==== |
| | 72 | |
| | 73 | To increase the logical volume size, issue a command like this (replacing as needed the values, +3G, VOLUME_GROUP, LOGICAL_VOLUME) : |
| | 74 | |
| | 75 | {{{ |
| | 76 | lvextend --size +3G VOLUME_GROUP/LOGICAL_VOLUME |
| | 77 | }}} |
| | 78 | |
| | 79 | In order to tell the file system to fill up the extra container space we just created, we do: |
| | 80 | |
| | 81 | {{{ |
| | 82 | resize2fs /dev/mapper/VOLUME_GROUP-LOGICAL_VOLUME |
| | 83 | }}} |
| | 84 | |
| | 85 | This should resize the file system and complete the process. |
| | 86 | |
| | 87 | ==== Example: Full Log of Increasing LV size on Daza ==== |
| | 88 | {{{ |
| | 89 | 0 daza:~# pvs |
| | 90 | PV VG Fmt Attr PSize PFree |
| | 91 | /dev/hda2 vg_daza0 lvm2 a- 49.52G 7.14G |
| | 92 | 0 daza:~# vgs |
| | 93 | VG #PV #LV #SN Attr VSize VFree |
| | 94 | vg_daza0 1 5 0 wz--n- 49.52G 7.14G |
| | 95 | 0 daza:~# lvs |
| | 96 | LV VG Attr LSize Origin Snap% Move Log Copy% Convert |
| | 97 | home.members vg_daza0 -wi-ao 32.59G |
| | 98 | root vg_daza0 -wi-ao 1.86G |
| | 99 | swap vg_daza0 -wi-ao 488.00M |
| | 100 | usr vg_daza0 -wi-ao 2.79G |
| | 101 | var vg_daza0 -wi-ao 4.66G |
| | 102 | 0 daza:~# lvextend --size +3G vg_da^Gza0/home.members |
| | 103 | Extending logical volume home.members to 35.59 GB |
| | 104 | Logical volume home.members successfully resized |
| | 105 | 0 daza:~# df -h /home/members |
| | 106 | Filesystem Size Used Avail Use% Mounted on |
| | 107 | /dev/mapper/vg_daza0-home.members |
| | 108 | 33G 31G 0 100% /home/members |
| | 109 | 0 daza:~# resize2fs /dev/mapper/vg_^Gdaza0-home.members |
| | 110 | resize2fs 1.41.3 (12-Oct-2008) |
| | 111 | Filesystem at /dev/mapper/vg_daza0-home.members is mounted on /home/members; on-line resizing required |
| | 112 | old desc_blocks = 3, new_desc_blocks = 3 |
| | 113 | Performing an on-line resize of /dev/mapper/vg_daza0-home.members to 9330688 (4k) blocks. |
| | 114 | The filesystem on /dev/mapper/vg_daza0-home.members is now 9330688 blocks long. |
| | 115 | |
| | 116 | 0 daza:~# resize2fs /dev/mapper/vg_daza0-home.members df -h /home/members |
| | 117 | Filesystem Size Used Avail Use% Mounted on |
| | 118 | /dev/mapper/vg_daza0-home.members |
| | 119 | 36G 31G 2.9G 92% /home/members |
| | 120 | 0 daza:~# vgs |
| | 121 | VG #PV #LV #SN Attr VSize VFree |
| | 122 | vg_daza0 1 5 0 wz--n- 49.52G 4.14G |
| | 123 | 0 daza:~# lvs |
| | 124 | LV VG Attr LSize Origin Snap% Move Log Copy% Convert |
| | 125 | home.members vg_daza0 -wi-ao 35.59G |
| | 126 | root vg_daza0 -wi-ao 1.86G |
| | 127 | swap vg_daza0 -wi-ao 488.00M |
| | 128 | usr vg_daza0 -wi-ao 2.79G |
| | 129 | var vg_daza0 -wi-ao 4.66G |
| | 130 | 0 daza:~# w |
| | 131 | }}} |