惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

宝玉的分享
宝玉的分享
NISL@THU
NISL@THU
E
Exploit-DB.com RSS Feed
L
LINUX DO - 热门话题
L
Lohrmann on Cybersecurity
K
Kaspersky official blog
Project Zero
Project Zero
Cisco Talos Blog
Cisco Talos Blog
T
The Exploit Database - CXSecurity.com
P
Palo Alto Networks Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
S
Schneier on Security
G
GRAHAM CLULEY
The Hacker News
The Hacker News
T
Threat Research - Cisco Blogs
Scott Helme
Scott Helme
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Privacy & Cybersecurity Law Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Cyberwarzone
Cyberwarzone
C
CERT Recently Published Vulnerability Notes
T
Tor Project blog
AWS News Blog
AWS News Blog
Simon Willison's Weblog
Simon Willison's Weblog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
爱范儿
爱范儿
P
Privacy International News Feed
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
S
Securelist
G
Google Developers Blog
The Last Watchdog
The Last Watchdog
Google Online Security Blog
Google Online Security Blog
美团技术团队
F
Fortinet All Blogs
小众软件
小众软件
Recorded Future
Recorded Future
V
Visual Studio Blog
B
Blog RSS Feed
H
Help Net Security
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Google DeepMind News
Google DeepMind News
Blog — PlanetScale
Blog — PlanetScale
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
Martin Fowler
Martin Fowler
Latest news
Latest news
Spread Privacy
Spread Privacy
H
Heimdal Security Blog

兴起百年 - XQBN.com - 2025年10月

暂无文章

ubuntu 22.04系统 如何将硬盘的inodes参数设置为最大值?
作者: 兴起百年 · 2025-10-18 · via 兴起百年 - XQBN.com - 2025年10月

这篇文章距离最后更新已过163 天,如果文章内容或图片资源失效,请留言反馈,我会及时处理,谢谢!

服务器系统是 ubuntu 22.04 通过命令fdisk -l 命令查看硬盘配置如下:

Disk /dev/sda: 1.82 TiB, 2000398934016 bytes, 3907029168 sectors
Disk model: Samsung SSD 860 
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: gpt
Disk identifier: 24C73ED3-DB2D-40B8-9DED-BE19E235EE68

Device         Start        End    Sectors  Size Type
/dev/sda1       2048       4095       2048    1M BIOS boot
/dev/sda2       4096  104861695  104857600   50G Linux filesystem
/dev/sda3  104861696  121638911   16777216    8G Linux swap
/dev/sda4  121638912  125833215    4194304    2G Linux filesystem
/dev/sda5  125833216 3907026943 3781193728  1.8T Linux filesystem

服务器有一块2TB的SSD硬盘,通过命令 df -h 查看硬盘挂载信息:

Filesystem      Size  Used Avail Use% Mounted on
tmpfs           3.2G  1.4M  3.2G   1% /run
/dev/sda2        50G   11G   40G  22% /
tmpfs            16G     0   16G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
/dev/sda5       1.8T   13G  1.8T   1% /www
/dev/sda4       2.0G  177M  1.9G   9% /boot
tmpfs           3.2G  4.0K  3.2G   1% /run/user/0

50G挂载在根目录,用于安装系统,剩下的空间主要挂载到 /www 目录,现在需要将 /www 设置为 xfs 文件系统格式,并将 inodes 参数设置为最大值

具体操作如下:

卸载分区

1、卸载 /www 分区:

umount /www

2、 强制格式化为 xfs 文件系统

使用 -f 选项强制格式化 /dev/sda5 为 xfs 文件系统,并将 inodes 的最大百分比设置为 100%:

mkfs.xfs -f -i maxpct=100 /dev/sda5

image-20240608104320851

3、重新挂载分区

使用命令 blkid 查看分区uuid

blkid
/dev/sda4: UUID="8625e190-f26b-496f-93e8-f0d1b382cc61" BLOCK_SIZE="512" TYPE="xfs" PARTUUID="5740cb6e-d07b-42f4-b9e1-3f30b2bd507c"
/dev/sda2: UUID="0b580b42-bbcf-43d0-b595-697da97b78a1" BLOCK_SIZE="512" TYPE="xfs" PARTUUID="ffe67324-a260-415d-9c71-98e280a2610c"
/dev/sda5: UUID="31daa251-d6d7-4f07-ba21-1b67f90f344c" BLOCK_SIZE="512" TYPE="xfs" PARTUUID="83577c17-46d6-4f3e-bfd9-25e733fefef0"
/dev/sda3: UUID="99fac7d5-1552-48b2-9e59-26972ff31a7d" TYPE="swap" PARTUUID="8cce3836-dd4d-4dab-89b0-7560c18a8269"
/dev/sda1: PARTUUID="14594e1d-8f9e-43d6-a75a-b6ed2ad995e7"

image-20240608104514662

然后编辑 /etc/fstab 文件,加入分区挂载信息

image-20240608104657783

4、挂载完成后使用 mount -a 重装加载硬盘挂载信息

image-20240608104758567

使用 df -hdf -hi查看硬盘分区挂载信息以及inodes参数的信息

image-20240608104822174

如上图:

服务器的硬盘 50G 挂载到根目录 / 用于安装服务器的操作系统;

1.8T挂载到 /www 目录,inodes 为 3.5G 这个 /www 目录用于存放网站的程序以及缓存文件。

版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自兴起百年 - XQBN.com