Linux系统中添加删除分区命令是什么
发表于:2025-11-09 作者:千家信息网编辑
千家信息网最后更新 2025年11月09日,小编给大家分享一下Linux系统中添加删除分区命令是什么,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!在Linux系统中如果要添加删除分区可以使用fdisk命令,执行命令之后系统会有
千家信息网最后更新 2025年11月09日Linux系统中添加删除分区命令是什么
小编给大家分享一下Linux系统中添加删除分区命令是什么,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!
在Linux系统中如果要添加删除分区可以使用fdisk命令,执行命令之后系统会有提示,只需要根据系统提示一步一步的操作。
fdisk命令:
增加一个分区
fdisk -l 查看系统上的分区信息
[root@fei ~]# fdisk -l Disk /dev/sda: 21.5 GB, 21474836480 bytes //总计21.5G 255 heads, 63 sectors/track, 2610 cylinders // 255个磁面,63个扇区,2610个磁柱 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: 0x0005936c Device Boot Start End Blocks Id System /dev/sda1 * 1 26 204800 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 26 1332 10485760 83 Linux /dev/sda3 1332 1593 2097152 82 Linux swap / Solaris 1234567891011121314
fdisk /dev/sda: 对/dev/sda/进行分区 磁盘分区表示: hda1 hda2 hdb1 hdb2…… sda1 sda2 sdb1 sdb2…… hd大多为IDE硬盘 , sd大多为SCSI或移动存储
[root@fei ~]# 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): 1234567 注释 ://Command (m for help): 查看帮助信息:输入m,看到如下信息 Command action # 输出帮助信息 a toggle a bootable flag #设置启动信息 b edit bsd disklabel # 编 辑分区标签 c toggle the dos compatibility flag d delete a partition # 这是删除一个分区的动作 l list known partition types # l是列出分区类型,以供我们设置相应分区的类型 m print this menu # m 是列出帮助信息; n add a new partition # 添加一个分区; o create a new empty DOS partition table # 创建一个新的DOS分区表 p print the partition table # p列出分区表; q quit without saving changes #不保存退出; s create a new empty Sun disklabel t change a partition's system id #t 改变分区类型 id u change display/entry units 改变现实单位 v verify the partition table w write table to disk and exit # 把分区表写入硬盘并退出 x extra functionality (experts only) #扩展应用,专家功能 123456789101112131415161718192021 - 选择n 来添加一个分区 Command (m for help): n Command action e extended #e,扩展分区 p primary partition (1-4) #p,主分区1-4 p Selected partition 4 #因为sda1-3已分,所有默认sda4 First cylinder (1593-2610, default 1593): #磁柱开始位置,采用默认,直接回车 Using default value 1593 #磁柱开始位置 Last cylinder, +cylinders or +size{K,M,G} (1593-2610, default 2610): +100M #磁柱解释位置,设置磁盘分区大小 Command (m for help): p #查看一下当前磁盘信息 Disk /dev/sda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 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: 0x0005936c Device Boot Start End Blocks Id System /dev/sda1 * 1 26 204800 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 26 1332 10485760 83 Linux /dev/sda3 1332 1593 2097152 82 Linux swap / Solaris /dev/sda4 1593 1606 111459 83 Linux //添加成功,sda4 Command (m for help): wq //保存退出 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. 1234567891011121314151617181920212223242526272829303132333435363738partprobe 或者 partx -a /dev/sda 分区之后,让内核更新分区信息,否则系统需要restart后,内核才能识别新的分区
mkfs.ext4 /dev/sda4 创建ext4文件系统,格式化.
[root@fei ~]# mkfs.ext4 /dev/sda4 mke2fs 1.41.12 (17-May-2010) 文件系统标签= 操作系统:Linux 块大小=1024 (log=0) 分块大小=1024 (log=0) Stride=0 blocks, Stripe width=0 blocks 3776 inodes, 15068 blocks 753 blocks (5.00%) reserved for the super user 第一个数据块=1 Maximum filesystem blocks=15466496 2 block groups 8192 blocks per group, 8192 fragments per group 1888 inodes per group Superblock backups stored on blocks: 8193 正在写入inode表: 完成 Creating journal (1024 blocks): 完成 Writing superblocks and filesystem accounting information: 完成 This filesystem will be automatically checked every 38 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. 1234567891011121314151617181920212223
将/dev/sda4 挂载
[root@fei ~]# mount /dev/sda4 /mnt [root@fei ~]# df-h -bash: df-h: command not found [root@fei ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 9.8G 1.4G 8.0G 15% / tmpfs 931M 0 931M 0% /dev/shm /dev/sda1 190M 35M 145M 20% /boot /dev/sr0 3.7G 3.7G 0 100% /media /dev/sda4 14M 130K 13M 2% /mnt //已将/dev/sda4挂载 12345678910
删除一个分区
[root@fei ~]# 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): d //删除一个分区 Partition number (1-4): 4 //选择删除一个分区,如果删除了扩展分区,扩展分区之下的逻辑分区都会删除 Command (m for help): p Disk /dev/sda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 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: 0x0005936c Device Boot Start End Blocks Id System /dev/sda1 * 1 26 204800 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 26 1332 10485760 83 Linux /dev/sda3 1332 1593 2097152 82 Linux swap / Solaris //sda4已经被删除 Command (m for help): wq //若之前有错误操作,只有不输入w只输入q退出即可
看完了这篇文章,相信你对"Linux系统中添加删除分区命令是什么"有了一定的了解,如果想了解更多相关知识,欢迎关注行业资讯频道,感谢各位的阅读!
系统
信息
命令
位置
大小
磁盘
类型
分区表
帮助
输入
内核
文件
标签
硬盘
篇文章
提示
选择
成功
操作系统
专家
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
数据库查看表的约束的命令
工程软件开发一体化
网络安全课程哪些比较好
邮政网络安全教育
网络安全法第十二条明确规定
服务器需要单独备案吗
华为云服务器安装不了软件怎么办
网络安全本质是对抗
网络安全监察民警个人
服务器必须初始化网络吗
access数据库 工资
东方国信服务器项目
下面哪项不是数据库管理的目标
gmod服务器怎么换图
什么叫服务器端渲染
h3c服务器启动虚拟机主机重启
科乐美服务器炸了
数据库技术及应用人民邮电
日本2013年网络安全战略
金砖国家网络安全案例
二层网络技术结论
临沂党性体检软件开发专业制作
软件开发一个功能多少钱
江苏服务器维修价格表
海南软件开发月薪上万
国内虚拟服务器排行榜
刀片服务器能独立运行吗
软件开发拿来主义的优势
大学生网络安全的主要内容
怎样打开系统管理服务器