In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
How is the fdisk command used in Linux? Many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can gain something.
Fdisk under Linux is extremely powerful and can be used to divide the most complex partitions. Here is a brief description of its usage:
For IDE hard drives, each disk has a device name: corresponding to the four IDE interfaces of the motherboard, the device names are: / dev/hda,/dev/hdb,/dev/hdc,/dev/hdd, etc.
If there is also an IDE said card, the order is: / dev/hde,/dev/hdf,/dev/hdg,/dev/hdh. For SCSI hard drives, the device name is / dev/sda,/dev/sdb... Wait
The command line usage of fdisk is: fdisk hard disk device name
After entering fdisk, you can type'm _ menu first to display the full menu of fdisk.
Type'pause 'again to display the current partition table status.
Type'npartition, add a partition, and you will be prompted 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), of which: the basic partition can be divided into up to four, and the extended partition can be divided into at most one. However, multiple logical partitions can be divided within the extended partition (at most, I have not tried, in short, many). After selecting the partition type and partition number you want to create, you will be prompted to enter the starting cylinder, starting from 1, and then enter the ending cylinder, at this time you can enter the actual number of cylinders, or you can enter "+ partition size". For example: + 1024m means to add 1024m after the starting cylinder. The device name of the primary partition is / dev/hda1,/dev/hda2,/dev/hda3,/dev/hda4, and the device name of the logical partition is / dev/hda5,/dev/hda6,/dev/hda7.... Wait.
Type 'dink' to delete the partition and enter the partition number to delete it. Note that when you delete an extended partition, all logical partitions are deleted at the same time.
Type'tswitch, and change the partition flag (this is the best part of Linux's fdisk!). The default mark for the new partition is 83 (Linux Ext2). You can change it to 82 (Linux exchange), or'b' (FAT32),'f' (FAT32 Extend, only for extended partitions). No, no, no. And so on dozens of types. In this way, friends who use multiple operating systems can use Linux's fdisk to partition all the partitions you want!
Type'aactivation'to toggle the partition activation switch. Please note: each time you type, the selected partition will change between active and inactive, but you must make sure that only one partition is activated in the end. At this point, you will get the'p 'command, and there will be a' * 'number on the activated partition.
In addition to the above commands, there are several others, but they are not very commonly used.
Finally, type 'changes', and your changes to the partition will be written to the hard disk; type'Q changes' and all changes will be discarded.
Flexible use of fdisk, you can also repair some damaged partition tables, as long as you must accurately remember the original starting and ending cylinders of each partition.
Add a way to format the hard drive:
To format the partition into Linux Ext2 format, use: mkext2fs / dev/hda?
To format the partition into FAT32 format, use: mkfs.vfat / dev/hda?
Annex 2:
Instruction: fdisk
Purpose: to observe the physical use of the hard disk and to divide the hard disk.
How to use it:
First, enter fdisk-l / dev/sda on console to observe the physical usage of the hard disk.
Second, enter fdisk / dev/sda on console to enter split hard disk mode.
1. Enter m to display all command lists.
two。 Enter p to display the hard disk partition situation.
3. Enter a to set the hard drive boot area.
4. Enter n to set a new hard disk partition.
4.1. Enter the e hard disk as a [extended] partition (extend).
4.2. Enter p hard disk as the [main] partition (primary).
5. Enter t to change the partition properties of the hard disk.
6. Enter d to delete the hard disk partition properties.
7. Enter Q to finish not saving the hard disk partition attribute.
8. Enter w to end and write the hard disk partition attribute
Eg:
Formatting and partitioning
Hd--IDE device sd--SCSI device
Fdisk-l / dev/sda to check the partition of the first hard disk
Fdisk / dev/sdb partitions the second hard disk
Command acton (m for help): M # displays a list of commands
A-set bootable flag; b-set volume label; d-delete a partition; n-create a new 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 New partition
Command action
E extended # extended partition
P primary partition (1-4) # Primary Partition
P # create primary partition
Partition number (1-4): 1 # create the first primary partition
First cylinder (1-522): 1 # starting cylinder (the first partition is always 1)
Last cylinder or + size or + sizeM or + siezK (1-522): 10 # cutoff cylinder (if 522, the whole hard disk is allocated to a zone) this partition size is automatically calculated by the system according to the cylinder size.
Command acton (m for help): n
Command action
E extended
P primary partition (1-4)
P
Partition number (1-4): 2 # create a second primary partition
First cylinder (11-522): 11
Last cylinder... (11-522): + 100m # 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 extent can be created on a disk
Partition number (1-4): 3
First cylinder (28-522): 28
Last cylinder. (28-522): 522 # allocate all the remaining space to the extended partition
Extended partitions cannot be used directly, and logical partitions must be created on them!
Command acton (m for help): n
Command action
L logical (5 or over) # logical partitioning
P primary partition (1-4)
L
First sylinder (28-255): 28 # create logical partitions in extended partitions
Last cylinder. (28-522): 522 # cylinder is exhausted, which means that only one logical partition is built.
Command acton (m for help): W # save exit
Convert the partition type:
Command acton (m for help): t # converts partition types
Partition number (1-4): 2 # Select the second primary partition
Hex code (type L to list codes): 82 # list the encodings corresponding to the partition type by L
You can use the "partprobe" command to re-detect disk partition emptying, # partprobe / dev/sdb
Format and mount: (the mount directory can be created by itself or you can specify an empty directory that exists)
Mksf.ext3 / dev/sdb1 formats the first primary partition of the second hard disk as ext3
Mkswap / dev/sdb2 initializes the swap area, which cannot be formatted.
Mount / dev/sdb1 / mnt/d # Mount the first partition to the d directory
Auto mount after restart: vi / etc/fstab
Add: / dev/sdb1 / mnt/d ext3 default 0 0
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.