Changes

Jump to: navigation, search

OPS235 Lab 5

429 bytes added, 07:02, 27 June 2016
no edit summary
===Part 2: Adding Additional Virtual Hard Drives===
Let's say that you have run out of disk space on your '''centos2''' VM, and you need more space on the root '''/home''' file-system in order to host more web-pages, or to support a larger database. What are your options? Getting a replacement hard-drive would probably require re-installation of the operating system and/or backing up and restoring data on the old hard disk.
Because we're using LVM we can avoid this problem. We can '''add a new <u>virtual</u> hard-drive''' (which will serve as a physical volume) to the volume group, and extend the root logical volume to make use of the new available space. Creating virtual hard drives is not only inexpensive, but a great way for students to learn now to simulate growing the size of the file system.
<li>Issue the command: <b><code><span style="color:#3366CC;font-size:1.2em;">ls /dev/vd*</span></code></b>, what has changed?</li>
<li>Use '''fdisk''' (''refer to how to use in Part 1'') to create a new single '''primary''' partition for '''/dev/vdb''' that fills the ''entire'' disk, save partition table (accepting defaults prompts would work), restart your '''centos3''' VM and then '''format''' that partition for file type: '''ext4'''.</li>
<li>Now we'll make the new device a '''physical volume''', add it to the '''volume group''', and extend by issuing the following commands:<br><b><code><span style="color:#3366CC;font-size:1.2em;">pvcreate /dev/vdb1</span></code></b> (enter '''lv_archivey'''to proceed - ignore warning)<br><b><code><span style="color:#3366CC;font-size:1.2em;">vgextend centos_centos2 /dev/vdb1</span></code></b></li> <li>Re-issue the '''ssm list''' command to see if there is any change.</li>
</ol>
:: <b><code><span style="color:#3366CC;font-size:1.2em;">pvcreate /dev/vdb1</span></code></b> (enter '''y''' to proceed - ignore warning)
:: <b><code><span style="color:#3366CC;font-size:1.2em;">vgextend cent0s_centos2 There is a problem here since we logged in as a regular user, the /devhome directory cannot be unmounted in order to extend the logical volume for centos_centos2/vdb1<home. On the other hand, we can change our run level to 1 (single-user mode) and unmount the '''/span></code></b>home''' partition.
:<ol> <li value="10">Issue the following command as root to change the run-level to 1 (single-user mode): <b><code><span style="color:#3366CC;font-size:1.2em;">lvextend -L +2G -r centos_centos2/lv_archiveinit 1</span></code></b></li>
<li>Issue the following command to unmount the /home partition: <b><code><span style="color:#3366CC;font-size:1.2em;">umount /home</span><ol/code></b></li> <li value>Issue the following command to extend the logical volume for the home file-system: <b><code><span style="10color:#3366CC;font-size:1.2em;">Now rerun the '''ls lvextend centos_centos2/home --size +2G</span></devcode></vd*''' , '''ssm list''' and '''df -h''' commands.b></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 Issue the changes, note '''ssm list''' command. Note that your root home file-system is now 2GB bigger, and you have not even rebooted your machine since you used fdisk to create a partition!</li> <li>Reduce the size of the '''lv_archive''' partition by '''1GB''' by issuing the following command:<br><b><code><span style="color:#3366CC;font-size:1.2em;">lvreduce centos_centos_2/lv_archive --size 1G</span></code></b></li>Confirm that the file system has been reduced.</li><li>Record the LVM Management commands in your lab log-book.</li>
</ol>
13,420
edits

Navigation menu