Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux system disk partitioning and mounting-fdisk

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Linux system disk partitioning and mounting-fdisk

Text keywords: file system, disk partition, format, mount

1. File system 1. The role of the file system

When we get a new hard drive, the maximum space it can support is only a parameter on the hardware. If we want it to work properly, we must have a corresponding file system. The file system determines the way and data structure in which files are stored and managed, that is, how to manage files and folders on disk. Different file systems have different characteristics, which is why we have to choose a file system for formatting operations.

When using a file system in an operating system (Windows, Linux, MacOS), there is usually a unified interface for reading and writing files, so there will be situations where some file systems are only suitable for a certain operating system.

System call interface: the interface provided by the system for users virtual file system: integrate the API interface of different file systems, using a unified way to operate, such as mounting, creating directories and other file systems: the specific file system type, the user through the format command to determine the general block device layer: manage different hard disk drivers Provide a unified interface device driver for the last time: there will be corresponding drivers for different hardware devices to ensure that the disk is available, and the general hard disk driver will be compiled directly into the kernel 2. Common Linux file system MINIX:Linux is the earliest file system used. At present, mainstream versions of Linux systems no longer use the file systems (EXT2, EXT3, EXT4) mainly used by EXT:CentOS 5 EXT3 6. EXT3: maximum single partition capable of managing 16TB, single file EXT4 of 2TB: maximum single partition capable of managing 1EB 16TB's single file FAT: Microsoft's early file systems (FAT12, FAT16, FAT32) FAT16: up to a single partition of 2GB, 2GB's single file FAT32: up to a single partition of 2TB, 4GB's single file NTFS: current Windows system mainstream file system maximum single manageable single partition: 2TB maximum supported single file: 2TBSWAP: strictly speaking, it is not a kind of file system It belongs to the memory swap partition, which is similar to the virtual memory of Windows. When the running memory of the system is insufficient, this part of the space will be used as memory. Since it is not used to store files, formatting and enabling will be different. Add a hard disk

This article uses the VMware virtual machine to demonstrate the process of adding a new hard disk.

If it is added in the boot state, you need to restart the boot virtual machine to identify 1. Open virtual machine settings

two。 Add Devic

3. Hard disk type selection

If you are operating on a real machine, you don't have to worry about this, just plug it in. The SCSI is used in this example, so be sure to restart the virtual machine after adding it.

IDE: the maximum speed of the interface is 133MB/s, which has been gradually replaced by SATA. SCSI: minicomputer system interface, suitable for workstations and personal PC and server SATA: hot-swappable, much faster than IDE

4. Hardware creation Wizard

It is recommended that you choose: store the virtual disk as a single file, it will be faster to use it.

3. Disk partition 1. MBR partition table

A partition table is a record of the entire disk partition, which takes up 512bytes (1 sector) space for MBR-type partition tables. MBR partition table does not support hard drives above 2TB.

Master boot record: occupy 446bytes partition table: there are up to four partitions, including primary partition and extended partition, occupy 64bytes partition Terminator: 55AA, occupy 2bytes

two。 Hard disk identification device information directory: / dev for IDE type disks, naming format: / dev/hd [Amurd] for SATA/SCSI/SAS type disks, naming format: / dev/sd [Amurp] before adding: only the default hard disk is recognized as sdasda1 and sda2 as partition numbers

After addition: a newly identified hard drive appears and is recognized as sdb

3. Zoning tool: fdisk

Use the fdisk tool to partition the disks below 2TB, use the MBR partition table, and use the parted tool for disks larger than 2TB.

Check the identified hard drive: fdisk-l

4. Set up a partition use the fdisk tool to partition the specified disk (be sure to specify the disk, otherwise it is easy to crash your own system): fdisk / dev/sdb

Partition step use the command n New Partition Select Partition Type Select Partition number (logical Partition without this step) Select start location Select end location (to specify the amount of space allocated)

Usually we need to decide the termination position according to the size of the allocated space, directly using the format of + size {K _ M _ M _ G}.

Set up primary partition: allocate space for 5GB command: n type: P number: 1 start position: 1 end position: + 5G partition table print: P

Set extended partition: allocate all remaining space command: n type: e number: 2 start position: enter end position: enter partition table print: P

Set logical partition: create two new space commands with the size of 5GB: n type: l start position: enter end position: + 5G command: n type: l start position: enter end position: + 5G partition table print: P

Save exit: command w

4. Format 1. File system format ext4 format: format the first primary partition as the ext4 file system mkfs.ext4 / dev/sdb1

Fat32 format: format the first logical partition as the ext4 file system mkfs.vfat-32 / dev/sdb5

2. Swap space formatting

Format the second logical partition to type swap

Mkswap / dev/sdb6

5. Mount and enable 1. Mounting of the file system

The mount of the file system is mainly divided into two steps: determine the mount point-> mount. In this example, two folders will be created under the / mnt path as the mount point. Before mounting, the directory belongs to the original disk sda, and the sda free space will be displayed when viewing the free space. If the mount is successful, storing files in this directory will take up sdb space, and the files will also be stored on sdb disk, and the usage space of the corresponding partition in sdb will be displayed when viewing the available space.

Mount a primary partition to the / mnt/ext4 directory mkdir / mnt/ext4df-h / mnt/ext4

Mount / dev/sdb1 / mnt/ext4df-h / mnt/ext4

Mount the first logical partition to the / mnt/fat32 directory mkdir / mnt/fat32df-h / mnt/fat32

Mount / dev/sdb5 / mnt/fat32df-h / mnt/fat32

The unmount command is: umount, which requires only one parameter, which can be either the partition name or the mount point 2. Enable of swap space

Because swap is a piece of space used to act as memory, we don't store files directly into it, and naturally we don't need a mount point, just enable it.

Swapon: enable swapoff: disable enable the swap space swapon / dev/sdb6 corresponding to the second logical partition

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report