0% found this document useful (0 votes)
96 views

06-Mounting and Unmounting Filesystems

The document discusses mounting and unmounting filesystems in Linux. It describes the Linux directory hierarchy and how absolute and relative paths work. It provides details on common directories in the hierarchy and how filesystems from different partitions or devices can be mounted at directories to form a unified view. It also covers mounting options, UUID, filesystem quotas, and common commands for mounting, unmounting, and managing quotas like mount, umount, quota, and edquota.

Uploaded by

Traxler Csilla
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
96 views

06-Mounting and Unmounting Filesystems

The document discusses mounting and unmounting filesystems in Linux. It describes the Linux directory hierarchy and how absolute and relative paths work. It provides details on common directories in the hierarchy and how filesystems from different partitions or devices can be mounted at directories to form a unified view. It also covers mounting options, UUID, filesystem quotas, and common commands for mounting, unmounting, and managing quotas like mount, umount, quota, and edquota.

Uploaded by

Traxler Csilla
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

6. Mounting and Unmounting Filesystems.

Basic Text Processing


 Not to be confused with Apple’s HFS
 A formalization of the traditional BSD filesystem
hierarchy
 Defines the main directories and their contents in
Linux
 In FHS all files and directories apear under the root
directory „/” even if they are stored on different
physical devices.
 Absolute path:
◦ /home/user/curs/fis1
 ~/curs/fis1 - also an absolute path!
◦ Starts from root ( / )
◦ Always the same, no matter what the current directory is

 Relative path:
◦ curs/fis1
◦ ../curs/fis1
◦ Relative to the current working directory
◦ Shorter, easier to write
◦ The path to the same file depends on where we are at
the moment
Directory Description
/ Primary hierarchy root and root directory of the entire file system hierarchy.
/bin/ Essential command binaries that need to be available in single user mode; for all users, e.g., cat, ls, cp.
/boot/ Boot loader files, e.g., kernels, initrd; often a separate partition
/dev/ Essential devices, e.g., /dev/null.
/etc/ Host-specific system-wide configuration files
/home/ Users' home directories, containing saved files, personal settings, etc.; normally a separate partition.
/lib/ Libraries essential for the binaries in /bin/ and /sbin/.
/media/ Mount points for removable media such as CD-ROMs (appeared in FHS-2.3).
/mnt/ Temporarily mounted filesystems.
/opt/ Optional application software packages
/proc/ Virtual filesystem documenting kernel and process status as text files, e.g., uptime, network. In Linux,
corresponds to a Procfs mount.
/root/ Home directory for the root user.
/sbin/ Essential system binaries, e.g., init, ip, mount.
/srv/ Site-specific data which is served by the system.
/tmp/ Temporary files (see also /var/tmp). Often not preserved between system reboots.
/usr/ Secondary hierarchy for read-only user data; contains the majority of (multi-)user utilities and
applications.
/var/ Variable files—files whose content is expected to continually change during normal operation of the
system—such as logs, spool files, and temporary e-mail files. Sometimes a separate partition.
 Linux directory hierarchy is usually made up of
multiple partition/devices joined under the same
root

 Separate filesystems are mounted to the parent


filesystem as a directory (or mount point) in the
unified hierarchy.
◦ Directories intended as mount points usually don't
contain files or other directories, they’re created solely
to mount a filesystem

 Typical mount points include the directories /usr,


/home, /var, and others.
 Multiple partition are mounted at boot
 Removable media may be used regularly with
recurring mount properties
 /etc/fstab keeps this options in 6 fields
Field Description
Device Partition holding the filesystem (for example /dev/sda1)
Mount point Directory on which the filesystem is to be mounted
FS type Type of filesystem
Mount options Comma-separated list of options
Dump How often to dump each filesystem. Usually set to 1 for native Linux
frequency filesystems and to 0 for others.
Pass number Used by the fsck utility when the -A option is specified (0 - never check, 1 –
for fsck check first, 2 – check after first)
 Filesystems are mounted using the mount
command manually to add other filesystems
to the filesystem hierarchy.
◦ mount [command_line_options] device

 Filesystems can be unmounted using the


umount command
◦ umount [options] device
Command-line description
option

-a Mounts all of the partitions specified in /etc/fstab


(except those with the noauto option)
-h Displays help on the mount command.
-o options Specifies mount options on the command line.
-r Mounts the filesystem as read-only.
-t fstype Specifies the filesystem type. Typically used interactively
when no entry for the mount exists in /etc/fstab.
-v Sets verbose mode.
-w Mounts the filesystem read/write mode.
Option Description
async Establishes asynchronous I/O to the mounted filesystem. The opposite is sync.
auto Enables a mount specification in /etc/fstab to be processed with the -a command-line option, as needed at
boot time. The opposite is noauto.
defaults Implies rw, suid, dev, exec, auto, nouser, and async. It is commonly found on /etc/fstab entries for ext2 and
ext3 mount points.
dev Interprets character or block special devices on the filesystem.
exec Enables the execution of programs contained on the mounted partition. The opposite is noexec.
noauto Prohibits automatic mounting with the -a option. This is usually specified for removable media.
noexec Prohibits the execution of executable programs, a potential security measure.
nosuid Disables the effect of suid or sgid bits on executable files.
nouser Forbids non-root users from mounting and unmounting the filesystem. See user and users for the opposite
effect.
ro Equivalent to specifying the command-line option -r.
rw Equivalent to specifying the command-line option -w.
suid Enables the effect of suid and sgid bits on executable files.
sync Establishes synchronous I/O to the mounted filesystem. The opposite is async.
user Allows an ordinary user to mount the filesystem but prohibits other ordinary users from unmounting it. This
is useful for removable media that an individual requires control over. See also users.
users Allows any user to mount and unmount the filesystem.
 A Universally Unique Identifier (UUID) is an identifier
standard used in software construction, standardized
by the Open Software Foundation (OSF) as part of the
Distributed Computing Environment (DCE). The intent
of UUIDs is to enable distributed systems to uniquely
identify information without significant central
coordination.
 Linux's ext2/ext3 filesystem uses UUID to identify
partitions.
 UUID can be used in /etc/fstab instead of
device name. If you move storage from one
device to another you don’t need to edit
/etc/fstab
 To probe filesystem type and read label and
uuid for /dev/sdb2 (or any other device) use
vol_id command:
◦ Ex. vol_id --uuid /dev/sdb2
 To list all UUIDs use blkid command
 The idea behind quota is that users are
forced to stay under their disk consumption
limit, taking away their ability to consume
unlimited disk space on a system.
 Quota is handled on a per user, per file
system basis.
 If there is more than one file system which a
user is expected to create files, then quota
must be set for each file system separately.
 Each filesystem has up to five types of quota
limits that can be enforced on it. These limits
are specified in disk blocks, usually 1,024
bytes each:
Limit Description
Per-user hard limit The hard limit is the maximum amount of space an individual user can have on the system. Once the user
reaches his quota limit, he won't be allowed to write files to the disk.
Per-user soft limit Each user is free to store data on the filesystem until reaching her soft limit. The soft limit implements a sort of
warning zone, instructing the user to clean up while still allowing her to work. When the amount of data exceeds
this limit but does not exceed the hard limit, a message is printed on the user's terminal, indicating that her
quota has been exceeded; however, the write operation will succeed.
Per-group hard This is the final limit set for a group by the quota system. Once this limit has been reached, none of the users
limit within that group will be allowed to write files to the disk even if the user's individual limits are not exceeded.
Per-group soft limit This limit behaves in the same way as a user's soft limit but is enforced based on group.
Grace period Once a soft limit is reached, the user or group enters the grace period . After the grace period expires, the soft
limit becomes a hard limit until enough files are deleted to eliminate the over-quota situation. The grace period
may be specified for any number of months, weeks, days, hours, minutes, or seconds. A typical value is seven
days.
 quota [-u] [options] user
 quota -g [options] group
◦ Displays quota limits on user or group. The -u option is the default. Only the superuser may use the -u flag and user to
view the limits of other users. Other users can use the -g flag and group to view only the limits of groups of which they
are members, provided that the quota.group files are readable by them.
 quotaon [options] [filesystems]
◦ Enable previously configured disk quotas on one or more filesystems
 quotaoff [options] [filesystems]
◦ Disables disk quotas on one or more filesystems.
 quotacheck [options] filesystems
◦ Examine filesystems and compile quota databases. You should run the quotacheck -a command on a regular basis
(perhaps weekly) via cron.
 edquota [-p proto-user] [options] names
◦ Modify user or group quotas. This interactive command uses a text editor to configure quota parameters for users or
groups. The vi editor is used by default unless either the EDITOR or VISUAL environment variables are set to another
editor.
 repquota [options] filesystems
◦ Used to report on the status of quotas.
 To use quotas, they must first be enabled. Quota support must also be compiled into
the kernel. After that several steps are required:
1. Set options in /etc/fstab. On the line containing the /home filesystem, add the
usrquota and grpquota options to the existing default option, like this:
• /dev/sda9 /home ext2 defaults,usrquota,grpquota 1 2
2. Create the quota.user and quota.group files at the top of the /home filesystem and set
their protection bits for root access only:
◦ # touch /home/quota.user /home/quota.group
◦ # chmod 600 /home/quota.user /home/quota.group
3. Run quotacheck to initialize the databases:
◦ # quotacheck -avug
4. Run quotaon to enable the quota system
◦ # quotaon -a
5. Add a command script to a system crontab directory (such as the directory
/etc/crontab.weekly) to execute quotacheck on a routine basis.
◦ #!/bin/bash exec
◦ /sbin/quotacheck -avug
 locate – find and lists files (if you have
permission to access them)
◦ uses a database with all the files in filesystem
◦ quicker than „find ”
◦ database must be updated periodically
 updatedb or slocate -u
 find – find and lists files
◦ slower but more accurate
◦ more flexible
 whereis - locate the binary, source, and manual
page files for a command
 which - shows the full path of (shell) commands
cat / tac - Concatenate files and print on the standard output, from
beginning to end or end to beginning, respectively
head / tail - Output the first and last part of files.
nl - Number lines of files.
wc - Print the number of lines, words, and bytes (in that order) in files.
cut - Remove sections from each line of files.
tr - Translate or delete character.
expand / unexpand - Convert tabs to spaces and space to tabs.
paste - Merge lines of files.
join - Join lines of two files on a common field.
uniq - Remove duplicate lines from a sorted file.
split - Split a file into pieces.
fmt - Simple optimal text formatter.
pr - Convert text files for printing.
sort - Sort lines of text files.
od - Dump files in octal and other formats.
 more paginates output. Most users find it easier to use "less",
but on some systems "more" has all of the features of "less".
◦ Keys:
 return - read next line
 space bar - read next screen
 q - quit
 less paginates output. The program is called "less" because of
the joke that "less is more", "less" actually has several features
which "more" lacks.
◦ Keys:
 h - read help. You might forget the other commands, but remember this one!
 j - go down one line. The down-arrow key might also work.
 k - go up one line. The up-arrow key might also work.
 d - go down one-half screen.
 u - go up one-half screen.
 f - go forward one screen.
 b - go back one screen.
 p - return to the top of the file.
 q - quit the pager.

You might also like