What does dev/hda5 mean in linux

青灯夜游
青灯夜游Original
2022-11-11 18:06:252821browse

dev/hda5 represents the logical partition of the main disk on the IDE0 interface in Linux. All Linux devices are represented as a file in the "/dev" directory, and the devices starting with "hd" in the ".dev" directory are IDE hard disks. The third letter in the device name is a, which represents the first hard disk (also known as the primary disk); the partition is represented by a number. The numbers 1 to 4 are used to represent the primary partition or extended partition. The number of the logical partition starts from 5. .

What does dev/hda5 mean in linux

#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

dev/hda5 in Linux represents the logical partition of the main disk on the IDE0 interface.

All devices in Linux are represented as a file in the /dev directory. Devices starting with "hd" in the .dev directory are IDE hard disks, and devices starting with "sd" are SCSI hard disks.

The third letter in the device name is a, which means the first hard disk (also becomes the master disk), and b means the second hard disk (also becomes the slave disk).

Partitions are represented by numbers. The numbers 1 to 4 are used to represent primary partitions or extended partitions. The number of logical partitions starts from 5. The primary partition of the main disk on the IDE0 interface is called /dev/hda1; and /dev/hda2 represents the extended partition of the main disk on the IDE0 interface; the first logical partition of the main disk on the IDE0 interface is called /dev/hda5

linux logical partition

When we need more partitions, we need to give up one of the primary partitions. Generally, after creating three primary partitions, the fourth A partition is divided into an extended partition, and the extended partition is divided into several logical partitions for use.

1. Demonstrate the effect of creating four primary partitions

1) Create four partitions (See the previous article for specific steps)

//进入分区工具
[root@localhost ~]# fdisk /dev/sdb
欢迎使用 fdisk (util-linux 2.23.2)。

更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。


命令(输入 m 获取帮助):n
Partition type:
   p   primary (3 primary, 0 extended, 1 free)
   e   extended
Select (default e): p
已选择分区 4
起始 扇区 (5015552-10485759,默认为 5015552):
将使用默认值 5015552
Last 扇区, +扇区 or +size{K,M,G} (5015552-10485759,默认为 10485759):
将使用默认值 10485759
分区 4 已设置为 Linux 类型,大小设为 2.6 GiB

命令(输入 m 获取帮助):w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
正在同步磁盘。

2) Try to create a fifth partition

[root@localhost ~]# fdisk /dev/sdb
欢迎使用 fdisk (util-linux 2.23.2)。

更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。

//创建第五个分区提示需要放弃一个主分区创建一个扩展分区
命令(输入 m 获取帮助):n
If you want to create more than four partitions, you must replace a
primary partition with an extended partition first.

命令(输入 m 获取帮助):p    //展示分区表

磁盘 /dev/sdb:5368 MB, 5368709120 字节,10485760 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x6928af85

   设备 Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     4196351     2097152   83  Linux
/dev/sdb2         4196352     4605951      204800   83  Linux
/dev/sdb3         4605952     5015551      204800   83  Linux
/dev/sdb4         5015552    10485759     2735104   83  Linux

命令(输入 m 获取帮助):

3) Delete the fourth primary partition and divide it into extended partition

命令(输入 m 获取帮助):d        //输入d删除分区
分区号 (1-4,默认 4):4        //选择删除4号分区
分区 4 已删除

命令(输入 m 获取帮助):n        //现在可以创建分区了
Partition type:
   p   primary (3 primary, 0 extended, 1 free)
   e   extended
Select (default e): e                //选择创建扩展分区
已选择分区 4                            //自动选择最后4号分区
起始 扇区 (5015552-10485759,默认为 5015552):    
将使用默认值 5015552
//直接回车表示将剩余所有空间分给扩展分区
Last 扇区, +扇区 or +size{K,M,G} (5015552-10485759,默认为 10485759): 
将使用默认值 10485759    
分区 4 已设置为 Extended 类型,大小设为 2.6 GiB

命令(输入 m 获取帮助):p

磁盘 /dev/sdb:5368 MB, 5368709120 字节,10485760 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x6928af85

   设备 Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     4196351     2097152   83  Linux
/dev/sdb2         4196352     4605951      204800   83  Linux
/dev/sdb3         4605952     5015551      204800   83  Linux
/dev/sdb4         5015552    10485759     2735104    5  Extended

命令(输入 m 获取帮助):

You can see sdb4 in the partition table The type is extended (extended partition). Extended partitions cannot store data. To use them, you need to divide them into several logical partitions. There is no limit on the number of logical partitions.

4) Create a logical partition

命令(输入 m 获取帮助):n            //创建分区
All primary partitions are in use
添加逻辑分区 5                            //默认直接创建5号逻辑分区
起始 扇区 (5017600-10485759,默认为 5017600):
将使用默认值 5017600
Last 扇区, +扇区 or +size{K,M,G} (5017600-10485759,默认为 10485759):+200M  //大小设置200M
分区 5 已设置为 Linux 类型,大小设为 200 MiB

命令(输入 m 获取帮助):p            //查看分区表

磁盘 /dev/sdb:5368 MB, 5368709120 字节,10485760 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x6928af85

   设备 Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     4196351     2097152   83  Linux
/dev/sdb2         4196352     4605951      204800   83  Linux
/dev/sdb3         4605952     5015551      204800   83  Linux
/dev/sdb4         5015552    10485759     2735104    5  Extended
/dev/sdb5         5017600     5427199      204800   83  Linux         //逻辑分区创建成功

命令(输入 m 获取帮助):n                //继续创建分区
All primary partitions are in use
添加逻辑分区 6                            //默认添加逻辑分区
起始 扇区 (5429248-10485759,默认为 5429248):
将使用默认值 5429248
Last 扇区, +扇区 or +size{K,M,G} (5429248-10485759,默认为 10485759)://将剩余空间全分配给6号逻辑分区
将使用默认值 10485759
分区 6 已设置为 Linux 类型,大小设为 2.4 GiB

命令(输入 m 获取帮助):p            //查看分区表

磁盘 /dev/sdb:5368 MB, 5368709120 字节,10485760 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x6928af85

   设备 Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     4196351     2097152   83  Linux
/dev/sdb2         4196352     4605951      204800   83  Linux
/dev/sdb3         4605952     5015551      204800   83  Linux
/dev/sdb4         5015552    10485759     2735104    5  Extended
/dev/sdb5         5017600     5427199      204800   83  Linux
/dev/sdb6         5429248    10485759     2528256   83  Linux

命令(输入 m 获取帮助):w        //保存分区
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
正在同步磁盘。
[root@localhost ~]#

2. Refresh the partition table , format, and mount

What we are talking about here are temporary mounts. Restarting the computer will not have mount information. It is just for the convenience of learning and understanding the disk. It is permanent. Mounting requires the uninstallation of the mount command to be written in etc/fstab, which will be discussed later.

As in the previous article, refresh and format the partition table, create a folder to be mounted, and mount the partition to the specified folder.

Note: Extended partitions cannot be mounted, only logical partitions divided by them can be mounted.

//1、刷新分区表
//直接查看分区表,发现刚刚创建的分区没有显示出来。
[root@localhost ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0   20G  0 disk 
├─sda1            8:1    0 1000M  0 part /boot
└─sda2            8:2    0   19G  0 part 
  ├─centos-root 253:0    0   17G  0 lvm  /
  └─centos-swap 253:1    0    2G  0 lvm  [SWAP]
sdb               8:16   0    5G  0 disk 
├─sdb1            8:17   0    2G  0 part 
├─sdb2            8:18   0  200M  0 part /mnt/disk2
└─sdb3            8:19   0  200M  0 part /mnt/fisk3
sdc               8:32   0    5G  0 disk 
sdd               8:48   0    5G  0 disk 
sde               8:64   0    5G  0 disk 
sdf               8:80   0    5G  0 disk 
sdg               8:96   0    5G  0 disk 
sdh               8:112  0    5G  0 disk 
sdi               8:128  0    5G  0 disk 
sr0              11:0    1  4.4G  0 rom  /run/media/root/CentOS 7 x86_64
//刷新分区表
[root@localhost ~]# partprobe /dev/sdb
//刷新之后查看分区表,发现刚刚创建的所有分区都显示出来了
[root@localhost ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0   20G  0 disk 
├─sda1            8:1    0 1000M  0 part /boot
└─sda2            8:2    0   19G  0 part 
  ├─centos-root 253:0    0   17G  0 lvm  /
  └─centos-swap 253:1    0    2G  0 lvm  [SWAP]
sdb               8:16   0    5G  0 disk 
├─sdb1            8:17   0    2G  0 part 
├─sdb2            8:18   0  200M  0 part /mnt/disk2
├─sdb3            8:19   0  200M  0 part /mnt/fisk3
├─sdb4            8:20   0  512B  0 part 
├─sdb5            8:21   0  200M  0 part 
└─sdb6            8:22   0  2.4G  0 part 
sdc               8:32   0    5G  0 disk 
sdd               8:48   0    5G  0 disk 
sde               8:64   0    5G  0 disk 
sdf               8:80   0    5G  0 disk 
sdg               8:96   0    5G  0 disk 
sdh               8:112  0    5G  0 disk 
sdi               8:128  0    5G  0 disk 
sr0              11:0    1  4.4G  0 rom  /run/media/root/CentOS 7 x86_64
//2、格式化
//格式化sbd5和sdb6,用分号隔开直接运行两个命令。
[root@localhost ~]# mkfs.ext4 /dev/sdb5;mkfs.ext4  /dev/sdb6
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=1024 (log=0)
分块大小=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
51200 inodes, 204800 blocks
10240 blocks (5.00%) reserved for the super user
第一个数据块=1
Maximum filesystem blocks=33816576
25 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks: 
	8193, 24577, 40961, 57345, 73729

Allocating group tables: 完成                            
正在写入inode表: 完成                            
Creating journal (4096 blocks): 完成
Writing superblocks and filesystem accounting information: 完成 

mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
158080 inodes, 632064 blocks
31603 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=648019968
20 block groups
32768 blocks per group, 32768 fragments per group
7904 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912

Allocating group tables: 完成                            
正在写入inode表: 完成                            
Creating journal (16384 blocks): 完成
Writing superblocks and filesystem accounting information: 完成 
//3、挂载
//创建disk5和disk6文件夹
[root@localhost ~]# mkdir /mnt/disk5 /mnt/disk6
//将sdb5挂载到disk5,将sdb6挂载到disk6
[root@localhost ~]# mount -t ext4  /dev/sdb5 /mnt/disk5 ;mount -t ext4  /dev/sdb6 /mnt/disk6
//查看挂载信息
[root@localhost ~]# df -hT
文件系统                类型      容量  已用  可用 已用% 挂载点
devtmpfs                devtmpfs  470M     0  470M    0% /dev
tmpfs                   tmpfs     487M     0  487M    0% /dev/shm
tmpfs                   tmpfs     487M  8.6M  478M    2% /run
tmpfs                   tmpfs     487M     0  487M    0% /sys/fs/cgroup
/dev/mapper/centos-root xfs        18G  4.2G   13G   25% /
/dev/sda1               xfs       997M  172M  826M   18% /boot
tmpfs                   tmpfs      98M   24K   98M    1% /run/user/0
/dev/sr0                iso9660   4.4G  4.4G     0  100% /run/media/root/CentOS 7 x86_64
/dev/sdb2               ext4      190M  1.6M  175M    1% /mnt/disk2
/dev/sdb3               ext4      190M  1.6M  175M    1% /mnt/fisk3
/dev/sdb5               ext4      190M  1.6M  175M    1% /mnt/disk5
/dev/sdb6               ext4      2.4G  7.3M  2.2G    1% /mnt/disk6
//挂载成功

3. Uninstall (cancel partition mounting)

Command: umount /dev/Partition that needs to be unmounted

[root@localhost ~]# df -hT
文件系统                类型      容量  已用  可用 已用% 挂载点
devtmpfs                devtmpfs  470M     0  470M    0% /dev
tmpfs                   tmpfs     487M     0  487M    0% /dev/shm
tmpfs                   tmpfs     487M  8.6M  478M    2% /run
tmpfs                   tmpfs     487M     0  487M    0% /sys/fs/cgroup
/dev/mapper/centos-root xfs        18G  4.2G   13G   25% /
/dev/sda1               xfs       997M  172M  826M   18% /boot
tmpfs                   tmpfs      98M   24K   98M    1% /run/user/0
/dev/sr0                iso9660   4.4G  4.4G     0  100% /run/media/root/CentOS 7 x86_64
/dev/sdb2               ext4      190M  1.6M  175M    1% /mnt/disk2
/dev/sdb3               ext4      190M  1.6M  175M    1% /mnt/fisk3
/dev/sdb5               ext4      190M  1.6M  175M    1% /mnt/disk5
/dev/sdb6               ext4      2.4G  7.3M  2.2     1% /mnt/disk6
[root@localhost ~]# umont  /dev/sdb6        //取消sbd6挂载
[root@localhost ~]# df -hT        //查看挂载信息,没有sbd6的挂载信息了
文件系统                类型      容量  已用  可用 已用% 挂载点
devtmpfs                devtmpfs  470M     0  470M    0% /dev
tmpfs                   tmpfs     487M     0  487M    0% /dev/shm
tmpfs                   tmpfs     487M  8.6M  478M    2% /run
tmpfs                   tmpfs     487M     0  487M    0% /sys/fs/cgroup
/dev/mapper/centos-root xfs        18G  4.2G   13G   25% /
/dev/sda1               xfs       997M  172M  826M   18% /boot
tmpfs                   tmpfs      98M   24K   98M    1% /run/user/0
/dev/sr0                iso9660   4.4G  4.4G     0  100% /run/media/root/CentOS 7 x86_64
/dev/sdb2               ext4      190M  1.6M  175M    1% /mnt/disk2
/dev/sdb3               ext4      190M  1.6M  175M    1% /mnt/fisk3
/dev/sdb5               ext4      190M  1.6M  175M    1% /mnt/disk5

Canceling the mount is equivalent to unplugging the U disk. For example, I just canceled it When sdb5 is mounted on disk5, it is equivalent to unplugging the U disk of sdb5. The files originally stored in disk5 will disappear, because those files are stored in sdb5. I unplugged the U disk. Naturally, these The files are gone and when sdb5 is remounted, the files will be restored.

Summary

# Mounting is the same as the primary partition at that time. The only difference is that multiple logical partitions can be created. Special attention is that extended partitions cannot be mounted and data cannot be stored. Logical partitions need to be divided for use. This article The article mainly divides logical partitions.

Related recommendations: "

Linux Video Tutorial"

The above is the detailed content of What does dev/hda5 mean in linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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