当前位置:   article > 正文

Linux (CentOS)存储结构与磁盘分化_centos储存关系图

centos储存关系图
  • Linux目录说明

目录

 

/bin

存放二进制可执行文件(ls,cat,mkdir等),常用命令一般都在这里。

/etc

存放系统管理和配置文件

/home

存放所有用户文件的根目录,是用户主目录的基点,比如用户user的主目录就是/home/user,可以用~user表示

 

/usr

用于存放系统应用程序,比较重要的目录/usr/local 本地系统管理员软件安装目录(安装系统级的应用)。这是最庞大的目录,要用到的应用程序和文件几乎都在这个目录。

/usr/x11r6 存放x window的目录

/usr/bin 众多的应用程序  

/usr/sbin 超级用户的一些管理程序  

/usr/doc linux文档  

/usr/include linux下开发和编译应用程序所需要的头文件  

/usr/lib 常用的动态链接库和软件包的配置文件  

/usr/man 帮助文档  

/usr/src 源代码,linux内核的源代码就放在/usr/src/linux里  

/usr/local/bin 本地增加的命令  

/usr/local/lib 本地增加的库

/opt

额外安装的可选应用程序包所放置的位置。一般情况下,我们可以把tomcat等都安装到这里。

/proc

虚拟文件系统目录,是系统内存的映射。可直接访问这个目录来获取系统信息。

/root

超级用户(系统管理员)的主目录(特权阶级^o^)

/sbin

存放二进制可执行文件,只有root才能访问。这里存放的是系统管理员使用的系统级别的管理命令和程序。如ifconfig等。

/dev

用于存放设备文件。

/mnt

系统管理员安装临时文件系统的安装点,系统提供这个目录是让用户临时挂载其他的文件系统。

/boot

存放用于系统引导时使用的各种文件

/lib

存放跟文件系统中的程序运行所需要的共享库及内核模块。共享库又叫动态链接共享库,作用类似windows里的.dll文件,存放了根文件系统程序运行所需的共享文件。

/tmp

用于存放各种临时文件,是公用的临时文件存储点。

/var

用于存放运行时需要改变数据的文件,也是某些大文件的溢出区,比方说各种服务的日志文件(系统启动日志等。)等。

/lost+found

这个目录平时是空的,系统非正常关机而留下“无家可归”的文件(windows下叫什么.chk)就在这里

 

Linux目录和Windows目录有着很大的不同,Linux目录类似一个树,最顶层是其根目录,如下图:

 

/bin 二进制可执行命令

/dev 设备特殊文件
/etc 系统管理和配置文件
/etc/rc.d 启动的配置文件和脚本
/home 用户主目录的基点,比如用户user的主目录就是/home/user,可以用~user表示
/lib 标准程序设计库,又叫动态链接共享库,作用类似windows里的.dll文件
/sbin 超级管理命令,这里存放的是系统管理员使用的管理程序
/tmp 公共的临时文件存储点
/root 系统管理员的主目录
/mnt 系统提供这个目录是让用户临时挂载其他的文件系统
/lost+found这个目录平时是空的,系统非正常关机而留下“无家可归”的文件(windows下叫什么.chk)就在这里
/proc 虚拟的目录,是系统内存的映射。可直接访问这个目录来获取系统信息。
/var 某些大文件的溢出区,比方说各种服务的日志文件
/usr 最庞大的目录,要用到的应用程序和文件几乎都在这个目录,其中包含:

/usr/x11R6 存放x window的目录
/usr/bin 众多的应用程序
/usr/sbin 超级用户的一些管理程序
/usr/doc linux文档
/usr/include linux下开发和编译应用程序所需要的头文件
/usr/lib 常用的动态链接库和软件包的配置文件
/usr/man 帮助文档
/usr/src 源代码,linux内核的源代码就放在/usr/src/linux里
/usr/local/bin 本地增加的命令

  • 物理设备命名规则

主分区或拓展分区的编号从1开始,到4结束;

逻辑分区编号从5开始

在这里插入图片描述

  • 存储格式
    • Ext3:能够在系统异常宕机时避免文件系统资料丢失,并能自动修复数据的不一致与错误。然而当硬盘容量较大时,需要的修复时间也会很长,也不能够保证百分百的保证数据不丢失;
    • Ext4:Ext3的改进版,支持存储容量1EB(1,073,731,824GB),而且有无限多的子目录,能够批量分配block块,从而极大的提高了读写效率;
    • XFS:发生宕机时优势很明显,可以快速回复可能被破坏的文件,且消耗计算与存储性能极低,最大容量可支持18EB;
  • mount挂载硬件设备,格式:mount 【文件系统】 【挂载目录】,例如:mount /dev/sdb2 /backup ,只是暂时挂载,重启后挂载关系失效
参数作用
-a挂载所有在 /etc/fstab 中定义的文件系统
-t指定文件系统类型 

 

持久挂载需要配置 /etc/fstab 文件

  1. /dev/fdo /mnt/flopy ext3 noauto 0 0
  2. /dev/cdrom /mnt/cdrom iso9660 noauto,ro 0 0
  3. /dev/sdb2 /mnt/cdrom ext4 defaults 0 0
  • umount 撤销已经挂载的设备文件,格式:umount 【设备文件或者挂载目录(其中之一即可)】,例如:umount /dev/sdb2

 

  • fdisk 磁盘分区,格式:fdisk 【磁盘名称】,例如:fdisk /dev/sdb2
  • fdisk -l 查看系统分区详细信息
  1. [root@test4 ~]# fdisk -l
  2. Disk /dev/sda: 21.4 GB, 21474836480 bytes
  3. 255 heads, 63 sectors/track, 2610 cylinders
  4. Units = cylinders of 16065 * 512 = 8225280 bytes
  5. Device Boot Start End Blocks Id System
  6. /dev/sda1 * 1 13 104391 83 Linux
  7. /dev/sda2 14 2610 20860402+ 8e Linux LVM
  • fdisk 对磁盘进行分区
  1. [root@test4 ~]# fdisk /dev/sda //对sda磁盘进行分区
  2. Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
  3. Building a new DOS disklabel. Changes will remain in memory only,
  4. until you decide to write them. After that, of course, the previous
  5. content won't be recoverable.
  6. The number of cylinders for this disk is set to 2597.
  7. There is nothing wrong with that, but this is larger than 1024,
  8. and could in certain setups cause problems with:
  9. 1) software that runs at boot time (e.g., old versions of LILO)
  10. 2) booting and partitioning software from other OSs
  11. (e.g., DOS FDISK, OS/2 FDISK)
  12. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
  13. Command (m for help): m //输出帮助信息
  14. Command action
  15. a toggle a bootable flag //设置启动分区
  16. b edit bsd disklabel //编辑分区标签
  17. c toggle the dos compatibility flag
  18. d delete a partition //删除一个分区
  19. l list known partition types //列出分区类型
  20. m print this menu //输出帮助信息
  21. n add a new partition //建立一个新的分区
  22. o create a new empty DOS partition table //创建一个新的空白DOS分区表
  23. p print the partition table //打印分区表
  24. q quit without saving changes //退出不保存设置
  25. s create a new empty Sun disklabel
  26. t change a partition's system id //改变分区的ID
  27. u change display/entry units //改变显示的单位
  28. v verify the partition table //检查验证分区表
  29. w write table to disk and exit //保存分区表
  30. x extra functionality (experts only)
  31. Command (m for help):n
  32. Command action
  33. e extended //e是扩展分区
  34. p primary partition (1-4) //p是主分区
  35. p
  36. Partition number (1-4): 1 //定义分区数量 --主分区最多只能有四个
  37. First cylinder (1-2597, default 1): 1
  38. Last cylinder or +size or +sizeM or +sizeK (1-2597, default 2597): +100M
  39. Command (m for help): w //保存刚才的配置信息。
  40. The partition table has been altered!
  41. Calling ioctl() to re-read partition table.
  42. WARNING: Re-reading the partition table failed with error 22: 无效的参数.
  43. The kernel still uses the old table.
  44. The new table will be used at the next reboot.
  45. Syncing disks.
  46. [root@test6 ~]# fdisk /dev/sda
  47. The number of cylinders for this disk is set to 2610.
  48. There is nothing wrong with that, but this is larger than 1024,
  49. and could in certain setups cause problems with:
  50. 1) software that runs at boot time (e.g., old versions of LILO)
  51. 2) booting and partitioning software from other OSs
  52. (e.g., DOS FDISK, OS/2 FDISK)
  53. Command (m for help): n
  54. First cylinder (1710-2610, default 1710):
  55. Using default value 1710
  56. Last cylinder or +size or +sizeM or +sizeK (1710-2610, default 2610): +100M
  57. Command (m for help): w
  58. The partition table has been altered!
  59. Calling ioctl() to re-read partition table.
  60. WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
  61. The kernel still uses the old table.
  62. The new table will be used at the next reboot.
  63. Syncing disks.
  64. [root@test6 ~]# partprobe /dev/sda //对硬盘进行更新
  65. [root@test6 ~]# fdisk -l
  66. Disk /dev/sda: 21.4 GB, 21474836480 bytes
  67. heads, 63 sectors/track, 2610 cylinders
  68. Units = cylinders of 16065 * 512 = 8225280 bytes
  69. Device Boot Start End Blocks Id System
  70. /dev/sda1 * 1 13 104391 83 Linux
  71. /dev/sda2 14 274 2096482+ 82 Linux swap / Solaris
  72. /dev/sda3 275 404 1044225 8e Linux LVM
  73. /dev/sda4 405 2610 17719695 5 Extended
  74. /dev/sda5 405 1709 10482381 83 Linux
  75. /dev/sda6 1710 1722 104391 83 Linux
  76. [root@test6 ~]# mkfs.ext3 /dev/sda6 //需要先进行格式化,才能使用 。mkfs -t ext3 /dev/sda5 (mkfs.ext3 一样效果 -t 指定类型 -b 指定block大小·)
  77. mke2fs 1.39 (29-May-2006)
  78. Filesystem label=
  79. OS type: Linux
  80. Block size=1024 (log=0)
  81. Fragment size=1024 (log=0)
  82. inodes, 104388 blocks
  83. blocks (5.00%) reserved for the super user
  84. First data block=1
  85. Maximum filesystem blocks=67371008
  86. block groups
  87. blocks per group, 8192 fragments per group
  88. inodes per group
  89. Superblock backups stored on blocks:
  90. 8193, 24577, 40961, 57345, 73729
  91. Writing inode tables: done
  92. Creating journal (4096 blocks): done
  93. Writing superblocks and filesystem accounting information: done
  94. This filesystem will be automatically checked every 23 mounts or
  95. days, whichever comes first. Use tune2fs -c or -i to override.
  96. [root@test6 ~]# mount /dev/sda6 /mnt/sda7/ //进行挂载使用
  97. anaconda-ks.cfg install.log install.log.syslog
  98. [root@test6 ~]# df -h
  99. 文件系统 容量 已用 可用 已用% 挂载点
  100. /dev/sda5 9.7G 1.1G 8.1G 12% /
  101. /dev/sda1 99M 12M 83M 13% /boot
  102. tmpfs 252M 0 252M 0% /dev/shm
  103. /dev/hdc 3.9G 3.9G 0 100% /mnt/cdrom
  104. /dev/sda6 99M 5.6M 89M 6% /mnt/sda7
  • 磁盘管理常用命令
  • ls -i 文件名 查看文件存储在哪个innode中
  1. [root@test6 ~]# ls -i lstest
  2. 1179659 lstest
  • ls -id 文件夹名 查看文件夹存储在哪个innode中
  1. [root@test6 ~]# ls -id lstest1
  2. 1179661 lstest1
  • filefrag -v 文件名 查看文件存储block具体位置
  1. [root@test6 ~]# filefrag -v lstest
  2. Checking lstest
  3. Filesystem type is: ef53
  4. Filesystem cylinder groups is approximately 78
  5. Blocksize of file lstest is 4096
  6. File size of lstest is 5 (1 blocks)
  7. First block: 1183744
  8. Last block: 1183744
  9. lstest: 1 extent found
  • mkfs,敲击两次tab键,会提示格式化后缀,选择对应的后缀名格式化,例如:mkfs.xfs /dev/sbd2
  • df -h 查看挂载状态与磁盘使用量信息
  • du 文件数据占用量,格式:du 【选项】 文件,例如:du -sh xxx.txt

 

  • mkswap 添加交换分区:通过在硬盘中预先划分一定的空间,然后将把内存中暂时不常用的数据临时存放到硬盘中,以便腾出物理内存空间让更活跃的程序服务来使用的技术。只有真实的物理内存耗尽后才会调用交换分区的资源,mkswap为其专用的格式化命令,例如:mkswap /dev/sdb2
  • xfs_quota 磁盘配额,格式:xfs_quota 【参数】 ‘【配额】 【用户】’ 【文件系统】,一个专门针对xfs文件系统来管理quota磁盘容量配额服务而设计的;
    • 例如:xfs_quota -x -c 'limit bsoft=3m bhard=6m usoft=3 ihard=6 tom' /boot ,解释:为tom用户限制磁盘使用额度,软限制为3m或3个文件,硬限制为6m或6个文件
    • 软限制:当达到软限制时会提示用户,但是允许用户在设定的额度内计需使用;
    • 硬限制:当达到软限制时会提示用户,且强制终止用户操作;
    • edquota 编辑用户配额,格式: edquota 【参数】 【用户】,例如:edquota -u tom
  • ln链接方式
    • 软连接:好比windows中的快捷方式,源文件删除后软链接失效;
    • 硬链接:硬链接与原文件其实是同一个文件,只是名字不同。每添加一个硬链接,该文件的inode连接数都会增加1,只有inode连接数为0时才可以彻底删除,实际上硬链接是原文件inode的指针,即使原文件被删除,让然可以通过硬链接访问,需要注意的是,不能跨分区对目录文件进行链接;
参数作用
-s创建“符号链接(软链接)”,不带 -s 参数默认创建的为硬链接
-f强制创建文件或目录的链接
-i覆盖前,先询问
-v显示创建链接的过程

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小惠珠哦/article/detail/1004447
推荐阅读
相关标签
  

闽ICP备14008679号