Formatting and attaching Hard Disk Partitions In CentOS

Source: Internet
Author: User

Formatting and attaching Hard Disk Partitions In CentOS

New Share

It is the formatting and mounting of Hard Disk Partitions. Combined with my actual work, I feel that "mounting" is the most used!
In my actual environment, it is common that the hard disk is broken !!
Then there is data. A joke, but a real example, is often used to handle irreversible hardware faults. PS (not all customers use brand servers, and the proportion of components is very high. Do not fantasizing about after-sales of tianxiao hardware) the customer will scream: "hurry up and try my best to get millions in minutes ".
Now, let's get started !!!!!


I have mentioned that mounting is mostly used, so you need to know your partition before mounting!
NO.1df
This is a practical command to view the partition status of the existing system... Look at the example

This is my current partition situation! When the second column marked by me is the size unit of the current partition, Kb is displayed! Is it very limited? the actual situation is that the current hard disk is so big that you can use kb to show your meaning
Therefore, adding-h to commonly used parameters is quite different.

-H makes me understand (that is, humans are displayed in a human-appropriate way)
This column shows

--- Total file system size use size available space use % Mount path ------


OK. You can see the line I added. tmpfs will explain it.
It can be understood that the memory is a virtual file system, and the size is 1/2 of the actual memory. Generally, data that is frequently read and not important can be written and read, but may be lost after a restart due to the timeliness. It is also possible to understand the virtual memory according to windows !!!


Now that partition is mentioned, I naturally want to think of a file system. Now there are many NTFS files in windows, and linux also has its own file system. After centos 6, ext4is used by default. If you want to see it, add a parameter to solve the problem.
Add-T

Now you need to add special effects.

Also, you want to see if inode continues to add the parameter-I

Df-iindoe usage is very important and there are also a number of inode. When a partition is large, you cannot continue writing data after using the inode resources.
Remember (generally enough)

-When using the-h parameter, remember to add your worth it !!!

After learning df, learn du again. This is a command with a different role and a bit similar to ll.
For example, because lsdu can see the directory or file capacity
The difference is that du can directly check the total capacity of a directory (including all contents of a directory)
Let me compare it.

Compare to see the difference in capacity! After du is displayed, the default unit is kb. You can set different units for display.
Du-sm MB display size
Du-sk KB display size
Du-sb B display size

Here we also introduce the concept of a block.
Logical Block: the logical block is the "minimum storage unit" specified during file system formatting by the partition. The default value is kb.
Let's look at another figure and understand the content based on the example.

Is the reason why the capacity listed by ls-ldh and du-sh is different?
When du-sh displays the result, if the file size is small and smaller than the size of one block, du-sh displays the size of one block, while ls-lhd displays the actual capacity. This is the difference ....


----------------------------- Partition and format -----------------------------
Before partitioning and formatting, we should know at least how my disk is used. Know how many disks I have! Or when you add a new hard disk, At least you must know that the system does not recognize it.
Remember to use the following
Fdisk-l

This is the disk sdb I added under the virtual machine.

Before partitioning, remember to have a knowledge point about the disk primary partition (P) extended partition (E ).
P + E is less than or equal to 4
Why is this! MBR Partition Table causes the mbr to have a 64 K size every 16 K storage records a partition table, so understand why it is less than or equal to 4!
Start partitioning
Fdisk/dev/sdb


It lists the frequently-used options. Select n if you want to create a new one.

View chart


Here I will create a primary partition. After the primary partition is created, it needs to be formatted! Only the specified file system is formatted. Generally, ext4 is written to inode.

Remember that grub must start MBR in the primary partition !!!
Next, we will continue formatting -------- mke2fs. Remember to add the parameter-t to specify the file system !!!!



After formatting, we need to mount the new partition and then use
Here we use mount mounting.
Mount/dev/sdb1/mnt/sdb1
Mount path of partition information

Here I mount the new partition sdb1 to/mnt/sdb1 ....
View my partitions

Partitions are also formatted and mounted, and data can be written. But we can't mount it today. I will not be able to survive tomorrow. So we need to enable him to automatically mount the device at startup?

The answer is required. We generally edit/etc/fstab.

We can use the cat command to view/etc/fstab

Use the vi command to edit it!

Mount-oloop1.iso/mnt1.iso is my example. This is used to mount the disk image file.


If there is a mount, there is an unmount. If not, umount will be unmounted under the partition.
Example:

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.