Difference between revisions of "SYA710 Lab01"
(→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 / | + | <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 | + | 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 | + | <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
Contents
SYA710 Lab #1
Focus: Working With File Systems
PART A (Container is a file):
Perform the following steps:
- Power on your PC and boot up Fedora 8 Test and login as 'joker' with password 'seneca99'.
- Open a console window and switch to superuser with this command:
su -
- 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
- Use the losetup command to associate your file with /dev/loop0
like this:
losetup /dev/loop0 fakedisk
- Now create a file system in the container:
mkfs -t ext2 /dev/loop0
- Make a directory to be a mount point for the file system:
mkdir /mnt1
- Mount the file system:
mount /dev/loop0 /mnt1
- Record the output of the following command:
df -Thi /dev/loop0
- Unmount the file system
umount /mnt1
- Delete the loop device
losetup -d /dev/loop0
- Delete the fakedisk file using the rm command.
- Answer the questions 1 to 4 in PART D.
PART B (Container is a partition):
Reboot the system and perform the following steps:
- Use fdisk to make primary partition #4 of about 1GB size.
- Inform the kernel of the change in the partition table with the
command:
partprobe
- Make an ext3 file system in the new partition:
mkfs -t ext3 /dev/sda4
- Make a new directory (mkdir /mnt1) and mount the file system onto it like this
mount /dev/sda4 /mnt1
- Now copy the contents of your /home directory to this new file
system like this:
cp -a /home/* /mnt1
- Add the following line for your /etc/fstab file
/dev/sda4 /home ext3 defaults 1 3
- Unmount /mnt1
- Close the console window and logout of joker.
- Login as root and open a console window.
- Enter the command
mount -a
- Enter the 'df -Thi' command to verify that /dev/sda4 is mounted as /home.
- Close the console window and logout.
- Login as joker, open a console window and use the df command to verify that /dev/sda4 is mounted at /home.
- Answer questions 5 through 11 in PART D.
umount /mnt1
PART C (Container is a logical volume):
Reboot the system and perform the following steps:
- Login to your Fedora 8 Test system as root.
- 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.
- 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
- When you are done with partitioning with fdisk, use the partprobe command to inform Linux of your changes.
- Now initialize the two unused partitions so they will be
avialable to LVM.
pvcreate /dev/sda5 /dev/sda6
- Create a volume group with the name of 'seneca' and put physical
volume /dev/sda5 into it.
vgcreate seneca /dev/sda5
- Run the 'vgscan' command to verify the previous step worked.
- Now create a logical volume with name 'home' and a size of 500MB.
lvcreate -n home --size 500M seneca
- 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.
- Format this logical partition as ext3 type.
mkfs.ext3 /dev/seneca/home
- We'll now mount this file system on empty directory /mnt.
mount /dev/seneca/home /mnt
- Use the 'df -Ti' command to verify the mount was successful. Save
the output, you'll need it for PART D.
- Now use the 'e2label' command to give this partition a label
named 'myhome' like
this
e2label /dev/seneca/home myhome
- Verify the labeling worked with the command
e2label /dev/seneca/home
- Use the 'lvdisplay' command to view your logical volume.
- Now move your old /home contents to your new logical volume.
mv /home/* /mnt
- 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
- Unmount /mnt and then remount all file systems listed in
/etc/fstab with the command
mount -a
- Again record the output of the 'df -Ti' command which you will
need for PART D.
- 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.
- As joker open a BASH shell and switch to root with the command
su -
- 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
- 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
- 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
- Once again record the output of the 'df -Ti' command.
PART D: (Questions)
Answer the following questions and email them to your teacher.
- What is your full name?
- What is the exact size (in bytes) of the fakedisk file you created in PART A?
- What is the exact output of the command used in question 8 in PART A?
- How many total inodes are there in the file system you created in
PART A?
- What is the exact output of the command used in question 11 in PARTB?
- How many inodes are there in the file system you created in PART B?
- What is the purpose of the e2label command?
- 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?
- List the steps needed to perform a file system check on the file system you created in PART B.
- 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.
- What command would you use to set the maximum mount count of the
file system in PART B to 100? Give the full command.
- 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.