Welcome to the Slackware Documentation Project

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
slackbook:working_with_filesystems [2012/09/09 22:54 (UTC)]
mfillpot Added original text with formatting for local filesystem sections
slackbook:working_with_filesystems [2012/10/24 09:40 (UTC)] (current)
alienbob [Using mount] Fixed a paragraph which was erroneously copied from the previous chapter
Line 138: Line 138:
 ===== Using mount =====  ===== Using mount ===== 
  
-Now that we've learned what (some of) the different filesystems available in Linux are, it's time we looked at how to use them. In order to read or write data on a filesystem, that filesystem must first be mounted. To do this, we (naturally) use mount(8). The first thing we must do is decide where we want the filesystem located. Recall that there are no such things are drive letters denoting filesystems in Linux. Instead, all filesystems are mounted on directories. The base filesystem on which you install Slackware is always located at / and others are always located in subdirectories of /. ///mnt/hd// is a common place to temporarily locate a partition, so we'll use that in our first example. In order to mount a filesystem'​s contents, we must tell mount what kind of filesystem we have, where to mount it, and any special options to use.+Now that we've learned what (some of) the different filesystems 
 +available in Linux are, it's time we looked at how to use them. 
 +In order to read or write data on a filesystem, that filesystem 
 +must first be mounted. To do this, we (naturally) use mount(8). 
 +The first thing we must do is decide where we want the filesystem 
 +located. Recall that there are no such things are drive letters 
 +denoting filesystems in Linux. Instead, all filesystems are mounted 
 +on directories. The base filesystem on which you install Slackware 
 +is always located at ''​/'' ​and others are always located in 
 +subdirectories of ''​/''​''​/mnt/hd'' ​is a common place to temporarily 
 +locate a partition, so we'll use that in our first example. 
 +In order to mount a filesystem'​s contents, we must tell mount what 
 +kind of filesystem we have, where to mount it, and any special 
 +options to use.
  
 <​code>​ <​code>​
Line 144: Line 157:
 </​code>​ </​code>​
  
-Let's disect this. We have an ext3 filesystem located on the third partition of the first IDE device, and we've decided to mount its contents on the directory ​///mnt/hd//. Additionally,​ we have mounted it read-only so no changes can be made to these contents. The [-t ext3] argument tells mount what type of filesystem we are using, in this case it is ext3. This lets the kernel know which driver to use. Often mount can determine this for itself, but it never hurts to explicitly declare it. Second, we tell mount where to locate the filesystem'​s contents. Here we've chosen ​///mnt/hd//. Finally, we must decide what options to use if any. These are declared with the [-o] argument. A short-list of the most common options follows.+Let's disect this. We have an ext3 filesystem located on the third 
 +partition of the first IDE device, and we've decided to mount its 
 +contents on the directory /mnt/hd. Additionally,​ we have mounted it 
 +read-only so no changes can be made to these contents. The [-t ext3] 
 +argument tells mount what type of filesystem we are using, in this 
 +case it is ext3. This lets the kernel know which driver to use. 
 +Often mount can determine this for itself, but it never hurts to 
 +explicitly declare it. Second, we tell mount where to locate the 
 +filesystem'​s contents. Here we've chosen ​''​/mnt/hd''​. Finally, 
 +we must decide what options to use if any. These are declared with 
 +the [-o] argument. A short-list of the most common options follows. ​
  
 **Table 11.2. Common mount options** **Table 11.2. Common mount options**
Line 154: Line 177:
 |defaults |sane defaults for most filesystems| |defaults |sane defaults for most filesystems|
  
-If this is your first Linux installation,​ the only options you typically need to be concerned about are [roand [rw]. The exception to this rule comes when you are dealing with filesystems that don't handle traditional Linux permissions such as vfat or NTFS. In those cases you'll need to use the [uidor [gidoptions to allow non-root users access to these filesystems.+If this is your first Linux installation,​ the only options you 
 +typically need to be concerned about are //ro// and 
 +//rw//. The exception to this rule comes when you are dealing 
 +with filesystems that don't handle traditional Linux permissions such 
 +as vfat or NTFS. In those cases you'll need to use the //uid// 
 +or //gid// options to allow non-root users access to these 
 +filesystems. 
  
 <​code>​ <​code>​
Line 160: Line 190:
 </​code>​ </​code>​
  
-But Alan, that's appalling! I don't want to have to tell mount what filesystem or options to use everytime I load a CD. It should be easier than that. Well thankfully, it is. The ///etc/fstab// file contains all this information for filesystems that the installer sets up for you, and you can make additions to it as well. //fstab(5)// looks like a simple table containing the device to mount along with its filesystem type and optional arguments. Let's take a look.+ 
 +But Alan, that's appalling! I don't want to have to tell mount what 
 +filesystem or options to use everytime I load a CD. It should be easier 
 +than that. Well thankfully, it is. The ''​/etc/fstab''​ 
 +file contains all this information for filesystems that the installer 
 +sets up for you, and you can make additions to it as well. 
 +''​fstab''​(5) looks like a simple table containing the 
 +device to mount along with its filesystem type and optional arguments. 
 +Let's take a look.  
  
 <​code>​ <​code>​
Line 173: Line 212:
 </​code>​ </​code>​
  
-If you have an entry in fstab for your filesystem, you need only tell mount the device node or the mount location.+ 
 +If you have an entry in ''​fstab'' ​for your filesystem, you 
 +need only tell mount the device node or the mount location. ​ 
  
 <​code>​ <​code>​
Line 180: Line 222:
 </​code>​ </​code>​
  
-One final use for mount is to tell you what filesystems are currently mounted and with what options. Simply run mount without any arguments to display these. 
  
 +One final use for
 +**//​mount//​**
 +is to tell you what filesystems are currently mounted and with what
 +options. Simply run
 +**//​mount//​**
 +without any arguments to display these. ​
 ===== Network Filesystems =====  ===== Network Filesystems ===== 
  
-In addition to local filesystems,​ Slackware supports a number of network filesystems as both client and server. This allows you to share data between multiple computers transparently. We'll discuss the two most common: NFS and SMB. +In addition to local filesystems,​ Slackware supports a number of network 
 +filesystems as both client and server. This allows you to share data 
 +between multiple computers transparently. We'll discuss the two most 
 +common: NFS and SMB. 
 ==== NFS ====  ==== NFS ==== 
  
-NFS is the Network File System for Linux as well as several other common operating systems. It has modest performance but supports the full range of permissions for Slackware. In order to use NFS as either a client or a server, you must run the remote procedure call daemon. This is easily accomplished by setting the ///​etc/​rc.d/​rc.rpc// file executable and telling it to start. Once it has been set executable, it will run automatically every time you boot into Slackware.+NFS is the Network File System for Linux as well as several other common 
 +operating systems. It has modest performance but supports the full range of 
 +permissions for Slackware. In order to use NFS as either a client or a 
 +server, you must run the remote procedure call daemon. This is easily 
 +accomplished by setting the ''​/​etc/​rc.d/​rc.rpc'' ​file 
 +executable and telling it to start. Once it has been set executable, it 
 +will run automatically every time you boot into Slackware. ​ 
  
 <​code>​ <​code>​
Line 195: Line 251:
 </​code>​ </​code>​
  
-Mounting an NFS share is little different than mounting a local filesystem. Rather than specifying a local device, you must tell mount the domain name or IP address of the NFS server and the directory to mount with a colon between them.+ 
 +Mounting an NFS share is little different than mounting a local filesystem. 
 +Rather than specifying a local device, you must tell mount the domain name 
 +or IP address of the NFS server and the directory to mount with a colon 
 +between them.  
  
 <​code>​ <​code>​
Line 201: Line 262:
 </​code>​ </​code>​
  
-Running an NFS server is a little bit different. First, you must configure each directory to be exported in the ///​etc/​exports//​ file. //​exports(5)//​ contains information about what directories will be shared, who they will be shared with, and what special permissions to grant or deny. 
  
-<code>+Running an NFS server is a little bit different. First, you must configure 
 +each directory to be exported in the ''/​etc/​exports''​ 
 +file. ''​exports''​(5) contains information about what 
 +directories will be shared, who they will be shared with, and what special 
 +permissions to grant or deny.  
 + 
 + 
 +<file>
 # See exports(5) for a description. # See exports(5) for a description.
 # This file contains a list of all directories exported to other computers. # This file contains a list of all directories exported to other computers.
Line 209: Line 276:
  
 /​home/​backup 192.168.1.0/​24(sync,​rw,​no_root_squash) /​home/​backup 192.168.1.0/​24(sync,​rw,​no_root_squash)
-</code>+</file>
  
-The first column in exports is a list of the files to be exported via NFS. The second column is a list of what systems may access the export along with special permissions. You can specify hosts via domain name, IP address, or netblock address (as I have here). Special permissions are always a parenthetical list. For a complete list, you'll need to read the man page. For now, the only special option that matters is [no_root_squash]. Usually the root user on an NFS client cannot read or write an exported share. Instead, the root user is "​squashed"​ and forced to act as the nobody user. [no_root_squash] prevents this. 
  
-You'​ll ​also need to run the NFS daemonStarting and stopping NFS server support is done with the ///etc/rc.d/rc.nfsd// rc script. Set it executable and run it just like we did for rc.rpc ​and you are ready to go.+The first column in 
 +''​exports''​ 
 +is a list of the files to be exported via NFS. The second column is a list 
 +of what systems may access the export along with special permissions. ​You 
 +can specify hosts via domain name, IP address, or netblock address (as I 
 +have here). Special permissions are always a parenthetical list. For a 
 +complete list, you'll need to read the man pageFor now, the only special 
 +option that matters is //no_root_squash//. Usually the root user on 
 +an NFS client cannot read or write an exported shareInstead, the root 
 +user is //"​squashed"​// and forced ​to act as the nobody user. 
 +//​no_root_squash//​ prevents this.
  
 +
 +You'll also need to run the NFS daemon. Starting and stopping NFS server
 +support is done with the ''/​etc/​rc.d/​rc.nfsd''​ rc script.
 +Set it executable and run it just like we did for
 +''​rc.rpc''​ and you are ready to go. 
 ==== SMB ====  ==== SMB ==== 
  
-SMB is the Windows network file-sharing protocol. Connecting to SMB shares (commonly called samba shares) is fairly straight forward. Unfortuantely,​ SMB isn't as strongly supported as NFS. Still, it offers higher performance and connectivity with Windows computers. For these reasons, SMB is the most common network file-sharing protocol deployed on local networks. Exporting SMB shares from Slackware is done through the samba daemon and configured in //smb.conf(5)//. Unfortunately configuring samba as a service is beyond the scope of this book. Check online for additional documentation,​ and as always refer to the man page.+SMB is the Windows network file-sharing protocol. Connecting to SMB shares 
 +(commonly called samba shares) is fairly straight forward. Unfortuantely,​ 
 +SMB isn't as strongly supported as NFS. Still, it offers higher performance 
 +and connectivity with Windows computers. For these reasons, SMB is the most 
 +common network file-sharing protocol deployed on local networks. Exporting 
 +SMB shares from Slackware is done through the samba daemon and configured 
 +in ''​smb.conf''​(5). Unfortunately configuring samba as a 
 +service is beyond the scope of this book. Check online for additional 
 +documentation,​ and as always refer to the man page.  
 + 
 + 
 +Thankfully mounting an SMB share is easy and works almost exactly like 
 +mounting an NFS share. You must tell mount where to find the server and 
 +what share you wish to access in exactly the same way. Additionally,​ you 
 +must specify a username and password
  
-Thankfully mounting an SMB share is easy and works almost exactly like mounting an NFS share. You must tell mount where to find the server and what share you wish to access in exactly the same way. Additionally,​ you must specify a username and password. 
  
 <​code>​ <​code>​
Line 225: Line 319:
 </​code>​ </​code>​
  
-You may be wondering why the filesystem type is cifs instead of smbfs. In older versions of the Linux kernel, smbfs was used. This has been deprecated in favor of the better performing and more secure general purpose cifs driver. 
  
-All SMB shares require the [usernameand [passwordarguments. This can create a security problem if you wish to place your samba share in fstab. You may avoid this problem by using the [credentialsargument. ​[credentialspoints to a file which contains the username and password information. As long as this file is safely guarded and readable only by root, the likelyhood that your authentication credentials will be compromised is lessened.+You may be wondering why the filesystem type is cifs instead of smbfs. In 
 +older versions of the Linux kernel, smbfs was used. This has been 
 +deprecated in favor of the better performing and more secure general 
 +purpose cifs driver.  
 + 
 + 
 +All SMB shares require the //username// and //password// 
 +arguments. This can create a security problem if you wish to place your 
 +samba share in fstab. You may avoid this problem by using the 
 +//credentials// argument. ​//credentials// points to a file 
 +which contains the username and password information. As long as this file 
 +is safely guarded and readable only by root, the likelyhood that your 
 +authentication credentials will be compromised is lessened. ​ 
  
 <​code>​ <​code>​
Line 234: Line 340:
 darkstar:~# mount -t cifs //​darkstar/​home -o credentials=/​etc/​creds-home darkstar:~# mount -t cifs //​darkstar/​home -o credentials=/​etc/​creds-home
 </​code>​ </​code>​
 +
 +====== Chapter Navigation ======
 +
 +**Previous Chapter: [[slackbook:​filesystem_permissions|Filesystem Permissions]]**
 +
 +**Next Chapter: [[slackbook:​vi|vi]]**
 ====== Sources ====== ====== Sources ======
- * Original source: [[http://​www.slackbook.org/​beta/]] +<!-- If you copy information from another source, then specify that source --> 
 +  * Original source: [[http://​www.slackbook.org/​beta]] ​\\ 
 +<!-- Authors are allowed to give credit to themselves! --> 
 +  * Originally written by Alan Hicks, Chris Lumens, David Cantrell, Logan Johnson 
 +<!-- * Contrbutions by [[wiki:​user:​yyy | User Y]] -->
  
 <!-- Please do not modify anything below, except adding new tags.--> <!-- Please do not modify anything below, except adding new tags.-->
-{{tag>​slackbook filesystem mount}}+<!-- You must also remove the tag-word "​template"​ below. Otherwise your page will not show up in the Table of Contents --> 
 +{{tag>​slackbook filesystem ​network_filesystems nfs smb mount}}

In Other Languages
QR Code
QR Code slackbook:working_with_filesystems (generated for current page)