linux-centOs6.5 添加新的硬盘
添加的思路为:
扩展硬盘---添加新的主分区--分区格式为文件--挂载--自动挂载设置
一、扩展硬盘
Vmware增大硬盘空间
二、添加新的主分区
查看分区 fdisk -l
[root@node2 ~]# fdisk -l Disk /dev/sda: 32.2 GB, 32212254720 bytes 255 heads, 63 sectors/track, 3916 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00064f31 Device Boot Start End Blocks Id System /dev/sda1 * 1 39 307200 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 39 2350 18566144 83 Linux /dev/sda3 2350 2611 2097152 82 Linux swap / Solaris
创建分区
[root@node2 ~]# fdisk /dev/sda 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): n Command action e extended p primary partition (1-4) p Selected partition 4 First cylinder (2611-3916, default 2611): Using default value 2611 Last cylinder, +cylinders or +size{K,M,G} (2611-3916, default 3916): Using default value 3916 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. 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) Syncing disks.
再次查看分区
[root@node2 ~]# fdisk -l Disk /dev/sda: 32.2 GB, 32212254720 bytes 255 heads, 63 sectors/track, 3916 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00064f31 Device Boot Start End Blocks Id System /dev/sda1 * 1 39 307200 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 39 2350 18566144 83 Linux /dev/sda3 2350 2611 2097152 82 Linux swap / Solaris /dev/sda4 2611 3916 10483750 83 Linux
[root@node2 ~]# reboot
[root@node2 ~]# partx -a /dev/sda4 /dev/sda ###########这个地方如果用partprobe会报错,这个是虚拟机下linux-centOs6.5的BUG
三、 分区格式为文件
[root@node2 ~]# reboot
##如果不重启。格式化会报错。
[root@node2 ~]# mkfs.ext4 /dev/sda4
mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type:
Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 655360 inodes,
2620937 blocks 131046 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2684354560 80 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
Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 33 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
四、挂载
[root@node2 ~]# mount /dev/sda4 /opt
五、开机自动挂载
vi /etc/fstab
###在末尾加上以下内容
dev/sda4 /opt ext4 defaults 1 2
六、问题汇总
6.1- partprobe报错
Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy). As a result, it may not reflect all of your changes until after reboot.
请用这个命令: partx -a /dev/sda4 /dev/sda
IT之界浩瀚无边
只有持之恒心方可打开一窗
偷窥此中奥秘之一二
取之受益,亦珍而视之
学之留香,方不失风范
共勉 共进
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· winform 绘制太阳,地球,月球 运作规律
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人