Chapter8:linux disk and File System Management (3) partitioning, formatting, checking and mounting of disks

Source: Internet
Author: User

When we add a new hard drive to the system, we have to do the following:

1. Partition the disk to create a new available partition.

2. Format the partition to create a file system that is available to the system.

3. Verify the file system you just created.

4. On Linux, you also create mount points, which are directories, and mount the partitions.

We have to consider the size of the partition, whether to join the log function, Inode and block number planning, these are to see the use of the host to determine.

I. Disk partitioning FDISK

Fdisk [-l] Device name

Outputs the partition contents of all subsequent devices. If you have only fdisk-l, the partitions for all devices on the system are listed. Use a USB stick test.

The above boot indicates the boot module, usually the C drive of window has this.

/dev/sda2 is the extended partition, which can be seen from start and end, so the entire disk is no longer able to make additional partitions.

Fdisk can only be executed with root, and note that Fdisk is for the device, not the partition of the device.

1. Delete a disk partition


Here we delete all the partitions, note, can not be saved with W, exit with Q discard.

2. New Partition

On top of that, we add new partitions. Divided into primary, extended,logical partitions.

(1) Added primary partition

, we added a primary partition with a partition number of 4. Size is 2G, and this time, there are 13th numbers left,

(2) Added extended partition

Here, we have added a extended partition, size 2G, generally we should divide all the remaining space into the extended partition, here is just the experiment.

(3) Added logical partition

As we can see, the logical partition SDA5 is a partition within the extended sda1. Size is 200M.

Operating Environment Description:

If the partition of the hard disk is still in use, it is possible that the kernel of the system will not be able to reload the partition table of the hard disk, this time should be used to unload the partition, and then re-enter the partition once, re-write to the partition table can be successful.

Precautions:

FDISK cannot handle hard drives larger than 2T, although EXT3 can already support more than 16T of hard drives. This time should be handled by the parted command.

Two. formatting of the disk

After the partition is finished, it is formatted, MKFS (make file system), which is actually a comprehensive command that will call the correct filesystem formatting tool.

MKFS [-T file system format] device file name

If you format/dev/sda1 as a ext3 file system.

Mkfs-t ext3/dev/sda1

In the information shown in the results, it is important to:

The name of the partition, the block size, the number of inode/block.

MKFS supported file systems are: (MKFS plus two tab display)

where VFAT is a U-disk that can be used in window/linux.

Three. Disk Inspection fsck,badblocks

1. File System Check Fsck

The file system will run with the hard disk and the memory of the data asynchronous situation, so this time the crash may cause file system confusion, we can use fsck to save.

This command is usually used when the system has a great problem, only root.

2. Hard disk or floppy disk bad track test badblocks

Four. Unmount and mount the disk

Chapter8:linux disk and File System Management (3) partitioning, formatting, checking and mounting of disks

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.