0
点赞
收藏
分享

微信扫一扫

LINUX第九节课--存储的结构与管理硬盘

在LINUX中一切皆是文件的定律,可见学好linux,就得了解什么地方会有什么文件,linux系统的一切文件都是从“根”目录开始,并且按照文件系统标准的(FHS)采用倒数状结构来存放文件。

LINUX第九节课--存储的结构与管理硬盘_ide

这里说下“根”目录下常用的目录以及存放的是什么文件和目录

/root

存放管理员的本地文件

/dev

存放物理设备的文件,例:硬盘,光盘,键盘,鼠标等

/etc

存放配置文件的位置

/home

普通用户的家目录

/bin

存放单用户模式可用的命令

/sbin

开机过程中需要的命令

/media

用于挂载文件的地址

/opt

第三方软件最好安装在这个目录下

/srv

存放网络数据的文件

/tmp

任何人可共享的文件目录

/proc

虚拟文件,例如系统内核、进程、外部设备及网络状态等

/var

存放经常变化的文件,例日志

搞清楚这里就可以更加了解linux中的文件存放位置

下面是物理设备的命名规则

硬件设备

文件名称

IDE设备

/dev/hd[a-d]

SCSI/SATA/U盘

/dev/sd[a-z]

virtio设备

/dev/vd[a-z]

软驱

/dev/fd[0-1]

打印机

/dev/lp[0-15]

光驱

/dev/cdrom

鼠标

/dev/mouse

磁带机

/dev/st0或/dev/ht0

在linux系统配置好后,往往需要将磁盘挂载到对应的目录下,可以用lsblk查看当前有哪些磁盘还未挂载到自己想挂载的地方

[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 8G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 7G 0 part
├─rhel-root 253:0 0 6.2G 0 lvm /
└─rhel-swap 253:1 0 820M 0 lvm [SWAP]
sdb 8:16 0 8G 0 disk
sr0 11:0 1 6.6G 0 rom /run/media/root/RHEL-8-0-0-BaseOS-x86_64
[root@localhost ~]#

而挂载的步骤是

分区  fdisk

[root@localhost ~]# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x5478fb1a.

Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-16777215, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-16777215, default 16777215): +1G

Created a new partition 1 of type 'Linux' and of size 1 GiB.

Command (m for help): p
Disk /dev/sdb: 8 GiB, 8589934592 bytes, 16777216 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5478fb1a

Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 2099199 2097152 1G 83 Linux

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]#

格式化 mkfs

[root@localhost ~]# mkfs /dev/sdb1
mke2fs 1.44.3 (10-July-2018)
Creating filesystem with 262144 4k blocks and 65536 inodes
Filesystem UUID: 4ab5cab8-b397-485b-b2f9-3b2266016607
Superblock backups stored on blocks:
32768, 98304, 163840, 229376

Allocating group tables: done
Writing inode tables: done
Writing superblocks and filesystem accounting information: done

挂载 mount

[root@localhost ~]# mkdir -p /media/text
[root@localhost ~]# mount /dev/sdb1 /media/text/

最后再把它加入到fstab下次重启后依然有效

[root@localhost ~]# vim /etc/fstab
/dev/sdb1 /media/text ext2 defaults 0 0


举报

相关推荐

0 条评论