0% found this document useful (0 votes)
1 views4 pages

Cis 191 Lab 7

Lab 7 focuses on exploring the EXT filesystem in Linux, specifically creating and managing file systems, modifying inode information, and implementing disk quotas. The lab requires students to move user home directories to a separate file system, configure it, and set up disk quotas for users. Students must complete various tasks including partitioning, formatting, mounting, and ensuring proper quota settings, with a final submission of their work for grading.

Uploaded by

kellermonika001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views4 pages

Cis 191 Lab 7

Lab 7 focuses on exploring the EXT filesystem in Linux, specifically creating and managing file systems, modifying inode information, and implementing disk quotas. The lab requires students to move user home directories to a separate file system, configure it, and set up disk quotas for users. Students must complete various tasks including partitioning, formatting, mounting, and ensuring proper quota settings, with a final submission of their work for grading.

Uploaded by

kellermonika001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

CIS 191 Linux Lab Exercise

Lab 7: File Systems


Fall 2008

Lab 7: File Systems

The purpose of this lab is to explore the structure of the EXT filesystem used throughout
most Linux Distributions. We will run commands that allow you to create file systems
configure the superblock, modify inode information, perform file system checks, and
implement disk quotas.

The objective of this lab is to move the home directories of users from the root file system
to a separate file system where we can implement disk quotas.

Supplies
• VMWare Server 1.05 or higher
• Benji VM or CentOS 5 ISO

Preconfiguration

• Benji should have the users configured in Lab 6.


• Initial partitions on Benji

Location Type Boot Code Type Mount Size


MBR
/dev/sda1 Primary GRUB ext3 / 3000 MB
/dev/sda2 Primary swap 512 MB
/dev/sda3 Primary ext3 /var 500 MB
/dev/sda4 Extended
/dev/sda5 Logical ext3 /opt 300 MB
/dev/sda6 Logical ext3 50 MB

Forum

If you get stuck on one of the steps below don’t beat your head against the wall.
Use the forum to ask for assistance or post any valuable tips and hints once you
have finished. Forum is at: http://simms-teach.com/forum/viewforum.php?f=13

Background
File systems are storage structures that allow the computer system to maintain the integrity
and whereabouts of large numbers of different files in a quick and secure manner.

Regardless of the type of file system, UNIX/Linux file systems treat files as having three
distinct components:

1. filenames - which are kept in special files called directories


2. inode - a block of data that keeps information about the file e.g. permissions,
ownership, size and location of the contents of the file.
3. data - the actual contents of the file are stored in blocks of data that are allocated in
clusters ranging from 1K to 32K or more in size. These clusters do not necessarily
have to be contiguous on the hard disk.

Part I: Creating a File system

Typically, file systems are used to format partitions of a hard disk, floppy or CD-ROM. In
this section, we are going to add and format a logical partition on the hard disk.

1. Log on as root and use the fdisk command to add a new 200 MB logical partition
(/dev/sda7) to your hard drive.
2. Use the fdisk –l command to verify that the new /dev/sda7 partition has been
created. If you made a partition that is larger than 200MB, delete it and make it
again.
3. Format this partition with an ext3 file system that contains 800 inodes:
mkfs -t ext3 -N 800 /dev/sda7
4. Before we mount the file system, lets look at the superblock structure:
dumpe2fs /dev/sda7 | more
Note the following fields:
o Filesystem volume name
o Filesystem state
o Inode count
o Block count
o Block size
o Maximum mount count

Do you understand the kind of information that's kept in the Superblock?

5. Let's configure some of these fields with some file system commands:
e2label /dev/sda7 /home # adds a volume name
tune2fs -c 24 /dev/sda7 # changes maximum mount count
6. Check your modifications using the dumpe2fs command.

Part II: Mounting and Populating a File System

File systems are controlled by device drivers, and therefore are treated as devices.
To make the files within a file system available to users, the file system device must be
mounted to a directory of an already-mounted file system (usually root).

1. Now mount your new filesystem:


mount /dev/sda7 /mnt
2. List the current contents of your filesystem by listing the contents of the /mnt
directory. What is there? Anything?
3. Note that the mkfs command made a fairly large, but empty, directory called
lost+found in your file system. This directory is used by fsck to store recovered
files when fixing file system corruption. What is the inode of the lost+found
directory? What is the inode of the mntpoint, (/mnt)? directory?
ls -ai /mnt
Note: mount point directories are always given inode number 2. (0 and 1 are
reserved and never used as regular inodes.)
4. Now populate your new fileystem with all the home directories of your users.
Here is a cool command for doing that, but it requires that you are in the /mnt
directory:
cd /mnt
(cd /home; tar cvf - . ) | tar xvf -
We have just copied all the subdirectories from the root filesystem to your file
system. Enclosing one or more commands in () runs them in a sub-shell. In this
case we only want the cd to /home to be temporary. The – is used to pipe stdout to
other commands. In this case the – is used to pipe the tar file created by the first
tar command to be used for extraction by the second tar command. See the –
section in http://tldp.org/LDP/abs/html/special-chars.html for more details.
5. List the contents of your filesystem with inode numbers:
ls -i
6. Change directory to / and unmount your file system.
7. Check the integrity of your new file system using the following command:
fsck -f /dev/sda7
The -f option forces the check even though the filesystem was unmounted cleanly.

Part III: Setting up disk quotas

In this procedure we will setup disk quotas for our users.


Disk quotas are setup on a per file system basis. Quotas may be set for individual user
accounts and/or groups. We are going to setup quotas for user accounts in the file system
that we just created.

1. As root, mount your new file system to the /home mount point with the following
command:
mount -o usrquota /dev/sda7 /home
What would you do if you wanted this file system mounted like this every time you
booted the system?
2. Change directory to /home and verify that all your user directories are there.
3. Analyze this file system for current disk usage:
quotacheck -cuv /dev/sda7
Notice the datafile that gets created for holding this quota information. What is its
name?
4. Now turn on user quotas on with the command:
quotaon -uv /dev/sda7
5. On another screen, log in as gimli and issue the quota command.
What does it say?
6. Go back to your root login and setup a quota for this user using the following
command:
edquota gimli
Notice the beautiful user interface! You are in vi, and you can edit the soft and hard
fields in this file. Note they are currently 0. Notice that you can set quotas on disk
space (blocks) or on number of files (inodes). Set Gimli’s soft quota to be 2MB and
his hard quota to be 2.5 MB:

Disk quotas for user gimli (uid 800):


Filesystem blocks soft hard inodes soft hard
/dev/sda7 25 2000 2500 5 0 0

7. Once you've setup the quota for gimli, test it out by logging in as gimli on another
terminal or Putty session and start using up his diskspace. Either copying files into
gimli’s home directory or use a script like the following. You should reach the limits.

> bigfile; while du; do man quota >> bigfile; done


(use several ctrl‐c’s to end)

8. To make this quota persistent across reboots, you will have to add the usrquota
keyword to the options column of the appropriate entry in /etc/fstab. Do that now.

[root@benji ~]# cat /etc/fstab


LABEL=/1 / ext3 defaults 1 1
devpts /dev/pts devpts gid=5,mode=620 0 0
tmpfs /dev/shm tmpfs defaults 0 0
LABEL=/opt /opt ext3 defaults 1 2
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
LABEL=/var /var ext3 defaults 1 2
LABEL=SWAP-sda2 swap swap defaults 0 0
LABEL=/home /home ext3 usrquota,defaults 1 2
[root@benji ~]#

To Turn in

fdisk –l > lab07


mount >> lab07
cat /etc/fstab >> lab07
repquota –a >> lab07
du /home/gimli >> lab07

Review you work in lab07 before submitting to make sure you have covered each
area of the grading rubric. Then submit your work using:

scp lab07 cis191@opus.cabrillo.edu:lab07.lastname

Grading rubric (30 points)

5 points for correctly sized /dev/sda7


5 points for correctly formatting /dev/sda7
5 points for /dev/sda7 mounted as /home
5 points for /dev/sda7 mounted with usrquota option
5 points for correct /etc/fstab
5 points for correct quotas set on gimli

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy