Home Operation and Maintenance Linux Operation and Maintenance What is the command to mount a hard disk in Linux?

What is the command to mount a hard disk in Linux?

Jan 03, 2023 am 11:22 AM
linux

The Linux hard disk mounting command is "mount". The method of mounting a new hard disk is: 1. Use the "fdisk -l" command to list the currently connected hard disks in the system; 2. Use the m command to view fdisk Internal command of the command; 3. Enter the disk and partition the disk; 4. Format the partition; 5. Create the "/data1" directory through "#mkdir /data1"; 6. Through "#mount /dev/sdb1 /data1" Just run the command to mount the partition.

What is the command to mount a hard disk in Linux?

#The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.

What is the command to mount a hard disk in Linux?

Mount a new hard disk on the Linux server:

Linux hard disk identification:

Generally use the "fdisk -l" command. List the currently connected hard disks in the system

Device and partition information. If the new hard disk has no partition information, only the hard disk size information will be displayed.

1. Shut down the server and add the new hard disk

2. Start the server and log in as root user

3. Check the hard disk information

#fdisk -l
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0004406e
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          39      307200   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              39        2589    20480000   83  Linux
/dev/sda3            2589        2850     2097152   82  Linux swap / Solaris
/dev/sda4            2850        5222    19057664    5  Extended
/dev/sda5            2850        5222    19056640   83  Linux
 
Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x14b52796
   Device Boot      Start         End      Blocks   Id  System
Copy after login

4. Create a new hard disk partition Command parameters:

fdisk can be done with the m command Look at the internal commands of the fdisk command;

a: The command specifies the boot partition;

d: The command deletes an existing partition;

l: The command displays the list of partition ID numbers ;

m: View fdisk command help;

n: Command to create a new partition;

p: Command to display partition list;

t: Command Modify the type ID number of the partition;

w: The command is to save the modification to the partition table and let it take effect

5. Enter the disk and partition the disk. Pay attention to the red part.

#fdisk /dev/sdb
Command (m for help):n
Command action
     e    extended                  //输入e为创建扩展分区
     p    primary partition (1-4)      //输入p为创建逻辑分区
p
Partion number(1-4):1      //在这里输入l,就进入划分逻辑分区阶段了;
First cylinder (51-125, default 51):   //注:这个就是分区的Start 值;这里最好直接按回车,如果您输入了一个非默认的数字,会造成空间浪费;
Using default value 51
Last cylinder or +size or +sizeM or +sizeK (51-125, default 125): +200M 注:这个是定义分区大小的,+200M 就是大小为200M ;当然您也可以根据p提示的单位cylinder的大小来算,然后来指定 End的数值。回头看看是怎么算的;还是用+200M这个办法来添加,这样能直观一点。如果您想添加一个10G左右大小的分区,请输入 +10000M ;
Command (m for help): w                     //最后输入w回车保存。
Copy after login

Check it:

#fdisk -l
Copy after login

You can see the /dev/sdb1 partition, I will omit the screenshot.

6. Format the partition

#mkfs.ext3 /dev/sdb1   //注:将/dev/sdb1格式化为ext3类型
mke2fs 1.41.12 (17-May-2010)文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
640848 inodes, 2562359 blocks
128117 blocks (5.00%) reserved for the super user第一个数据块=0
Maximum filesystem blocks=2625634304
79 block groups
32768 blocks per group, 32768 fragments per group
8112 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
 
This filesystem will be automatically checked every 35 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
Copy after login

After formatting, we can use mount to load the partition and then use this file system;

7. Create / data1 directory:

#mkdir /data1
Copy after login

8. Start mounting the partition:

#mount /dev/sdb1 /data1
Copy after login

9. Check the hard disk size and mount the partition:

#df -h
Copy after login

10. Configure automatic mounting at boot

Because the mount will become invalid after restarting the server, you need to write the partition information to the /etc/fstab file to make it permanently mounted:

#vim /etc/fstab
Copy after login

Join:

/dev/sdb1(磁盘分区) /data1(挂载目录) ext3(文件格式)defaults 0 0
Copy after login

11. Restart the system

#reboot
Copy after login

Recommended study: "Linux Video Tutorial"

The above is the detailed content of What is the command to mount a hard disk in Linux?. 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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

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)

How to solve the permissions problem encountered when viewing Python version in Linux terminal? How to solve the permissions problem encountered when viewing Python version in Linux terminal? Apr 01, 2025 pm 05:09 PM

Solution to permission issues when viewing Python version in Linux terminal When you try to view Python version in Linux terminal, enter python...

Why does an error occur when installing an extension using PECL in a Docker environment? How to solve it? Why does an error occur when installing an extension using PECL in a Docker environment? How to solve it? Apr 01, 2025 pm 03:06 PM

Causes and solutions for errors when using PECL to install extensions in Docker environment When using Docker environment, we often encounter some headaches...

How to efficiently integrate Node.js or Python services under LAMP architecture? How to efficiently integrate Node.js or Python services under LAMP architecture? Apr 01, 2025 pm 02:48 PM

Many website developers face the problem of integrating Node.js or Python services under the LAMP architecture: the existing LAMP (Linux Apache MySQL PHP) architecture website needs...

How to solve permission issues when using python --version command in Linux terminal? How to solve permission issues when using python --version command in Linux terminal? Apr 02, 2025 am 06:36 AM

Using python in Linux terminal...

How to configure apscheduler timing task as a service on macOS? How to configure apscheduler timing task as a service on macOS? Apr 01, 2025 pm 06:09 PM

Configure the apscheduler timing task as a service on macOS platform, if you want to configure the apscheduler timing task as a service, similar to ngin...

Can the Python interpreter be deleted in Linux system? Can the Python interpreter be deleted in Linux system? Apr 02, 2025 am 07:00 AM

Regarding the problem of removing the Python interpreter that comes with Linux systems, many Linux distributions will preinstall the Python interpreter when installed, and it does not use the package manager...

Four ways to implement multithreading in C language Four ways to implement multithreading in C language Apr 03, 2025 pm 03:00 PM

Multithreading in the language can greatly improve program efficiency. There are four main ways to implement multithreading in C language: Create independent processes: Create multiple independently running processes, each process has its own memory space. Pseudo-multithreading: Create multiple execution streams in a process that share the same memory space and execute alternately. Multi-threaded library: Use multi-threaded libraries such as pthreads to create and manage threads, providing rich thread operation functions. Coroutine: A lightweight multi-threaded implementation that divides tasks into small subtasks and executes them in turn.

How to open web.xml How to open web.xml Apr 03, 2025 am 06:51 AM

To open a web.xml file, you can use the following methods: Use a text editor (such as Notepad or TextEdit) to edit commands using an integrated development environment (such as Eclipse or NetBeans) (Windows: notepad web.xml; Mac/Linux: open -a TextEdit web.xml)

See all articles