In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to use the Linux operating system partitioning tool Fdisk. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Fdisk is a hard disk partition tool under linux. The principle of hard disk partition is the same, but the tool format is different. One is the partition when the system is installed, and the other is the partition after the system is installed.
The partition when installing the system is generally impossible to modify and difficult to adjust after installing the system, and the hard disk space that is not partitioned when the system is installed can be operated or loaded by partition after installing the system.
This is mainly about this situation, one is the operation on the unpartitioned free hard disk, or the operation on the newly added hard disk.
Fdisk is about to be used here, but this can only be operated on a hard disk that is less than 2T, and if it is larger than 2T, it cannot be used. You have to use another parted tool.
One more thing, Linux's understanding of hard drives is that
/ dev/hd | sd (a | b | xxx) in this way
Hd is mainly for IDE hard drives, which is rare.
Most of them start with sd, including hard drives with stata,sas,scsi and other interfaces, such as
Hda is the first hard drive.
Hdb is the second hard drive.
Sda is the first hard drive.
Sdb is the second hard drive.
The order here is also related to one factor, that is, the interface order or jumper. We should know that there is a jumper in the hard disk interface, that is, a main hard disk and so on.
Here's how to use fdisk
Fdisk-l is a list of all hard drives, as follows
[root@hnwt ~] # fdisk-l
Disk / dev/sda: 320.0 GB, 320071851520 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/ dev/sda1 * 1 13 104391 83 Linux
/ dev/sda2 14 38913 312464250 8e Linux LVM
Fdisk / dev/sda means to operate the hard disk. After running this, you will enter the interactive state of fdisk, as follows
[root@hnwt ~] # fdisk / dev/sda
The number of cylinders for this disk is set to 38913.
There is nothing wrong with that, but this is larger than 1024
And could in certain setups cause problems with:
1) software that runs at boot time (e.g.old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help):
Here is a hint, pressing m will prompt you for a help, such as
Command (m for help): M
Command action
A toggle a bootable flag
B edit bsd disklabel
C toggle the dos compatibility flag
D delete a partition delete partition
L list known partition types lists all supported partition types
M print this menu displays this menu
New partition added to n add a new partition
O create a new empty DOS partition table
P print the partition table displays partition information
Q quit without saving changes exit does not save
S create a new empty Sun disklabel
T change a partition's system id changes the partition type
U change display/entry units
V verify the partition table
W write table to disk and exit writes to the partition table and exits
X extra functionality (experts only)
Command (m for help):
All the parameters are listed here.
According to the above tips, you can continue with the operation, as follows
Newly added partition
1 press n to add
2 Select primary partition / extended partition
3 starting value, you can enter by default.
4 partition size valu
Complete
Delete partition
1 press d
2. Select the corresponding partition number and enter.
Change the partition type
1 press t
2 Select Partition
3 Select partition type (press l to list all partitions and ID)
Under linux, this operation is mainly needed in a swap partition.
The general operation is like the three above
When all operations are done and make sure they are correct, you can press w to save and exit
If the operation is wrong, press Q to exit directly.
Do not test the environment / production environment online, otherwise you will bear the consequences.
For a test machine or virtual machine, you can operate it several times. Practice makes perfect.
The following is a supplement:
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 name is: / dev/hda,/dev/hdb,/dev/hdc,/dev/hdd, etc., and if there is an IDE Raid card, it 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?
/ sbin/mkfs.ext3 / dev/sda2
Mkdir / test
Modify / etc/fstab to restart the computer as follows
/ dev/sda2 / test ext3 defaults 1 1
Thank you for reading! This is the end of the article on "how to use the Linux operating system Partition tool Fdisk". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!
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.