File system-create partition + format partition

Source: Internet
Author: User

Concept: The file system is for storage devices.



You need to specify the storage partition that this file system will apply to before you create the file system.

Partition of the storage device can be completed via the FDISK command

Fdisk/dev/sda

Warning:dos-compatible mode is deprecated. It ' s strongly recommended to
Switch off the mode (command ' C ') and change display units to
Sectors (Command ' u ').


Command (M for help): P

disk/dev/sda:21.5 GB, 21474836480 bytes
255 heads, Sectors/track, 2610 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x0006210d


Device Boot Start End Blocks Id System
/DEV/SDA1 * 1 307200 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 2354 18598912 Linux
/dev/sda3 2417 2611 1564384-up Linux

has been divided into sda1, sda2 and Sda3, now a new partition sda4

Command (M for help): N
Command Action
E Extended
P primary partition (1-4)

Partitions are divided into extended partition E and primary partition p

Extended partition: The extended partition can only accommodate other primary partitions, cannot accept the file system (formatted), the role of the extended partition is because there can be only 4 primary partitions on a storage device, so if you want more primary partitions, you need to partition in the extended partition again (the extended partition is the equivalent of a new storage device, The primary partition can be created again for this storage device.)

Primary partition: The primary partition can accept file systems (formatted), with a maximum of 4 primary partitions per storage device.


Delete last partition

Command (M for help): D
Partition number (1-4): 4

Create again

Command (M for help): N
Command Action
E Extended
P primary partition (1-4)
P
Selected Partition 4

Results

Device Boot Start End Blocks Id System
/DEV/SDA1 * 1 307200 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 2354 18598912 Linux
/dev/sda3 2417 2611 1564384-up Linux
Partition 3 does not end on cylinder boundary.
/DEV/SDA4 2354 2416 499384-up Linux

Effective partitioning results

Command (M for help): W
The partition table has been altered!


Calling IOCTL () to re-read partition table.


Warning:re-reading the partition table failed with error 16:device or resource busy.
The kernel still uses the old table. The new table is being used at
The next reboot or after you run Partprobe (8) or KPARTX (8)
Syncing disks.

At this point, a new partition Sda3 has been created, but the hardest part of creating a new hard disk partition is finding the physical disk on the Linux system. For older IDE hard disks, Linux is identified by/DEV/HDX, where x represents the ordinal, such as SDA on behalf of the first disk, SDB for the second disk, and so on. For newer SATA hard drives and SCSI hard drives, Linux is identified with/DEV/SDX (this is the system partition).

after reboot, the above partition operation takes effect (or through the partprobe Command, of course, this command to install )

Here if not restart will error Could not stat/dev/sda4---No such file or directory

/|\

| —————————————————————————————————————————————————————————————— above has obtained the desired disk partition


Here's how to format the partition as the file system you want ——————————————————————————————————————————————————————— |

\|/

For different file systems, there are different command lines for formatting partitions

Mkefs Creating an Ext file system

MKE2FS ext2

Mkfs.ext3 ext3

MKFS.EXT4 ext4

Mkreiserfs ReiserFS

Jfs_mkfs JFS

MKFS.XFS XFS

You can create the default file system (if you don't want any special settings) directly with the command above.


After the partition is finished, the file system is formatted for the partition, and the following is where you hang the partition into a folder for use.

Create the destination folder to be hung first mkdir/v_sda4

Mount-t EXT4/DEV/SDA4/MNT/V_SDA4

This hangs at the end of the job and looks at the post information: Mount


The last one is for just-mounted.

Note: The above mounted file system will automatically expire after rebooting the system (the partition still exists, but the partition does not have a specific file system, is not yet formatted), you want to restart the system and still retain the file system, you can add the file system to the/etc/fstab file.

Now restart the machine and mount again, and the last one is gone.














File system-create partition + format partition

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.