70 likes | 94 Views
Mounting file systems and Managing Removable Media. Filesystems Concept Review Linux uses a single-rooted filesystem If you want to use additional filesystems, they must be grafted into the root filesystem You can mount both local and remote network-shared filesystems (ex. NFS, SMB, etc.)
E N D
Filesystems Concept Review Linux uses a single-rooted filesystem If you want to use additional filesystems, they must be grafted into the root filesystem You can mount both local and remote network-shared filesystems (ex. NFS, SMB, etc.) Linux/UNIX systems traditionally have many filesystems; /, /tmp/, /home/, etc.
MountingFilesystems • Mount filesystems with the mount command • • mount [-t type] [-o option[,option[,...]]] [device] [dir] • # mount -t ext2 /dev/hda10 /mnt/tmp • • searches the /etc/fstab file for missing parameters if supplied with only device or dir • # mount /mnt/tmp • • mount without parameters to list currently mounted filesystems • $ mount • /dev/hda5 on / type ext2 (rw) • /dev/hda1 on /boot type ext2 (rw) • . . . snip . . . • Unmount filesystems not currently in use with • • umount [device|dir] • # umount /mnt/tmp • Mounting with Filesystem Labels • # mount LABEL=webdata /projects/website
NFS • The Network Filesystem is the standard and native UNIX file- sharing method • • Developed by Sun Microsystems • • NFS servers export directories • • Client machines mount NFS exports and local applications and users access files as if they were local • • Default settings are conservative; can be tuned for much higher performance • Syntax • # mount -t nfs server:/exported/filesystem mountpoint • # mount -t nfs of50:/stage /mnt/stage • Greatly increase performance by setting the read and write packet size to 8 kilobytes. For example: • # mount -t nfs -o wsize=8192,rsize=8192 of50:/stage /mnt/stage/
Filesystem Table • /etc/fstab • • Contains information about filesystems • • Which filesystems to mount and when • One filesystem per line • Order is significant • • Options for mounting each filesystem • Filesystem type • Security • Additional per-filesystems features • • Complete documentation of all available filesystem options is available on the mount(8) man page
Automating Mounts • /etc/fstab • • Lists resources to mount at boot time • • Subsequent mounts/unmounts must be carried out manually • • Requires root access • autofs • • Allows automated mounting of resources on demand • • Automatically unmounts resources when no longer used • • Allows non-privileged users to trigger mounts and unmounts of resources
Removable Media • Must be mounted before use • Must be unmounted before removal • • when possible, the system will attempt to enforce this by preventing removal of mounted media • • use fuser to locate processes accessing a filesystem • GNOME and KDE automount removable media devices (CDs, DVDs, USB drives, etc.) • Umounting In-use Filesystems • Sometimes it can be difficult to determine what processes are accessing a filesystem, preventing you from being able to unmount it. To list by PID all processes that are accessing a filesystem, you can use the command: • $ fuser -m /filesystem/ • Add the -k option to also kill all those processes. The lsof command can also be helpful in identifying culprits.