120 likes | 243 Views
Chapter 6: Linux Filesystem Administration. The /dev directory. Each device is represented as files in /dev Devices are divided into two types Character Block The first character in the long listing indicates the type of the device
E N D
The /dev directory • Each device is represented as files in /dev • Devices are divided into two types • Character • Block • The first character in the long listing indicates the type of the device • Major and minor numbers replace the size. Major for the type of the device and minor for the device itself • If a device file is corrupted or deleted you can use mknod to re-create it if you know the type, major and minor numbers. $mknod /dev/fd10 b 2 10 • Otherwise, you can use: $/dev/MAKEDEV fd0 • The file /proc/devices contains a list of used devices
File Systems • An advantage of Linux is that you can use several files systems at the same time, thus: • Each partition can have its own file system • Mounting means making the data available • A storage device can be mounted to any directory in the system • It is common to use directories under /mnt • Mounting will temporary covers up all the content of the mount point for the duration of mounting • To mount and un-mount devices, use the mount/ unmount commands • The file system table (/etc/fstab) contains various information about currently mounted devices
Floppy Disks • To format a floppy disk (i.e. creating a file system) you use the mkfs commands • mkfs takes a –t option to specify the file system type and you need to specify the device file to be used • $ mkfs –t ext3 fd4 • The default file system is ext2 • A list of variant to mkfs is given in Table 6-3 • A disk should be mounted to be accessible • The command mount lists currently mounted file systems • Similar effect can be achieved by viewing the mount table. $cat /etc/mtab • After mounting, use the mount point as the root dir.
Floppy Disks (cont.) • When an ext2 is created on a device, a directory called lost+found is created by default • To check if a mounted directory is not used by any users, you use the fuser: $fuser –u /mnt/floppy • You need to unmount the floppy disk before ejecting it. To do so, use $unmount /mnt/floppy • The unmount commands accepts the device to be un-mounted or the mount point directory • You can use the fuser to check if any process is using the mount directory which will prevent the device from being un-mounted • The file-systems table is used to mount devices at boot time and in case the mount command does not have enough arguments
Floppy Disks (cont.) • The /etc/fstab has six fields: Device to mount, mount point, type, mount options, dump#, fsck# • The dump# determines if the FS is to be backed up or not • The fsck# determines if FS is to be checked at boot or not • The mount can take fewer arguments • Example: $mount /dev/fd0 or $mount /mnt/floppy • Contents of /etc/fstab • Generally, floppy disks are mounted automatically when using a GUI environment such as the KDE or the GNOME
CD-ROMs • They are different than floppies in which they usually use IDE controller • Thus, they use similar naming convention like IDE hard disks (hda for primary master, etc.) • Besides, they typically use the iso9660 filesystem, thus they are mounted with • -t iso9660 option for the filesystem type • -r for read-only • $mount –r –t iso9660 /dev/cdrom /mnt/cdrom • They can be un-mounted using unmount • CD-ROM can NOT be ejected unless properly un-mounted.
Hard Disks • They are usually partitioned with different FS why • Separate different data types • Use of more than FS • Improve system reliability (FS corruption) • Enhance system performance • The MBR stores info about all partitions • Hard disk structure: Tracks, sectors, cylinder • Physical and logical partitions • Partitioning hard disks: • During installation: using Druid • After installation: Using fdisk • The machine might need to be rebooted to manually reload the new partition info
Maintenance Commands • Monitoring disk usage using disk free space (df) • It gives results in terms of block numbers • The –h option prints results measured in MB & GB • It only views mounted file systems • To get info about a specific directory use du (Directory Usage) • It, du, gives results in KB • The option –s give summary and can be used with –h • To view total number of i-nodes and the number of free ones use: dumpe2fs –h /dev/sda0
Maintenance Commands (cont) • Disk quotas • Soft limit and hard limit • Setting quotas (quotaon/quotaoff) • Editing quota (edquota) • List quota values for all users (repquota) • Checking quota values for individual users (quota –v <user>)