Linux commands (24) Disk Management commands (ii) Mkfs,mount

Source: Internet
Author: User

First, the format of the file system Mkfs

When the hard disk partition is completed and the hard disk is formatted, the MKFS series corresponding commands are used to format the hard drive as a file system in the specified format. The MKFS itself does not perform the work of establishing the filesystem, but rather calls the relevant program to execute it. For example, if you specify ext2 in the-t parameter, MKFS calls MAKE2FS to establish the file system. When using MKFS, if you omit the "block number" parameter, MKFS automatically sets the appropriate number of blocks, which can format not only the Linux file system, but also the file system under DOS or Windows.

The common parameters of the MKFS command are as follows

-V 显示详细模式-t: 给定文件系统的格式,Linux的预设值为 ext3-c 操作之前检查分区是否有坏道-l 记录坏道的资料block 指定block的大小-L: 建立卷标

The file format supported by MKFS in Linux system depends on whether there are any corresponding commands in the current system, such as to format the partition as Ext3 file system, the MKFS.EXT3 command to be present in the system, and other similar.

MKFS Command Usage instance

View the file system formats supported by the current system MKFS command

[[email protected] hk]# ls /sbin/mkfs.* -l-rwxr-xr-x. 1 root root 308200 Nov  5  2016 /sbin/mkfs.btrfs-rwxr-xr-x. 1 root root  32784 Nov  6  2016 /sbin/mkfs.cramfs-rwxr-xr-x. 4 root root  96384 May 16 12:51 /sbin/mkfs.ext2-rwxr-xr-x. 4 root root  96384 May 16 12:51 /sbin/mkfs.ext3-rwxr-xr-x. 4 root root  96384 May 16 12:51 /sbin/mkfs.ext4-rwxr-xr-x. 1 root root  32872 Nov  6  2016 /sbin/mkfs.minix-rwxr-xr-x. 1 root root 368464 Nov  6  2016 /sbin/mkfs.xfs

Format a partition as a ext3 file system

[[email protected] hk]# mkfs -t ext3 /dev/sda1
Second, mount, unmount file system Mount/umount

The Mount command is used to mount the partition, and the corresponding unload partition is umount. These two commands are typically executed by the root user. In addition to the ability to mount a hard disk partition, closing and memory can be mounted to the user-specified directory using this command.

Common parameters for the Mount command:

-v 显示详细信息-a 加载文件 /etc/fstab 中设置的所有设备-F 需与 -a 参数同时使用。所有在 /etc/fstab 中设置的设备会被同时加载,可加快执行速度-f 不实际加载设备。可与-v等参数同时使用可以查看mount的执行过程-n 不讲加载信息记录在 /etc/mtab 文件中-L 加载指定卷边的文件系统-r 挂载为只读模式-w 挂载为读写模式-t 指定文件系统的格式,通常不用指定。mount 会自动选择正确的格式。常见的文件系统有 ext2 ext3 ext4 msdos nfs iso9660 ntfs等-o 指定加载文件系统时的选项爱那个,如 noatime 每次存取时不更新inode的存取时间

A very frequent command is used to mount partitions in the Linux operating system. Mount command can mount a variety of media, such as hard disk, CD-ROM, NFS, etc., USB drive can also be mounted to the specified directory.

Mount Command Usage Instance

Mount partitions to the specified directory

[[email protected] hk]# mount /dev/sdb /mnt/disk2

To mount a partition as read-only mode

[[email protected] hk]# mount -o ro /dev/sdb /mnt/disk2

Mount the optical drive, use the ISO file can avoid extracting files, can be mounted directly to access

[[email protected] hk]# mount it iso9660 /dev/cdrom /mnt/cdrom

The mount point must be a directory, and if the directory has content, the original file of the directory will not be visible after it is mounted, and can be reused after uninstallation.

If the partition you want to mount is frequently used to mount automatically, you can add the partition mount information to/etc/fstab, which is described below:

/dev/sdb1     /mnt/disk2                       ext3     defaults        0 0
    • The first column represents the device name of the file system to be mounted, which can be a hard disk partition, a CD-ROM, a USB flash drive, or an ISO file, or NFS.
    • The second column represents the mount point, and the mount point is actually an oyster, which can be empty or not empty.
    • The third column represents the mounted file type, Linux can support most of the partition format, and the partition system under Windows can also be supported. such as the common Ext3, ext2, Ext4, iso9660, NTFS and so on.
    • The four columns are set options and each option is separated by commas. Set default to indicate RW, suid, dev, exec, auto, Nouser, and async.
    • The five columns are sorted backup settings. This is 1, which means to back up the contents of the entire file system, or 0, which means no backup, and a general setting of 0.
    • The last column indicates whether to run the fsck command to check the file system. 0 means not running, 1 means running each time, 2 indicates an unhealthy shutdown or a maximum load count or a certain number of days to run.

Linux commands (24) Disk Management commands (ii) Mkfs,mount

Related Article

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.