当前位置: 首页 > ai >正文

使用fdisk 、gdisk管理分区

fdisk 管理分区
fdisk 命令工具默认将磁盘划分为 mbr 格式的分区
命令: fdisk 设备名 fdisk 命令以交互方式进行操作的,在菜单中选择相应功能键即可
[root@localhost ~]# fdisk /dev/sda
# sda 进行分区
Command (m for help):
# 进入 fdisk 交互界面进行分区
Command (m for help): m
# 输入 m 可查看帮助信息
Help:
DOS (MBR)
a toggle a bootable flag
b edit nested BSD disklabel
c toggle the dos compatibility flag
Generic
d delete a partition
F list free unpartitioned space
l list known partition types
n add a new partition
p print the partition table
t change a partition type
v verify the partition table
i print information about a partition
Misc
m print this menu
u change display/entry units
x extra functionality (experts only)
Script
I load disk layout from sfdisk script file
O dump disk layout to sfdisk script file Save & Exit
w write table to disk and exit
q quit without saving changes
Create a new label
g create a new empty GPT partition table
G create a new empty SGI (IRIX) partition table
o create a new empty DOS partition table
s create a new empty Sun partition table
Command (m for help): n
# 输入 n 创建新分区
Partition type
p primary (0 primary, 0 extended, 4 free)
# 输入 p 创建主分区
e extended (container for logical partitions)
# 输入 e 创建扩展分区
Select (default p): p
# 输入 p 创建主分区
Partition number (1-4, default 1): 1
# 选择主分区号,输入 1 表示第一个主分区
First sector (2048-10485759, default 2048):
# 直接按回车从当前第 2048 个扇区开始分区
Last sector, +sectors or +size{K,M,G,T,P} (2048-10485759, default 10485759): +300M
# 设置第一个分区为 300M
Created a new partition 1 of type 'Linux' and of size 300 MiB.
# 一个主分区创建完成,大小为 300M
Command (m for help): p
# 输入 p 查看分区信息
Disk /dev/sda: 5 GiB, 5368709120 bytes, 10485760 sectors
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: dos
Disk identifier: 0x5bb0744f
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 616447 614400 300M 83 Linux
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 616447 614400 300M 83 Linux
/dev/sda2 616448 10485759 9869312 4.7G 0 Empty
# 有两个分区,其中新添加的 sda2 有误,需要删除
Command (m for help): d
# 输入 d 删除分区
Partition number (1,2, default 2): 2
# 输入 2 ,选择需要删除的是第二个分区
Partition 2 has been deleted.
Command (m for help): p
Disk /dev/sda: 5 GiB, 5368709120 bytes, 10485760 sectors
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: dos
Disk identifier: 0x5bb0744f Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 616447 614400 300M 83 Linux
# 查看现有分区,有误的 sda2 已删除
# 创建一个扩展分区
Command (m for help): n
# 输入 n 创建新分区
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): e
# 输入 e 创建扩展分区
Partition number (2-4, default 2): 2
# 选择分区号,输入 2 表示第二个分区
First sector (616448-10485759, default 616448):
# 直接按回车从当前第 616448 个扇区开始分区
Last sector, +sectors or +size{K,M,G,T,P} (616448-10485759, default 10485759): +500M
# 添加一个 500M 的分区
Created a new partition 2 of type 'Extended' and of size 500 MiB.
Command (m for help): p
Disk /dev/sda: 5 GiB, 5368709120 bytes, 10485760 sectors
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: dos
Disk identifier: 0x5bb0744f
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 616447 614400 300M 83 Linux
/dev/sda2 616448 1640447 1024000 500M 5 Extended
# 输入 p 查看,新增一个 500M 的扩展分区
Command (m for help): w
# 所有分区设置完成后,输入 w 保存,即可退出 fdisk 交互界面
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
使用 gdisk 管理分区
gdisk 命令工具默认将磁盘划分为 GPT 格式的分区
[root@localhost ~]# gdisk /dev/sda
# 进入 gdisk 交互界面
GPT fdisk (gdisk) version 1.0.3
Partition table scan:
MBR: MBR only
BSD: not present
APM: not present
GPT: not present Command (? for help): ?
# 输入 ? 可查看帮助信息
b
back up GPT data to a file
c
change a partition's name
d
delete a partition
i
show detailed information on a partition
l
list known partition types
n
add a new partition
o
create a new empty GUID partition table (GPT)
p
print the partition table
q
quit without saving changes
r
recovery and transformation options (experts only)
s
sort partitions
t
change a partition's type code
v
verify disk
w
write table to disk and exit
x
extra functionality (experts only)
?
print this menu
#gdisk 创建新分区(默认 GPT 格式)
Command (? for help): n
# 输入 n 创建新分区
Partition number (1-128, default 1):
# 输入分区编号,默认为 1 ,因为是 /dev/sda 硬盘的第一块分区
First sector (34-10485726, default = 2048) or {+-}size{KMGTP}: # 输入扇区的开始位置,选择默认即
可,也可手动指定
Last sector (2048-10485726, default = 10485726) or {+-}size{KMGTP}: +300M
#
入扇区的结束位置,一般都是指定磁盘大小,这里输入 +300M 表示新分区大小为 300M
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300):
# 默认即可,分区完成后可以修改
Changed type of partition to 'Linux filesystem'
Command (? for help): p
# 输入 p 查看分区情况
Disk /dev/sda: 10485760 sectors, 5.0 GiB
Model: VMware Virtual S
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 61FA16FB-FAD8-4873-A857-BD387FE0A592
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 10485726
Partitions will be aligned on 2048-sector boundaries
Total free space is 9871293 sectors (4.7 GiB)
Number Start (sector) End (sector) Size Code Name
1 2048 616447 300.0 MiB 8300 Linux filesystem Command (? for help): w
# 输入 w 保存分区并退出 gdisk 交互界面
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!!
Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sda.
The operation has completed successfully.
http://www.xdnf.cn/news/5274.html

相关文章:

  • Satori:元动作 + 内建搜索机制,让大模型实现超级推理能力
  • python:ASCII-generator 实用教程
  • $\int_{0}^{1} x \arcsin \sqrt{4x - 4x^2}dx$
  • LintCode第366题-斐波那契数列
  • 各种环境测试
  • 解释器和基于规则的系统比较
  • 【Linux基础】文件和目录管理指令
  • 对日开发 TeraTerm ttl脚本开发环境配置
  • python04——条件判断(选择结构)
  • 部署RocketMQ
  • 数孪实战笔记(1)数字孪生的含义、应用及技术体系
  • java-代理
  • [特殊字符] AI网关:大模型时代的智能交通指挥官 [特殊字符]
  • 科大讯飞TTS(文字转语音)和STT(语音转文字)
  • 如何将 Windows 11 的开始菜单移到左侧
  • ECMAScript 2017(ES2017):异步编程与对象操作的革新
  • CUDA编程——性能优化基本技巧
  • 常用的Linux命令100条
  • python 版本管理用的是pyenv pip install 把东西安装到那里了,好的检测方法,注意是windows环境
  • RENAME 语句与RENAME选项学习
  • 理解Yocto项目中`${D}`作为模拟目标系统根文件结构的临时目录
  • 投影显示技术全解析:主流方案对比与雷克赛恩 CyberPro1 的核心优势
  • 【桌面】【输入法】常见问题汇总
  • Day 14
  • 介绍一下synchronized锁升级过程
  • 2024年AI发展趋势全面解析:从多模态到AGI的突破
  • LintCode第485题-生成给定大小的数组,第220题-冰雹猜想,第235题-分解质因数
  • JDBC演进之路:从基础操作到高效连接池
  • 计算机科技笔记: 容错计算机设计03 系统可信性的度量 偶发故障期 浴盆曲线 韦布尔分布
  • 工程师视角下的 AI 浏览器智能体拆解(AI Browser Agent from an Engineer‘s Perspective)