The Linux fdisk command uses

Source: Internet
Author: User
Tags hex code

Fdisk on the hard disk and partition operation, into FDISK on the hard disk operation stage we can partition the hard disk operation, if you make fdisk-l understand; through fdisk-l, we can find out the number of drives and device names in the machine, for example above, we will see two devices one is /dev/hda, the other is/DEV/SDA; the command format for Fdisk to operate the hard disk is as follows: [[[email protected] beinan]# fdisk device such as we know fdisk-l or/d through/DEV/HDA  EV/SDA equipment; If you want to add or remove some partitions, you can use [[email protected] beinan]# fdisk/dev/hda or [[email protected] beinan]# fdisk /DEV/SDA Note In the following example, we will take the/DEV/SDA device as an example, to explain how to use Fdisk to manipulate the addition, delete the partition and other actions; Fdisk's description when we go through the FDISK device, the operation of the corresponding device, we will find a hint like the following; fdisk/d  EV/SDA equipment As an example, with the same as the following; [[email protected] beinan]# Fdisk/dev/sdacommand (M for help): press m here to output assistance; Command Actiona Toggle A bootable FLAGB edit BSD DISKLABELC toggle the DOS compatibility FLAGD Delete a partition note: This is the action of deleting a partition; L list known par Tition Types Note: L is a list of partition types for us to set the appropriate partition type; M print this menu note: M is a list of Help information; n Add a new partition note: Add a partition; O Create a new empty do s partition TABLEP print the partition table Note: P lists the partition tables; Q Quit without saving changes Note: Do not save exit; s create a new empty Sun DISKL Abelt change a partition ' s SYSTEM ID NOTE: T changes the partition type; u change display/entry unitsv Verify the partition Tablew write table to disk and exit Note: Write the partition table to the hard disk and exit; x E Xtra functionality (Experts only) Note: Extended application, expert function; in fact, we commonly use only the note has the Chinese, other functions we do not use (ah, mainly I will not be used, otherwise will show off); x extension function, also not commonly used  In general, as long as the understanding of D l m p Q t w on the line; The following example operation to detail, no example of no way, novice also do not understand; list the current operation of the disk partition, with Pcommand (M for help): pdisk/dev/sda:1035 MB, 1035730944 bytes256 heads, sectors/track, cylindersunits = cylinders of 16128 * = 8257536 bytesdevice Boot Sta RT End Blocks Id system/dev/sda1 1 201568+ C W95 FAT32 (LBA)/dev/sda2 806400 5 extended/dev/sda5 26 50 201568+ 8 3 Linux/dev/sda6 200781. Linux Deletes a partition command by using the D Directive of Fdisk (M for help): P Note: Lists the partitioning situation; disk/dev/sda:1035 MB, 103573094 4 bytes256 heads, sectors/track, cylindersunits = cylinders of 16128 * = 8257536 bytesdevice Boot Start End Blo cks Id system/dev/sda1 1 201568+ C W95 FAT32 (LBA)/dev/sda2 806400 5 Extended/dev/sda5 201568+ V/sda6 200781 Linuxcommand (MFor help): D Note: Performs a delete partition designation; Partition number (1-6): 6 Note: I want to delete Sda6, just enter 6; Command (M for help): P Note: Check the hard disk partition again to see if it is deleted? disk/dev/sda:1035 MB, 1035730944 bytes256 heads, sectors/track, cylindersunits = cylinders of 16128 * 512 = 82575 Bytesdevice Boot Start End Blocks Id system/dev/sda1 1 201568+ C W95 FAT32 (LBA)/dev/sda2 806400 5 extended/d Ev/sda5 201568+ Linuxcommand (M for help): Caution: Be careful when deleting partitions, please watch the partition number, if you delete the extended partition, the logical partition under the extended partition will be deleted; so be careful when you do it If you know your operation is wrong, please do not panic, with Q do not save the exit; Remember! When the partition operation is wrong, do not enter W Save exit!!! Add a partition command via the n instruction of Fdisk (M for help): pdisk/dev/sda:1035 MB, 1035730944 bytes256 heads, sectors/track, cylinders Units = Cylinders of 16128 * 8257536 bytesdevice Boot Start End Blocks Id system/dev/sda1 1 201568+ C W95 FAT32 ( LBA)/dev/sda2 806400 5 extended/dev/sda5 201568+ Linuxcommand (M for help): N Note: Add a partition; Command actionl log ical (5 or over) Note: Increase the logical partition, the partition number is greater than 5, why is greater than 5, because there is already a sda5; P primary partition (1-4) Note: Add a primary partition; numbering from 1-4; SDA1 and Sda2 are occupied, so only starting from 3; ppartition number (1-4): 3No free sectors available Note: Why failed in failure? Note: I tried to add a primary partition, which seems to be a failure, why failed? Because we see the main partition + extended partition of the entire disk is exhausted, look at the value of the end of the extended partition, and then see the P output message has the cylinders; it is better to look at the front part; there is a reference; so we can only add the logical Partition command (M for help): Ncommand actionl Logical (5 or over) p primary partition (1-4) L Note: Entering L here will enter the partitioning phase of the logical partition; First cylinder (51-125, default 51): Note: This is the start value of the partition, it is best to press ENTER directly, if you enter a non-default number, it will cause a waste of space; Using default value 51Last cylinder or +size or +sizem or +sizek (51-125 , default): +200m Note: This is the definition of partition size, +200m is the size of 200M, of course, you can also be based on the P hint of the unit cylinder size to calculate, and then to specify the value of end. Look back to see how it is, or use +200m this method to add, this can be intuitive. If you want to add a partition of about 10G size, enter +10000m; command (M for help): Specify the partition type command with the T instruction of Fdisk: T note: Specify the partition type by T; Partition Numb ER (1-6): 6 Note: Which partition type do you want to change? I have specified 6, which is Sda6hex code (type L to list codes): L Note: Here, you can see the ID of the partition type; Hex code (type L to list codes): B Note: If I want this partition to be W9 5 FAT32 type, through L view know B is indicated, so entered the b;changed system type of partition 6 to B (W95 FAT32) Note: System Information, change success, whether it is changed, please use P to view; Command (M For help): pdisk/dev/sda:1035 MB, 1035730944 bytes256 heads, sectors/track, cylindersunits = cylinders of 16128 * 512 = 825 7536 bytesdevice Boot Start End Blocks Id system/dev/sda1 1 201568+ C W95 FAT32 (LBA)/dev/sda2 806400 5 Extended /dev/sda5 201568+ Linux/dev/sda6 201568+ b W95 FAT32 6, Fdisk of the exit, with Q or W where q is not saved exit, W is to save the exit Command (M fo  R Help): W or Command (M for help): Q Four, an example of adding a partition in this example we will add two 200M primary partition, the other is extended partition, in the extended partition we add two 200M size logical partition Command (M for help): P NOTE: List partition table; disk/dev/sda:1035 MB, 1035730944 bytes256 heads, sectors/track, cylindersunits = cylinders of 16128 * 8257536 bytesdevice Boot Start End Blocks Id systemcommand (M for help): N Note: add partition; Command Actione EXTENDEDP Primary Partition (1-4) P Note: Add primary partition; partition number (1-4): 1 Note: Add Primary partition 1;first cylinder (1-125, default 1): Note: Direct carriage return, primary partition 1 start position; default is 1, default is OK Using default value 1Last cylinder or +size or +sizem or +sizek (1-125, default): +200m Note: Specify the partition size and +200m to specify a size of 200MComm and (M for help): N Note: Add newpartition; Command actione EXTENDEDP Primary partition (1-4) P Note: Add primary partition partition number (1-4): 2 Note: Add Primary partition 2;first cylinder (26-125, de Fault: Using default value 26Last cylinder or +size or +sizem or +sizek (26-125, default): +200m Note: Specify the partition size, using +200m to specify  Size 200MCommand (M for help): Ncommand actione EXTENDEDP Primary partition (1-4) E Note: Add an extended partition; partition number (1-4): 3 Note: specified as 3 , because the primary partition has been divided by two, this is also the primary partition, starting from 3; first cylinder (51-125, default 51): Note: Direct carriage, Using default value 51Last cylinder or +size or +s Izem or +sizek (51-125, default 125): Note: Direct carriage return, all the rest of the space to the extended partition; Using default value 125Command (M for help): Pdisk/dev/sda:1 035 MB, 1035730944 bytes256 heads, sectors/track, cylindersunits = cylinders of 16128 * = 8257536 bytesdevice B Oot Start End Blocks Id system/dev/sda1 1 201568+, Linux/dev/sda2, 201600, Linux/dev/sda3, 604800 5 exte Ndedcommand (M for help): Ncommand actionl Logical (5 or over) p primary partition (1-4) L Note: Add logical partition; First cylinder (51-125, Default): Using defaulT value 51Last cylinder or +size or +sizem or +sizek (51-125, default): +200m Note: Add a partition with a size of 200M; Command (M for help): Ncommand actionl Logical (5 or over) p primary partition (1-4) L Note: Add a logical partition; First cylinder (76-125, default): Using Defau Lt value 76Last cylinder or +size or +sizem or +sizek (76-125, default): +200m Note: Add a partition with a size of 200M; Command (m for help) : p lists the partition table; disk/dev/sda:1035 MB, 1035730944 bytes256 heads, sectors/track, cylindersunits = Cylinders of 16128 * 5 8257536 bytesdevice Boot Start End Blocks Id system/dev/sda1 1 201568+, Linux/dev/sda2, 201600  /sda3 604800 5 Extended/dev/sda5, 201568+, Linux/dev/sda6, 201568+, and then we change the partition type by the T instruction according to the above. Finally do not forget W save exit five, format the partition, and load the first hint; with Mkfs.bfs mkfs.ext2 mkfs.jfs mkfs.msdos Mkfs.vfatmkfs.cramfs mkfs.ext3 Mkfs.minix MKF S.reiserfs Mkfs.xfs and other commands to format the partition, such as I want to format Sda6 for ext3 file system, then enter; [[email protected] beinan]# Mkfs.ext3/dev/sda6 If I want to load SD A6 to the current system to access the file, there should be a mount command, butFirst you have to build a mount directory, such as/mnt/sda6; [[email protected] beinan]# mkdir/mnt/sda6[[email protected] beinan]# mount/dev/  Sda6/mnt/sda6[[email protected] beinan]# df-lhfilesystem capacity used available% mount point/dev/hda8 11G 8.4G 2.0G 81%//dev/shm 236M 0 236M 0%/dev/shm/dev/hda10 16G 6.9G 8.3G 46%/mnt/hda10/dev/sda6 191M 5.6M 176M 4%/mnt/sda6 So we can go into the/mnt/sda6 directory and save Take the file.

  

The Linux fdisk command uses

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.