In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the relevant knowledge of "how to achieve disk partitioning in Linux". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Disk partition 1. Formatting
(1) Why should it be zoned?
Formatting is to establish order in empty space, that is, to establish a file system (file system types such as squares, rectangles, etc.)
Supports multiple file systems and is easy to manage.
(2) generally speaking, we partition before formatting (because we can format different file systems after partitioning)
two。 Disk on which data is stored
The characteristic of hash table is that data is found very quickly.
First calculate the hashcode (hash code) of the data-- save it to the corresponding location-- if the two characters hashcode are equal, then store a linked list with both characters pointing to the same location, and then look for it in the linked list (so that there is no conflict)
Note: if the calculated hashcode is the same, you also need to perform an equals operation to really determine whether the two characters are the same.
(it takes less time to judge whether characters are equal by hash codes. If the hash codes are all the same, you can only call the function equals directly to compare whether the two characters are equal.)
3. Disk partition
If you need to find the data in a disk, you can jump to a disk character directly through the partition information, so you don't have to traverse it from scratch.
There is partition information in the first track of the first cylinder of the disk, which is called the hard disk partition table. If this piece is damaged, the hard disk is destroyed (I don't know where the hard disk starts and ends). The partition table can only record information about four partitions, so the computer's hard disk can only be divided into four pieces.
Partition on hard disk:
(1) Primary partition (usually the disk on which the operating system is installed, of course, other disks can also be installed with the operating system, which is equivalent to disk C in Windows)
(2) extended partition (there can be up to four primary partitions + extended partitions, and logical partitions can be divided in the extended partition, which is equivalent to the DEF disk in Windows)
Note: the above figure means that the disk is divided into two areas, a primary partition and an extended partition. The extended partition is divided into a plurality of logical partitions, and the partition information is recorded in the first byte of the logical partition.
(3) logical partition (extended partition can be divided into several logical partitions)
Non-destructive partitioning software:
Linux partition naming
In Linux, all devices are files, which are divided into two categories: character devices and binary devices (block devices). Printers and keyboards are character devices, while USB drives and optical drives are block devices. The names of all devices are fixed and cannot be changed (the drive letter name can be modified in Windows). The advantage of this is that programming is simple and only needs to program files.
1. / dev directory-hardware
All device files are located in the dev directory.
For the naming of this hardware: the first two letters of the partition name-the type of device on which the partition is located (hd-IDE,sd-SCSI), y indicates which interface on the motherboard (usually represented by an and b), and N represents the partition (the first four partitions, that is, primary and extended partitions are arranged according to 1x4, logical partitions start at 5).
For example: / dev/hda3- the third primary or extended partition on the first IDE hard disk; in Windows, disk D is named the equivalent of hda5 in Linux (disk D is the first logical partition and disk F is hda7).
Go to the graphical interface
Start X (the graphical interface is called X_Window in linux)
Return to the command line: right-click-- open terminal
Note: forget yourself: whoami
Operation of mount point
If I want to access the contents of a hardware device (such as a CD-ROM drive), executing cd / cdrom displays not a directory (it shows that it is not a directory, and Linux thinks it is a device, so it cannot be accessed). We can think of it as a directory (in theory, it can be seen as any path, but the default is in / mnt under the root path), which requires us to create a directory and associate it with the device.
(the devices under the dev directory are all devices, so we can't access the devices directly, but we use the idea of "mounting", that is, to associate the device with our own defined directory, and accessing this directory is equivalent to accessing the device.)
-- find the path: cd dev/mnt
-- create a new file as a temporary attachment point mkdir cdr
(mkdir- create directory, touch- new text)
-- attach to mount / dev/cdrom [space] / mnt/cdr (note that there is a space after cdrom, otherwise an error will be reported)
(the mounting and unmounting operations here are all done in the mnt directory.)
Cdrom is our device, and cdr is the mount point. Accessing cdrom can be accessed through the device and mount point.
Note:
-- Unmount (you can use the device name or mount name)
Umount / dev/cdrom
Umount / mnt/cdr
View the details of the mount point:
Reason: the directory we are in now is already inside the CD-ROM drive, so we should come out to the outside of the CD-ROM drive before we can perform the relevant operations.
Note: we should unmount it in the mnt directory, not in the dev directory. Here is a typical error:
Cd.-- return to the previous directory
Obtain administrator privileges-su root
Note: $will change to # after obtaining administrator privileges.
Physical structure of disk
If there is no MBR, the hard drive will not work.
Expansion: MBR
The main boot sector of the hard disk is one of the most sensitive areas in the hard disk. The master boot record is located on the 0 track 0 cylinder of the hard disk, with a total 512bytes, which is composed of three parts:
Hard disk master boot record MBR (Master Boot Record) occupies 446bytes
Partition table DPT (Disk Partition Table) occupies 64bytes
Hard disk valid flag (Magic Number) occupies 2bytes
Master boot record (MBR) is used to detect the correctness of the hard disk partition and determine the active partition, its content is written by the partition software (such as FDISK) to the sector when the hard disk partition, so MBR does not belong to any operating system, does not vary with the operating system, even if different, MBR will not entrainment the nature of the operating system, with the characteristics of public boot. The task of MBR is to hand over the boot power to the operating system. If this record is damaged, it will not be able to boot from the hard disk.
Therefore, the main boot area of the hard disk has also become the main target of virus attacks, and some other software will also modify the contents of the boot area. If the modification is wrong, the hard disk will not be able to start. The main boot sector is destroyed, and the system will mention "quot;Disk boot failure, Insert system disk and press enter" after booting.
Disk partition comparison 1. Windows partition
2. Partition comparison between Linux and Windows
Disk partitioning scheme 1. At least two partitions
(1) Root partition: /-- that is, the partition on the hard disk is mounted on /, / usr
(2) SWAP partition
(using the hard disk as memory, that is, virtual memory, must have and must be a separate partition, which is generally set to twice the actual memory size. Some programs default to insufficient physical memory and put it in physical memory, so it is necessary to set up SWAP partitions no matter how large the actual physical memory is.)
two。 Partition manually before installation
Note: the so-called root partition is an area on the hard disk and mounted to the root partition, not the CDEF disk in Winodws. Other partitions are mounted in this way, so what is listed here is the name of the partition mount point, not the partition name.
(what we enumerate here are the names of partition mount points, because manual partitions can only change directory names, but the real device names cannot be changed.)
3. Directory under the root directory
Partition is required during the installation of Linux, either manually or automatically. (at first we can partition automatically)
Expansion: what is the root directory and what is its function?
The root directory is the most important directory in the whole system, because not only all directories are derived from the root directory, but also related to boot / restore / system repair actions. Therefore, the FHS standard recommends that the partition of the root directory (/) should be as small as possible, and the software installed by the application should not be placed in the same partition as the root directory, so as to keep the root directory as small as possible. In this way, not only is the performance better, but also the file system where the root directory is located is less prone to problems. To put it bluntly, the root directory is the same as the C disk of Windows.
Introduction to Linux common catalogs
This is the end of the content of "how to achieve disk partitioning in Linux". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.