The use of the Linux Command Learning series 14-mount,fstab

Source: Internet
Author: User

previous section review:

1. gzip/gunzip command

2. tar command

Assignment: compress the Lastlog file under /var/log with gzip, then unpack with Gunzip , and package ect with tar Directory to the tmp directory

Gzip/var/log/lastlog

Gunzip/var/log/lastlog.gz

Tar–zcvf/tmp/etc.tar.gz/etc

The content of this section:

1. Mount command

The Mount command is used to mount external resources.

Common ways mount–a, mount–l, Mount [option] source mount point

Mount–a used to manually mount automatic mounts defined in the/etc/fstab file

Mount–l is used to view all mounted devices with no parameters like mount

For example, we want to mount a device from /dev/sda1 to /tmp/sda1 .

Create a mount point first,mkdir/tmp/sda1

to perform the mount again,mount/dev/sda1/tmp/sda1

you can see that the/dev/sda1 has been hung into the /tmp/sda1 .

to mount a directory inside the system, such as mount /etc to/tmp/etc , you can simply execute the following command

Create a/tmp/etc mount point first , mkdir/tmp/etc

then execute,mount–b/etc/tmp/etc

you can see that the/etc Directory has been hung under /tmp/etc

Cancel mount, use umount command + mount point, for example to cancel /tmp/sda1 mount, execute umount/tmp/sda1


2. Etc/fastab

with the Mount command mounted device, the mount will fail when the Linux system restarts. To allow the system to mount automatically when it restarts, you need to configure the mount in the Fstab file. Use the cat command to view the contents of the Fstab file.

You can see that some auto-mounts are already defined inside.

The Fstab file consists of 6 columns, as detailed below:

<file system> <dir> <type> <options> <dump> <pass> ;

For example, we attach the/etc to /tmp/etc , we need to add the following text to fstab

/etc/tmp/etc None bind 0 0

job: attach/opt to /tmp/opt and add to fstab

Follow the public number "get kicked genius" for free video tutorials + graphic Tutorials

The details of each parameter can be found in the following text (from the network)

· <file systems>- the partition or storage device that you want to mount .

· <dir>- mount position of the <file systems>.

·         <type> - to mount the file system type of the device or partition, Supports a number of different file systems: ext2, ext3, ext4, reiserfs, xfs, jfs, smbfs, iso9660,  vfat, ntfs, swap   auto set to Auto mount command guesses the type of file system used, the CDROM DVD

· <options>- parameters used when mounting, note that some mount parameters are only available for specific file systems. Some of the more commonly used parameters are:

· Auto-mounts automatically at startup or when you type the mount-a command.

· Noauto- is only mounted under your command.

· exec- allows binary files to execute this partition.

· noexec- binary files on this file system are not allowed to execute.

· Ro- mount the file system in read-only mode.

· rw- mount the file system in read-write mode.

· User- allows any user to mount the file system without the display definition, implicitly enabling noexec, Nosuid, Nodev parameters.

· User- allows users in all users groups to mount the file system .

· Nouser- can only be mounted by root .

· Owner- allows the device owner to Mount .

· the sync-i/o is synchronized.

· async-i/o is asynchronous.

· Dev- parses the block special device on the file system.

· Nodev- block special devices on the file system are not parsed.

· suid- allows suid to operate and set Sgid bits. This parameter is typically used for special tasks that temporarily elevate permissions when a general user runs the program.

· nosuid- Disable suid operation and set sgid bit.

· Noatime-the Inode access record on the file system is not updated to improve performance ( see atime parameters ).

·         nodiratime - do not update the directory on the file system Inode Access record, can improve performance ( see atime parameter "

·         relatime - Live update inode access record. Only the access time in the record is older than the current access will be updated. (Similar to noatime mutt ( see atime parameters )

· flush-vfat option to refresh data more frequently, the Copy dialog box or progress bar disappears after all data is written.

· Defaults- using the file system's default mount parameters, such as Ext4 's default parameters are : rw, suid, dev, exec, auto, nouser, async.

·         <dump> dump tool to decide when to make a backup . Dump The allowed number is 0 1 0 is ignored, 1 is backed up. Most of the users are not installing dump <dump > 0

· <pass> fsck reads <pass> values to determine the order in which the file system needs to be checked. The allowed numbers are 0, 1, and 2. the root directory should have the highest priority of 1, and all other devices that need to be checked are set to 2. 0 means the device will not be checked by fsck .


The use of the Linux Command Learning series 14-mount,fstab

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.