Fdisk usage (reprinted)

Source: Internet
Author: User
Tags hex code

The fdisk function in Linux is extremely powerful. It can be used to divide the most complex partitions. The following briefly introduces its usage:

For an IDE hard disk, each disk has a device name that corresponds to the four ide interfaces of the motherboard. The device names are/dev/hda,/dev/HDB,/dev/HDC, /dev/HDD, etc,

If there is an ide raid card, the cards are/dev/HDE,/dev/HDF,/dev/hdg,/dev/hdh in sequence. For SCSI hard disks, the device names are/dev/SDA,/dev/SDB...

Fdisk command line usage: fdisk hard disk device name

After entering fdisk, type 'M' to display all the fdisk menus.

Type 'P' to display the current Partition Table status.

Type 'n', add a partition, and then prompt you to select the partition type (Basic partition or extended partition), and then select the Partition Number (1-4 ). Note: Each hard disk can be divided into up to four primary partitions (including basic partitions and extended partitions). A maximum of four basic partitions can be divided, and a maximum of one extended partition can be divided, however, you can divide multiple logical partitions in the extended partitions (I have not tried at most, but there are many logical partitions ). After selecting the partition type and partition number you want to create, the system will prompt you to enter the starting cylinder, starting from 1, and then entering the ending cylinder. At this time, you can enter the actual number of cylinders, you can also use the "+ partition size" Method for input. For example, + 1024 M indicates that M is added to the start cylindrical surface. The device names in the primary partition are/dev/hda1,/dev/hda2,/dev/hda3,/dev/hda4, and the device names in the logical partition are as follows: /dev/hda5,/dev/hda6,/dev/hda7... and so on.

Type 'D' to delete the partition. Enter the Partition Number to delete the partition. Note: When you delete an extended partition, all logical partitions are also deleted.

Type 'T' to change the partition flag (this is the most essential part of Linux fdisk !), The default identifier of the new partition is 83 (Linux ext2). You can change it to 82 (Linux swap zone), 'B' (FAT32), 'F' (FAT32 extend, limited to extended partitions), '86' (NTFs )... And so on. In this way, friends who use multiple operating systems can use Linux fdisk to divide all the partitions you want!

Type 'A' to switch to partition activation. Note: each time you type a partition, the selected partition changes once between activation and non-activation, but you must ensure that only one partition is activated. In this case, the 'p' command is obtained. The activated partition has a '*' number.

In addition to the preceding commands, there are several other commands that are not commonly used.

Finally, type 'W'. The changes you made to the partition are written to the hard disk. Type 'q' to discard all the changes.

Flexible application of fdisk can also repair damaged partition tables on the premise that you must accurately remember the start and end cylinders of each original partition.

Add the following method to format the hard disk:
To Format partitions into Linux ext2 format, use: mkext2fs/dev/hda?
To format the partition into FAT32 format, use: mkfs. vfat/dev/hda?
Appendix 2:
Command: fdisk

Purpose: Observe the physical usage of the hard disk and separate the hard disk.

Usage:

1. Enter fdisk-L/dev/SDA on the console to observe the physical usage of the hard disk.

2. Enter fdisk/dev/SDA on the console to enter the split hard disk mode.

1. Enter m to display all commands listed.

2. Enter P to display hard disk segmentation.

3. Enter a to set the hard disk boot zone.

4. Enter n to set the new hard disk partition.

4.1. Enter the "e" hard drive as the [extended] partition (extend ).

4.2. Enter P hard drive as the [primary] partition (primary ).

5. Input t to change the partition property of the hard disk.

6. Enter d to delete the partition property of the hard disk.

7. Input Q to the end and do not store it into the hard disk partition.

8. Enter W and write it to the hard disk partition property.

Eg:

Format and partition

HD-ide device SD-SCSI Device

Fdisk-L/dev/SDA view the first hard disk partition

Fdisk/dev/SDB partitions the second Hard Disk

Command Acton (M for help): m # displays the command list

A-set the bootable flag; B-set the volume label; D-delete a partition; n-create a partition.

P-display partition information; V-verify Partition Table; q-do not save disk exit; W-save disk exit; t-change partition type

Command Acton (M for help): n creates a partition.

Command action

E extended # extended partition

P primary partition (1-4) # primary Partition

P # create a primary Partition

Partition Number (1-4): 1 # create the first primary Partition

First cylinder (1-522, default 1): 1 # Start cylindrical (the first partition is always 1)

Last cylinder or + size or + sizem or + siezk (1-522, default 522): 10 # End cylindrical (if 522, the entire hard disk is allocated to a zone) the partition size is automatically calculated by the system based on the cylindrical size.

Command Acton (M for help): n

Command action

E extended

P primary partition (1-4)

P

Partition Number (1-4): 2 # create the second primary Partition

First cylinder (11-522, default 11): 11

Last cylinder... (11-522, default 522): + 100 m # custom partition size

Command Acton (M for help): n

Command action

E extended

P primary partition (1-4)

E # create an extended partition. Note that only one extended partition can be created for one disk.

Partition Number (1-4): 3

First cylinder (28-522, default 28): 28

Last cylinder... (28-522, default 522): 522 # allocate all the remaining space to the extended partition

Extended partitions cannot be used directly. You must create logical partitions on them!

Command Acton (M for help): n

Command action

L logical (5 or over) # logical Partition

P primary partition (1-4)

L

First Sylinder (28-255, default 28): 28 # create a logical partition in the extended partition

Last cylinder... (28-522, default 522): 522 # The number of cylinders is exhausted, which means only one logical partition is created.

Command Acton (M for help): W # Save and exit

Convert partition type:

Command Acton (M for help): T # convert the partition type

Partition Number (1-4): 2 # select the second primary Partition

HEX Code (type L to list codes): 82 # encoding corresponding to the partition type can be listed by L

You can run the "partprobe" command to re-test disk partition clearing, # partprobe/dev/SDB

Format and mount: (you can create or specify an empty directory)

Mksf. ext3/dev/sdb1 format the first primary partition of the second hard disk as ext3

Mkswap/dev/sdb2 initializes the swap zone, which cannot be formatted.

Mount/dev/sdb1/mnt/D # mount the first partition to the d directory.

Automatic mounting after restart: VI/etc/fstab

Add:/dev/sdb1/mnt/d ext3 default 0 0

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.