13,420
edits
Changes
no edit summary
<ol>
<li value="20">Restart the system-config-lvm utility. Do you see a new /dev/sda3 partition under Physical Volumes?</li>
<li>To add the newly created partition, you need to add it into LVM to be used. Exit the system-config-lvm utility and issue the following command to add the partition into LVM:<br><b><code><span style="color:#3366CC;font-size:1.2em;">pvcreate /dev/sda3</span></code></b>(enter '''y''' to proceed - ignore warning)</li>
<li>Restart system-config-lvm. You should notice a section at the bottom indicating Unallocated Physical Volumes. Click on that section and click on the button to add that unallocated Physical Volume to our current Volume Group. The screen should then show the partition /dev/sda3 contained in our default Volume Group.</li>
<li>Click on Logical View (i.e. above home, root, swap), and then click on '''Create New Logical Volume''' button and fill out the details for this new logical volume including: size: '''1GB''', LV Properties: '''linear''', file system: '''ext4''' file system name: '''archive''', select '''mount''' and mount it at: '''/archive'''. Have the system create the directory /archive if it does not exist.</li>
<li>Now we'll make the new device a '''physical volume''', add it to the '''volume group''', and extend '''lv_root''':</li>
</ol>
:: <b><code><span style="color:#3366CC;font-size:1.2em;">pvcreate /dev/vdbvdb1</span></code></b>(enter '''y''' to proceed - ignore warning)
:: <b><code><span style="color:#3366CC;font-size:1.2em;">vgextend vg_centos3 /dev/vdbvgs</span></code></b>(to determine: ''name_of_volumegroup'')
:: <b><code><span style="color:#3366CC;font-size:1.2em;">vgextend ''name_of_volumegroup'' /dev/vdb1</span></code></b> :: <b><code><span style="color:#3366CC;font-size:1.2em;">lvextend -L +2G -r vg_centos3''name_of_volumegroup''/lv_root</span></code></b>
{| width="40%" align="right" cellpadding="10"
|- valign="top"
|{{Admon/note|LVM Safeguards When Reducing File System Size|In older versions of LVM, the system administrator had to be careful when reducing the size of Linux file-systems using LVM. This usually required to separate operations:<ul><li>Reducing the file-system to make room (''resize2fs'')</li><li>Reduce the logical volume by using the '''lvreduce''' command</li></ul><br>This used to be performed to prevent a catastrophic loss of data if the logical volume was resize smaller than the available space on the file-system.<br>The newer LVM commands have "safeguards" (eg. option '''-r''' to prevent destroying the file-system (thus making the ''resize2fs'' command <u>obsolete</u>). '''|}}
|}
<li value="13">Now rerun the '''ls /dev/vd*''' , '''pvs''' , '''vgs''' , '''lvs''' and '''df -h''' commands.</li>
<li>Record the size of the volume group and the amount of free space. What has changed and what caused those changes?</li>
<li>Among the changes, note that your root file-system is now 2GB bigger, and you have not even rebooted your machinesince you used fdisk to create a partition!</li> <li>Reduce the size of the '''lv_root''' partition by '''1GB''' by issuing the following command:<br><b><code><span style="color:#3366CC;font-size:1.2em;">lvreduce vg_centos''name_of_volumegroup''/lv_root root --size -1G</span></code></b></li>Confirm that the file system has been reduced.</li><li>Increase the size of the '''lv_root''' partition by another '''1GB''' by issuing the command:<br><b><code><span style="color:#3366CC;font-size:1.2em;">lvextend vg_centos''name_of_volumegroup''/lv_root root --size +1G</span></code></b></li><Confirm that the file system can been increased.</li><li>Record the LVM Management commands in your lab log-book.</li>
</ol>