【CentOS】CentOS7 添加新硬盘
参考文章: https://www.it610.com/article/520586.htm(亲测可用,因没有及时存档,故用该文章调整作为记录)
1、查看硬盘
1 2 3 4 5 6 7 8 9 | # fdisk -l Disk /dev/sdb : 2000.4 GB, 2000398934016 bytes 255 heads, 63 sectors /track , 243201 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical /physical ): 512 bytes / 4096 bytes I /O size (minimum /optimal ): 4096 bytes / 4096 bytes Disk identifier: 0x97d16691 Device Boot Start End Blocks Id System |
2、硬盘新建分区
使用fdisk命令对新增的sdb硬盘进行操作
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | <strong> # fdisk /dev/sdb</strong> The device presents a logical sector size that is smaller than the physical sector size. Aligning to a physical sector (or optimal I /O ) size boundary is recommended, or performance may be impacted. WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode ( command 'c' ) and change display units to sectors ( command 'u' ). Command (m for help): <strong>p< /strong > #查看此颗硬盘分区状况 Disk /dev/sdb : 2000.4 GB, 2000398934016 bytes 255 heads, 63 sectors /track , 243201 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical /physical ): 512 bytes / 4096 bytes I /O size (minimum /optimal ): 4096 bytes / 4096 bytes Disk identifier: 0x97d16691 Device Boot Start End Blocks Id System Command (m for help):<strong> n< /strong > #新建分区 Command action e extended p primary partition (1-4) p #新建原始分区 Partition number (1-4): <strong>1< /strong > #分区编号 First cylinder (1-243201, default 1): #从第一个扇区开始(使用默认) Last cylinder, +cylinders or +size{K,M,G} (1-243201, default 243201): #直接回车使用所有空间 Using default value 243201 Command (m for help): <strong>p< /strong > #再次查看分区情况 Disk /dev/sdb : 2000.4 GB, 2000398934016 bytes 255 heads, 63 sectors /track , 243201 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical /physical ): 512 bytes / 4096 bytes I /O size (minimum /optimal ): 4096 bytes / 4096 bytes Disk identifier: 0x97d16691 Device Boot Start End Blocks Id System /dev/sdb1 1 243201 1953512001 83 Linux Partition 1 does not start on physical sector boundary. Command (m for help): <strong>w< /strong > #保存分区 The partition table has been altered! Calling ioctl() to re- read partition table. Syncing disks. |
3、再次查看
1 2 3 4 5 6 7 8 9 10 11 | # fdisk -l Disk /dev/sdb : 2000.4 GB, 2000398934016 bytes 255 heads, 63 sectors /track , 243201 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical /physical ): 512 bytes / 4096 bytes I /O size (minimum /optimal ): 4096 bytes / 4096 bytes Disk identifier: 0x97d16691 Device Boot Start End Blocks Id System /dev/sdb1 1 243201 1953512001 83 Linux Partition 1 does not start on physical sector boundary. |
(此时可以看见新建的sdb1分区,还需要格式化才能使用)
4、格式化分区
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | <strong> # mkfs.ext3 /dev/sdb1</strong> mke2fs 1.41.12 (17-May-2010) /dev/sdb1 alignment is offset by 512 bytes. This may result in very poor performance, (re)-partitioning suggested. Filesystem label= OS type : Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=1 blocks, Stripe width=0 blocks 122101760 inodes, 488378000 blocks 24418900 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=0 14905 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 102400000, 214990848 Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 20 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. |
5、挂载
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # mkdir /eda_bak #建立新挂载点 # mount /dev/sdb1 /eda_bak #挂载使用此硬盘 # mount #查看系统挂载情况 /dev/sda3 on / type ext3 (rw) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) tmpfs on /dev/shm type tmpfs (rw,rootcontext= "system_u:object_r:tmpfs_t:s0" ) /dev/sda1 on /boot type ext3 (rw) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw) gvfs-fuse-daemon on /root/ .gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev) /dev/sdb1 on /eda_bak type ext3 (rw) # df -h #查看使用空间 Filesystem Size Used Avail Use% Mounted on /dev/sda3 457G 3.0G 431G 1% / tmpfs 995M 260K 994M 1% /dev/shm /dev/sda1 194M 26M 158M 15% /boot /dev/sdb1 1.8T 196M 1.7T 1% /eda_bak |
6、开机自动挂载
1 2 3 | # vi /etc/fstab 增加 /dev/sdb1 /eda_bak ext3 defaults 1 2 |
得意时做事,失意时读书
分类:
Linux
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律