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

藏色散人
Release: 2023-01-04 16:44:19
Original
9873 people have browsed it

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!

Related labels:
source:php.cn
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!