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:
- 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
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:
- Mount the file system:
mount /dev/loop0 /mnt1
- Record the output of the following command:
df -Thi /dev/loop0
- Unmount the file system
- 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
- 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
- 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.
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:
- 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.
- 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
e2label /dev/seneca/home myhome
- Verify the labeling worked with the command
- 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
- 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
- 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
- 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
- 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.