Linux hard disk partitioning and formatting learning notes

Source: Internet
Author: User

One, hard disk partition

(a) hard disk partitioning benefits

1. Data loss can be avoided. Usually in Windows systems, the hard disk is often divided into multiple partitions, such as C, D, E, F, and so on, while the C disk is mainly used as system disk. The advantage of this is that once the system crashes and the system is re-installed, data other than the C drive can be saved, reducing the risk of data loss. Partitioning is also useful for managing software, data, and more.

2. Multiple systems can be installed. For example, WIN8 and Linux cannot be installed on the same partition. Each partition can be formatted into a different file system, or support Windows FAT32, NTFS, or a Linux-enabled Ext series, NFS, GFS, etc., which can be installed on the partition with different file systems to install different types of systems to achieve user needs.

(ii) MBR (Master boot Record)

Hard disk partitions are usually segmented in the form of cylinders, while the 0-cylinder 0 Track 1 sector is often retained as an MBR, and once the cylinder is damaged, the hard disk will not function as a boot device. The sector size of the MBR is typically 512 bytes. The first 446 bytes are used to store bootloader, and the next 64 bytes are partitioned tables, where each 16 bytes identifies a primary partition, so a hard disk supports up to four primary partitions, and the last 2 bytes are 5A (hexadecimal), also known as the encapsulation code, to identify if the hard disk is bootable.

MBR determines that the hard disk can only have a maximum of four primary partitions, if you want to use more than four partitions should use extended partition, extended partition is a logical concept, need to be divided into logical partition to use.


Second, the Linux partitioning process

(a) You should first create a partition

Fdisk is a common partitioning tool under Linux, using the following methods:

1. View disk information

# fdisk-l: View information for all disks on the current host

# FDISK-L Device: View information for the specified disk device

2. Create and modify partitions

# FDISK Device: Partitioning the specified disk device

You can use "cat/proc/partitions" to see if the kernel has recognized the modified partition information

(ii) second to format

The purpose of formatting a partition is to create a file system:

1.mkfs for formatting:

# MKFS [-T Fstype] partitions: Format partition partitions to file system Fstype

For Fstype, the following two points need to be noted:

(1) Fstype must be supported by the system kernel, that is, the kernel should have the corresponding kernel module;

(2) to have the corresponding file system creation tool, this is usually mkfs.fstype (typing mkfs, two times a row tab to see MKFS.FSTYPE)

Note: Extended partitions cannot be formatted

# Blkid partitions: Displays the UUID and file system type of the partition

2. For formatted EXT series, the MKE2FS function is more powerful than MKFS:

# mke2fs-t {EXT2|EXT3|EXT4} partitions

Common options:

-B {1k,2k,4k}: Specifies the block size. Note: To modify the block size, you can only reformat it.

-L Label: sets the volume label,

-M: The proportion of the total space occupied by the block reserved for the administrator to use

The TUNE2FS is used to adjust the values set by the MKE2FS, and the relationship is similar to Useradd and UserMode:

(iii) should finally be mounted

Mounting is the process of associating a directory (also called a mount point) with a partition, so that access to the partition can be achieved only by accessing the directory:

1.mount Tools for mounting:

# mount: Displays the currently mounted partition (essentially displaying the contents of the/etc/mstab)

# mount [-t Fstype] Partitions Mount_point: Association

# Mount-n: When mounting the file system, the/etc/mstab is not updated

# Mount-a: Mount content from all/etc/fstab

The 2.umount tool is used to cancel the mount:

# Umount Partitions


This article is from the "Rain Star Blog" blog, please be sure to keep this source http://xyxyl.blog.51cto.com/8875749/1718426

Linux hard disk partitioning and formatting learning notes

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.