Difference between revisions of "SYA710 Lab01"

From CDOT Wiki
Jump to: navigation, search
(PART C (Container is a logical volume):)
 
(2 intermediate revisions by 2 users not shown)
Line 65: Line 65:
 
   </li>
 
   </li>
 
   <li>Unmount /mnt1</li>
 
   <li>Unmount /mnt1</li>
<pre>      umount /mnt </pre>
+
<pre>      umount /mnt1 </pre>
 
   <li>Close the console window and logout of joker.</li>
 
   <li>Close the console window and logout of joker.</li>
 
   <li>Login as root and open a console window.</li>
 
   <li>Login as root and open a console window.</li>
Line 211: Line 211:
  
 
   <li>Again record the output of the 'df -Ti' command which you will
 
   <li>Again record the output of the 'df -Ti' command which you will
need for PART B.<br>
+
need for PART D.<br>
 
   </li>
 
   </li>
 
   <li>You should now be able to logout of root and login as joker. If
 
   <li>You should now be able to logout of root and login as joker. If
Line 245: Line 245:
 
<ol>
 
<ol>
 
</ol>
 
</ol>
 +
 
=== PART D: (Questions) ===
 
=== PART D: (Questions) ===
 
Answer the following questions and email them to your teacher.
 
Answer the following questions and email them to your teacher.
Line 258: Line 259:
 
   <li>What is the exact output of the command used in question 11 in
 
   <li>What is the exact output of the command used in question 11 in
 
PARTB?</li>
 
PARTB?</li>
   <li>How many inodes inodes are there in the file system you created
+
   <li>How many inodes are there in the file system you created
 
in PART B?</li>
 
in PART B?</li>
 
   <li>What is the purpose of the e2label command?</li>
 
   <li>What is the purpose of the e2label command?</li>

Latest revision as of 17:36, 17 September 2008

SYA710 Lab #1

Focus: Working With File Systems

PART A (Container is a file):

Perform the following steps:

  1. Power on your PC and boot up Fedora 8 Test and login as 'joker' with password 'seneca99'.
  2. Open a console window and switch to superuser with this command:
           su - 
  3. Create a regular file (filled with zeros) which will be the container for our file system. Use this command:
           dd if=/dev/zero of=fakedisk bs=1024 count=10000 
  4. Use the losetup command to associate your file with /dev/loop0 like this:
           losetup /dev/loop0 fakedisk 
  5. Now create a file system in the container:
           mkfs -t ext2 /dev/loop0 
  6. Make a directory to be a mount point for the file system:
           mkdir /mnt1 
  7. Mount the file system:
           mount /dev/loop0 /mnt1 
  8. Record the output of the following command:
           df -Thi /dev/loop0
  9. Unmount the file system
           umount /mnt1 
  10. Delete the loop device
           losetup -d /dev/loop0 
  11. Delete the fakedisk file using the rm command.
  12. Answer the questions 1 to 4 in PART D.

PART B (Container is a partition):

Reboot the system and perform the following steps:

  1. Use fdisk to make primary partition #4 of about 1GB size.
  2. Inform the kernel of the change in the partition table with the command:
           partprobe 
  3. Make an ext3 file system in the new partition:
           mkfs -t ext3 /dev/sda4
  4. Make a new directory (mkdir /mnt1) and mount the file system onto it like this
           mount /dev/sda4 /mnt1 
  5. Now copy the contents of your /home directory to this new file system like this:
           cp -a /home/* /mnt1 
  6. Add the following line for your /etc/fstab file
           /dev/sda4 	/home 	ext3 	defaults 	1 3
  7. Unmount /mnt1
  8.        umount /mnt1 
  9. Close the console window and logout of joker.
  10. Login as root and open a console window.
  11. Enter the command
           mount -a 
  12. Enter the 'df -Thi' command to verify that /dev/sda4 is mounted as /home.
  13. Close the console window and logout.
  14. Login as joker, open a console window and use the df command to verify that /dev/sda4 is mounted at /home.
  15. Answer questions 5 through 11 in PART D.

PART C (Container is a logical volume):

Reboot the system and perform the following steps:

  1. Login to your Fedora 8 Test system as root.
  2. Open a shell and use fdisk to create an extended partition of 3GB. This should be partition 4. Also create two logical partitions of sizes 1GB and 2GB respectively.
  3. So this is what your partition table should look like:

    Device
    Size
    Type
    /dev/sda1
    400M
    /boot
    /dev/sda2
    5G
    /
    /dev/sda3
    500M
    swap
    /dev/sda4
    3G
    Extended
    /dev/sda5
    1G
    Unused
    /dev/sda6
    2G
    Unused

  4. When you are done with partitioning with fdisk, use the partprobe command to inform Linux of your changes.
  5. Now initialize the two unused partitions so they will be avialable to LVM.
    	pvcreate /dev/sda5 /dev/sda6
  6. Create a volume group with the name of 'seneca' and put physical volume /dev/sda5 into it.
    	vgcreate seneca /dev/sda5
  7. Run the 'vgscan' command to verify the previous step worked.
  8. Now create a logical volume with name 'home' and a size of 500MB.
    	lvcreate -n home --size 500M seneca
  9. This logical volume you created can now be accessed as device '/dev/seneca/home' and can be formatted and mounted just like any other partition.
  10. Format this logical partition as ext3 type.
    	mkfs.ext3 /dev/seneca/home
  11. We'll now mount this file system on empty directory /mnt.
    	mount /dev/seneca/home /mnt
  12. Use the 'df -Ti' command to verify the mount was successful. Save the output, you'll need it for PART D.
  13. Now use the 'e2label' command to give this partition a label named 'myhome' like this
    	e2label /dev/seneca/home myhome
  14. Verify the labeling worked with the command
    	e2label /dev/seneca/home
  15. Use the 'lvdisplay' command to view your logical volume.
  16. Now move your old /home contents to your new logical volume.
    	mv /home/* /mnt
  17. In order to use your new /home directory you'll have to update your /etc/fstab file. You can do this by adding in the following line:
    	LABEL=myhome          /home                   ext3    defaults        1 3
  18. Unmount /mnt and then remount all file systems listed in /etc/fstab with the command
    	mount -a
  19. Again record the output of the 'df -Ti' command which you will need for PART D.
  20. You should now be able to logout of root and login as joker. If this was successful, you can go on to the next step, otherwise you have a problem which must be fixed first, so see your teacher or lab tutor for assistance.
  21. As joker open a BASH shell and switch to root with the command
    	su -
  22. Now we'll increase the size of our home directory by first adding the second unused partition, /dev/sda6, to the volume group like this
    	vgextend seneca /dev/sda6
  23. Ok, our volume group has two physical volumes in it and therefore is larger, so we can now expand by 1 GB our logical volume, home, with this command
    	lvextend -L+1G /dev/seneca/home
  24. So now our 'home' logical volume should be about 1.5GB. However, if you use the 'df' command you'll see that nothing has changed - the size of our home directory is still 500MB. So now we need to resize the ext3 file system to fill all the space of the logical volume. We can do this with the command
    	resize2fs /dev/seneca/home
  25. Once again record the output of the 'df -Ti' command.

PART D: (Questions)

Answer the following questions and email them to your teacher.

  1. What is your full name?
  2. What is the exact size (in bytes) of the fakedisk file you created in PART A?
  3. What is the exact output of the command used in question 8 in PART A?
  4. How many total inodes are there in the file system you created in PART A?
  5. What is the exact output of the command used in question 11 in PARTB?
  6. How many inodes are there in the file system you created in PART B?
  7. What is the purpose of the e2label command?
  8. If you added a label of /home to the file system you created in PART B, how would you change step 6 of PART B?
  9. List the steps needed to perform a file system check on the file system you created in PART B.
  10. The file system you created in PART B occupied the entire 1GB partition. List the steps you would need to do to increase the file system size to 2GB.
  11. What command would you use to set the maximum mount count of the file system in PART B to 100? Give the full command.
  12. Using LVM, explain, in your own words, how a file system can be increased and decreased. Be sure to include the commands you would use.