Linux (13) disk partitioning, creating file systems, mounting

Source: Internet
Author: User
Tags uuid disk usage

Before learning the Linux user management, feel is not Linux multi-user multitasking system feel very understanding, but in fact not. You also need to know more. And the next thing we're going to share

Add a hard disk in VMware to create a partition and mount it to the specified directory. Remember never to give up what you are after, even if you may not be able to catch up, but also enjoy the fun.

I. Adding a hard drive in VMware

First of all to install a VMware virtual machine, I believe most people to learn Linux will use this tool, so here I do not introduce VMware. Go to the Chase

First step: Enter the settings for the specified Linux system in VMware

    

Step Two:

      

Step three: Next is basically the next step, the next step, which needs to be noted in several points

Fourth step: Restart the Ubuntu system and view it (remember to restart it to use it)

  

Can see my newly added SDC disk

Second, partition the disk

For a newly added hard drive we know we can't use it directly, we need to format it first, and then we can partition it.

2.1. fdisk command  

Command description: Observe hard disk usage and hard disk partitioning

Enter fdisk-l/DEV/SDA on the console to observe the physical use of the hard disk

2.2. Partitioning steps 

First, for operational purposes, we switch to the root user

First step: Enter the FDISK/DEV/SDCon the console to enter the split-drive mode

  

Step two: Enter M to display all the commands listed, we can first press p to see if it was created before the partition

Step three: Enter N to set a new hard disk partition

    

Fourth Step: View

    

The fifth step: this time just create a partition table, no save, this time you input Q of the words will be naught, we have to enter W save. Then the FDISK mode is released

  

iii. Creating a file system3.1. MKFS command  

Command description: MKFS is used to build Linux-supported file systems on a single device, or as a format tool , where the device is usually the indicator hard disk partition . After partitioning through a tool such as Fdisk on Linux, the partition needs to be processed to support the appropriate file system.

At this point, the MKFS tool is needed, and the essence of establishing a filesystem process is to create the required structure of the filesystem on disk space, write data about the filesystem on disk space according to the file system design (called File system metadata), based on these data

The management of the file system and related operations are now performed. In fact, MKFS is a simplified front-end tool for different file system Builders (Mkfs.fstype) under Linux.

Command format: MKFS [-v] [-t fstype] [fs-options] filesys [blocks]
Parameter description
Device: Pre-check the hard disk partition, for example:/dev/sda1
    -V: Verbose display mode
    -T: Given the type of file system, the default value for Linux is EXT4
C: Before making the file system, check whether the partition has bad track
-L Bad_blocks_file: add block data with bad track to Bad_blocks_file
Block: The size of the given block

Instance:

Build a Msdos file system on/DEV/HDA5, check for bad tracks, and list the process in detail:
Mkfs-v-T Msdos-c/dev/hda5
Format the SDA6 partition as ext3 format
Mfks-t Ext3/dev/sda6
Note: The file system here is to be specified, such as ext3; reiserfs; ext2; fat32; MSDOS, etc.

3.2. Create File System

Create a file system for the SDC1 partition you just created above

  

We created the partition but we haven't created an access path for the partition yet. Next we need to mount the partition to a directory of the system in order to use this partition.

Iv. Mounting4.1. Mount Command 

Command Description: Mount is a command under Linux that can attach a partition to a folder in Linux, thereby linking the partition to that directory, so that we access the partition as long as it accesses the folder .

The Linux mount command is a frequently used command that is used to mount files outside the Linux system.

Command syntax:

Mount [-HV]
mount-a [-FFNRSVW] [-t Vfstype]
Mount [-FNRSVW] [-O options [,...]] device | dir
Mount [-FNRSVW] [-t vfstype] [-O options] Device dir
parameter Description
- V: Show program version
- H: Display auxiliary messages
-V: Displays more messages, usually and-F for debugging.
-A: Hang up all the file systems defined in the/etc/fstab.
- F: This command is usually used with-a, which generates a stroke for each mount action. You can speed up the action of hanging when the system needs to hang a large number of NFS file systems.
-F: Usually used for debugging purposes. It makes mount not perform the actual hanging action, but rather simulates the entire hanging process. It is usually used with-V.
-N: In general, Mount will write a piece of data in the/etc/mtab after it is hung. However, this option can be used to cancel this action if there is no writable file system in the system.
-s-r: Equals-o ro
- w: equals-o rw
-L: Split the hard drive with a specific label on it.
- u: The file system with the file segmentation sequence is hung down. The-L and-u must be meaningful when the/proc/partition file is present.
-T: Specifies the configuration of the file system, which is usually not required. Mount will automatically select the correct form.      
-O Async: Open non-synchronous mode, all file read and write actions will be performed in asynchronous mode.
-o Sync: Executes in synchronous mode.
- o atime,-o noatime: When Atime is turned on, the "Last Call time" of the archive is updated each time the file is read. When we use the Flash file system, we may turn this option off to reduce the number of writes.
-o auto,-o Noauto: Turn on/off auto-hang mode.
-O Defaults: Use preset options for RW, suid, dev, exec, auto, Nouser, and async.
-O Dev,-o nodev-o exec,-o noexec allow execution of the file.
-o suid,-o Nosuid: Allows execution of the file under root authority.
-o user,-o nouser: The user can perform mount/umount actions.
- o remount: Put a file system that has been hung back in a different way. For example, a system that was originally read-only, is now re-hung in a read-write mode.
-O ro: Hang up with read-only mode.      
-o RW: Hang up in read/write mode.       
-O loop=: Use loop mode to mount a file as a hard disk split system.

Instance:    

    Hang the/dev/hda1 under/MNT and set the file system type to EXT4.
# mount-t Ext4/dev/hda1/mnt
Hang the/dev/hda1 under/mnt with read-only mode.
#mount-O ro/dev/hda1/mnt
Use the loop mode to hang the image file of the/tmp/image.iso disc under/mnt/cdrom. In this way, the Linux CD ISO file that can be found on the general network can be viewed without being burned into a disc.
#mount-O Loop/tmp/image.iso/mnt/cdrom

4.2. unmount command 

Command format:unmount mount point
Command description: Uninstall a mount point  

4.3. Permanently mount the disk   

The mount command above is just a temporary mount, and it is inconvenient to mount it again after the reboot, so it will need to be mounted permanently or automatically mounted on the boot.
Steps:
1) First get/DEV/VDB1 the UUID of this partition, use the following command:sudo blkid/dev/vdb1
2) Open the/etc/fstab file with the VI editor, and then add another to mount the VDB1 by referencing the mount information that already exists in the file.

      

Where the first column is a UUID
The second column is the mount directory , which must be an empty directory
Third column file system type
Column four parameter
Fifth Column 0 means no backup
The last column must be 2 or 0 (unless the boot partition is 1)
Finally, use the MOUNT-A command to detect the Mount , which is used to detect errors in the Fstab file and will not mount successfully if there is an error.

  

    

 

  

 

    

Linux (13) disk partitioning, creating file systems, mounting

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.