fdisk使用

本文介绍了如何使用fdisk工具在Linux系统中进行分区操作,包括查看当前分区、创建新分区、写入分区表以及刷新分区表的步骤。通过示例展示了创建新分区的具体流程,并提到了在分区表更新过程中可能遇到的问题及解决方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

0)fdisk /dev/sda进入交互式命令行


1)显示当前分区

p


2)创建新分区

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (524-60801, default 524):
Using default value 524
Last cylinder, +cylinders or +size{K,M,G} (524-60801, default 60801): +20G

Command (m for help): p

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 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: 0x000b52a5

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1         523     4200966   83  Linux
/dev/sda2             524        3135    20980890   83  Linux


//写入分区表,这一步不能少,否则分区表不会被修改!

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: 设备或资源忙.
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.



3)刷新分区表

partprobe或系统重启

[root@ihost ~]# partprobe
Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (设备或资源忙).  As a result, it may not reflect all of your changes until after reboot.
[root@ihost ~]# reboot

Broadcast message from root@ihost.test.com
    (/dev/pts/0) at 11:00 ...

The system is going down for reboot NOW!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值