Home System Tutorial LINUX Master Linux must-learn commands: how to use fidsk and practical examples

Master Linux must-learn commands: how to use fidsk and practical examples

Jun 12, 2024 pm 07:02 PM

掌握 Linux 必学命令:fidsk 的使用方法及实例演示

Preface

Write an article to share with you a command that must be learned under Linux: fidsk

If you don’t have a Linux environment at hand, you can refer to my previous article: Oops, I suddenly want to get a Linux centos8 system to play with, what should I do?

Introduction

Linuxfdisk is a program that creates and maintains partition tables. It is compatible with DOS-type partition tables, BSD or SUN-type c drive lists.

Usually we use it to manage Linux c drive, partition View Linux 64-bit system, low format and other operations.

is one of the must-learn commands for contacting Linux.

Sentence pattern

fdisk [必要参数][选择参数]
Copy after login

Required parameters:

Select parameters:

Menu operation instructions

Running environment

Before demonstrating the example, let me explain that the environment I am running this time is CentOS864

Example demonstration

1. Display the current partition situation

The most commonly used one here is fdisk-l, as follows:

As you can see from the picture, I only have a c drive /dev/sdaView linux 64-bit system, the size is 20G. There are two partitions in this disk, namely /dev/sda1 and /dev/sda2, with sizes of 1G and 19G respectively, as well as other information such as starting point and sector.

The two /dev/mappers below the picture are logical volume devices. We will not discuss them in this chapter, just know that there is such a thing.

In addition, if there are multiple c drives, you can also use fdisk-l/dev/sda followed by the c drive name to view them individually.

Simply put, that’s all for viewing fdisk. In other words, it meets daily needs.

Let’s talk specifically about how to use fdisk to build a new partition and mount it to the directory.

fdisk build new partition

need:

Add a new hard drive and require building a new partition and mounting it to /root/study_video

accomplish:

1. Add c drive

If it is a cloud server, just go to the background and lower the c drive.

If it is a chemical server, shut down the server and power off, open the chassis, and lower the c drive.

查看linux操作系统位数_查看linux 64位系统_linux查看位置

I am using VMware here and it crashes first. Let me teach you a little method, you can use the command: shutdown-hnow to crash

linux查看位置_查看linux操作系统位数_查看linux 64位系统

After returning to VMware, you can see that it is also frozen here.

We double-click the c drive (SCSI) location in the picture on the right.

linux查看位置_查看linux 64位系统_查看linux操作系统位数

Click below to add a button

查看linux 64位系统_查看linux操作系统位数_linux查看位置

Select the c drive in the new panel that opens and click Next

查看linux 64位系统_查看linux操作系统位数_linux查看位置

Default, next step

linux查看位置_查看linux操作系统位数_查看linux 64位系统

Here you can choose to create the c drive mode, such as directly loading it using the one created before, or recreating it.

If not necessary, just continue with the default and next step.

linux查看位置_查看linux 64位系统_查看linux操作系统位数

Adjust the size, set other defaults, and continue to the next step (I have too few learning materials, so the capacity is set to 5G, you can use it as you like [silly laugh])

linux查看位置_查看linux 64位系统_查看linux操作系统位数

查看linux操作系统位数_查看linux 64位系统_linux查看位置

If there is no need to rename, just default and click Finish

查看linux 64位系统_查看linux操作系统位数_linux查看位置

Looking at the settings panel now, is there an extra hard drive?

ok, click OK to close the panel.

查看linux操作系统位数_查看linux 64位系统_linux查看位置

2. Create partition

Turn on the computer and connect to Xshell (if you don’t know how to connect, you can refer to my article: Let’s talk about the collision between VMware16’s centos8 and Win10’s Xshell).

Afterwards, fdisk-l is used again to view the c drive information. The results are as follows:

It is obvious that the new c drive has been downloaded successfully, and the partition operation is carried out below.

①After fdisk command + c drive device name

linux查看位置_查看linux 64位系统_查看linux操作系统位数

You can see the software prompts, pay attention to red hat linux, this is a high-risk operation. Be careful, careful, careful!

Enter m at this time to see the help information:

查看linux操作系统位数_linux查看位置_查看linux 64位系统

查看linux操作系统位数_查看linux 64位系统_linux查看位置

If you forget the specific command during temporary operation, you can check it at any time through this function.

Here we enter n to build a new partition:

查看linux 64位系统_linux查看位置_查看linux操作系统位数

Default directly and create a primary partition.

linux查看位置_查看linux操作系统位数_查看linux 64位系统

This is usually the direct default.

If you are interested in partitioning, you can refer to this article of mine: Briefly talk about the relationship and number restrictions between primary partitions/expanded partitions/logical partitions in Linux

After that comes the track settings. Here you will be asked to start and end, that is, select the capacity of the current partition. We directly default here, and the system will allocate all the capacity of the c drive to this partition.

Look, as shown in the picture above, the new partition has already been constructed.

Use the p command to query the newly built partition:

As you can see, /dev/sdb1 already exists. And you can't use it to check the disk space in Linux yet. At least before we mount it, we have to low-level it.

Enter w first to save changes:

linux查看位置_查看linux 64位系统_查看linux操作系统位数

After saving, you will find a prompt message, and then manually exit the operation command interactive mode.

After that, we use the mkfs command to low-format it, here it is formatted into an ext4 partition.

ok, partition construction and low formatting are completed. Next, mount to the directory.

Mount partition to directory

As mentioned in it, we need to mount this partition to the study material folder in the /home directory. Here we need to create the /home/study_video directory first, and then use the mount command to mount it.

Specific examples are as follows:

Get it done and call it a day!

Summarize

There are two functions of fdisk:

1. View the C drive overview

2. Operate the c drive, such as partition

Although it seems like a lot, it is not difficult after all. When you need to operate, just follow my steps one by one.

查看linux 64位系统_linux查看位置_查看linux操作系统位数

The above is the detailed content of Master Linux must-learn commands: how to use fidsk and practical examples. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1655
14
PHP Tutorial
1254
29
C# Tutorial
1228
24
What are the 5 basic components of Linux? What are the 5 basic components of Linux? Apr 06, 2025 am 12:05 AM

The five basic components of Linux are: 1. The kernel, managing hardware resources; 2. The system library, providing functions and services; 3. Shell, the interface for users to interact with the system; 4. The file system, storing and organizing data; 5. Applications, using system resources to implement functions.

How to learn Linux basics? How to learn Linux basics? Apr 10, 2025 am 09:32 AM

The methods for basic Linux learning from scratch include: 1. Understand the file system and command line interface, 2. Master basic commands such as ls, cd, mkdir, 3. Learn file operations, such as creating and editing files, 4. Explore advanced usage such as pipelines and grep commands, 5. Master debugging skills and performance optimization, 6. Continuously improve skills through practice and exploration.

What is the most use of Linux? What is the most use of Linux? Apr 09, 2025 am 12:02 AM

Linux is widely used in servers, embedded systems and desktop environments. 1) In the server field, Linux has become an ideal choice for hosting websites, databases and applications due to its stability and security. 2) In embedded systems, Linux is popular for its high customization and efficiency. 3) In the desktop environment, Linux provides a variety of desktop environments to meet the needs of different users.

What is a Linux device? What is a Linux device? Apr 05, 2025 am 12:04 AM

Linux devices are hardware devices running Linux operating systems, including servers, personal computers, smartphones and embedded systems. They take advantage of the power of Linux to perform various tasks such as website hosting and big data analytics.

Does the internet run on Linux? Does the internet run on Linux? Apr 14, 2025 am 12:03 AM

The Internet does not rely on a single operating system, but Linux plays an important role in it. Linux is widely used in servers and network devices and is popular for its stability, security and scalability.

What are Linux operations? What are Linux operations? Apr 13, 2025 am 12:20 AM

The core of the Linux operating system is its command line interface, which can perform various operations through the command line. 1. File and directory operations use ls, cd, mkdir, rm and other commands to manage files and directories. 2. User and permission management ensures system security and resource allocation through useradd, passwd, chmod and other commands. 3. Process management uses ps, kill and other commands to monitor and control system processes. 4. Network operations include ping, ifconfig, ssh and other commands to configure and manage network connections. 5. System monitoring and maintenance use commands such as top, df, du to understand the system's operating status and resource usage.

What are the disadvantages of Linux? What are the disadvantages of Linux? Apr 08, 2025 am 12:01 AM

The disadvantages of Linux include user experience, software compatibility, hardware support, and learning curve. 1. The user experience is not as friendly as Windows or macOS, and it relies on the command line interface. 2. The software compatibility is not as good as other systems and lacks native versions of many commercial software. 3. Hardware support is not as comprehensive as Windows, and drivers may be compiled manually. 4. The learning curve is steep, and mastering command line operations requires time and patience.

What is the salary of Linux administrator? What is the salary of Linux administrator? Apr 17, 2025 am 12:24 AM

The average annual salary of Linux administrators is $75,000 to $95,000 in the United States and €40,000 to €60,000 in Europe. To increase salary, you can: 1. Continuously learn new technologies, such as cloud computing and container technology; 2. Accumulate project experience and establish Portfolio; 3. Establish a professional network and expand your network.

See all articles