磁盘分区-热门看点
2023-06-12 19:21:35 来源:博客园
磁盘分区
一、fdisk
(1)fdisk命令只支持msdos,分区的时候只支持小容量硬盘(<=2T),但是如果不需要分区的话,那么整块sdb硬盘,类型为msdos,那么他的大小是可以大于2T的。(2)fdisk命令不支持gpt,所以当使用fdisk命令给gpt类型硬盘分区是会出现告警
首先先把设备关机,添加一块新的磁盘
fdisk -l磁盘 /dev/sda:21.5 GB, 21474836480 字节,41943040 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 512 字节I/O 大小(最小/最佳):512 字节 / 512 字节磁盘标签类型:dos磁盘标识符:0x000e0f54 设备 Boot Start End Blocks Id System/dev/sda1 * 2048 2099199 1048576 83 Linux/dev/sda2 2099200 41943039 19921920 83 Linux磁盘 /dev/sdb:21.5 GB, 21474836480 字节,41943040 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 512 字节I/O 大小(最小/最佳):512 字节 / 512 字节磁盘标签类型:dos磁盘标识符:0x8ff20778
[root@localhost ~]# fdisk /dev/sdb欢迎使用 fdisk (util-linux 2.23.2)。更改将停留在内存中,直到您决定将更改写入磁盘。使用写入命令前请三思。命令(输入 m 获取帮助):m a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition g create a new empty GPT partition table G create an IRIX (SGI) partition table l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition"s system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only)
命令(输入 m 获取帮助):p磁盘 /dev/sdb:21.5 GB, 21474836480 字节,41943040 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 512 字节I/O 大小(最小/最佳):512 字节 / 512 字节磁盘标签类型:dos磁盘标识符:0x8ff20778 设备 Boot Start End Blocks Id System
添加主分区
(资料图片)
命令(输入 m 获取帮助):nPartition type: p primary (0 primary, 0 extended, 4 free) e extendedSelect (default p): p分区号 (1-4,默认 1):起始 扇区 (2048-41943039,默认为 2048):将使用默认值 2048Last 扇区, +扇区 or +size{K,M,G} (2048-41943039,默认为 41943039):+500M分区 1 已设置为 Linux 类型,大小设为 500 MiB命令(输入 m 获取帮助):p磁盘 /dev/sdb:21.5 GB, 21474836480 字节,41943040 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 512 字节I/O 大小(最小/最佳):512 字节 / 512 字节磁盘标签类型:dos磁盘标识符:0x8ff20778 设备 Boot Start End Blocks Id System/dev/sdb1 2048 1026047 512000 83 Linux
添加扩展分区
命令(输入 m 获取帮助):nPartition type: p primary (1 primary, 0 extended, 3 free) e extendedSelect (default p): e分区号 (2-4,默认 2):起始 扇区 (1026048-41943039,默认为 1026048):将使用默认值 1026048Last 扇区, +扇区 or +size{K,M,G} (1026048-41943039,默认为 41943039):将使用默认值 41943039分区 2 已设置为 Extended 类型,大小设为 19.5 GiB命令(输入 m 获取帮助):p磁盘 /dev/sdb:21.5 GB, 21474836480 字节,41943040 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 512 字节I/O 大小(最小/最佳):512 字节 / 512 字节磁盘标签类型:dos磁盘标识符:0x8ff20778 设备 Boot Start End Blocks Id System/dev/sdb1 2048 1026047 512000 83 Linux/dev/sdb2 1026048 41943039 20458496 5 Extended
添加逻辑分区
命令(输入 m 获取帮助):nPartition type: p primary (1 primary, 1 extended, 2 free) l logical (numbered from 5)Select (default p): l添加逻辑分区 5起始 扇区 (1028096-41943039,默认为 1028096): 将使用默认值 1028096Last 扇区, +扇区 or +size{K,M,G} (1028096-41943039,默认为 41943039):+10G分区 5 已设置为 Linux 类型,大小设为 10 GiB命令(输入 m 获取帮助):p磁盘 /dev/sdb:21.5 GB, 21474836480 字节,41943040 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 512 字节I/O 大小(最小/最佳):512 字节 / 512 字节磁盘标签类型:dos磁盘标识符:0x8ff20778 设备 Boot Start End Blocks Id System/dev/sdb1 2048 1026047 512000 83 Linux/dev/sdb2 1026048 41943039 20458496 5 Extended/dev/sdb5 1028096 21999615 10485760 83 Linux命令(输入 m 获取帮助):nPartition type: p primary (1 primary, 1 extended, 2 free) l logical (numbered from 5)Select (default p): l添加逻辑分区 6起始 扇区 (22001664-41943039,默认为 22001664):将使用默认值 22001664Last 扇区, +扇区 or +size{K,M,G} (22001664-41943039,默认为 41943039):将使用默认值 41943039分区 6 已设置为 Linux 类型,大小设为 9.5 GiB命令(输入 m 获取帮助):p磁盘 /dev/sdb:21.5 GB, 21474836480 字节,41943040 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 512 字节I/O 大小(最小/最佳):512 字节 / 512 字节磁盘标签类型:dos磁盘标识符:0x8ff20778 设备 Boot Start End Blocks Id System/dev/sdb1 2048 1026047 512000 83 Linux/dev/sdb2 1026048 41943039 20458496 5 Extended/dev/sdb5 1028096 21999615 10485760 83 Linux/dev/sdb6 22001664 41943039 9970688 83 Linux
最后w保存退出
命令(输入 m 获取帮助):wThe partition table has been altered!Calling ioctl() to re-read partition table.正在同步磁盘。
最后使用 partx -a /dev/sdb 命令重新读取一下修改后的磁盘信息
partx -a /dev/sdb
二、parted
(1)支持msdos和gpt,可以支持大硬盘,也支持小硬盘。
这里我还是用sdb磁盘 先把原来分好删除 (如果你创建新的,就可以对新的磁盘parted 不用删除sdb)
[root@localhost ~]# fdisk /dev/sdb欢迎使用 fdisk (util-linux 2.23.2)。更改将停留在内存中,直到您决定将更改写入磁盘。使用写入命令前请三思。命令(输入 m 获取帮助):d分区号 (1,2,5,6,默认 6):分区 6 已删除命令(输入 m 获取帮助):d分区号 (1,2,5,默认 5):分区 5 已删除命令(输入 m 获取帮助):d分区号 (1,2,默认 2):分区 2 已删除命令(输入 m 获取帮助):d已选择分区 1分区 1 已删除命令(输入 m 获取帮助):dNo partition is defined yet!命令(输入 m 获取帮助):w The partition table has been altered!Calling ioctl() to re-read partition table.正在同步磁盘。
先parted /dev/sdb 然后创建新的磁盘标签
[root@localhost ~]# parted /dev/sdbGNU Parted 3.1使用 /dev/sdbWelcome to GNU Parted! Type "help" to view a list of commands.(parted) help align-check TYPE N check partition N for TYPE(min|opt) alignment help [COMMAND] print general help, or help on COMMAND mklabel,mktable LABEL-TYPE create a new disklabel (partition table) mkpart PART-TYPE [FS-TYPE] START END make a partition name NUMBER NAME name partition NUMBER as NAME print [devices|free|list,all|NUMBER] display the partition table, available devices, free space, all found partitions, or a particular partition quit exit program rescue START END rescue a lost partition near START and END resizepart NUMBER END resize partition NUMBER rm NUMBER delete partition NUMBER select DEVICE choose the device to edit disk_set FLAG STATE change the FLAG on selected device disk_toggle [FLAG] toggle the state of FLAG on selected device set NUMBER FLAG STATE change the FLAG on partition NUMBER toggle [NUMBER [FLAG]] toggle the state of FLAG on partition NUMBER unit UNIT set the default unit to UNIT version display the version number and copyright information of GNU Parted(parted) mklabel gpt警告: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?是/Yes/否/No? yes (parted) p Model: VMware, VMware Virtual S (scsi)Disk /dev/sdb: 21.5GBSector size (logical/physical): 512B/512BPartition Table: gptDisk Flags: Number Start End Size File system Name 标志(parted)
创建主分区 起始点0 分配500M
(parted) mkpart primary 0 500警告: The resulting partition is not properly aligned for best performance.忽略/Ignore/放弃/Cancel? Ignore(parted) p Model: VMware, VMware Virtual S (scsi)Disk /dev/sdb: 21.5GBSector size (logical/physical): 512B/512BPartition Table: gptDisk Flags: Number Start End Size File system Name 标志 1 17.4kB 500MB 500MB primary(parted)
创建逻辑分区 起始点501 10000M 也就是 10G
(parted) p Model: VMware, VMware Virtual S (scsi)Disk /dev/sdb: 21.5GBSector size (logical/physical): 512B/512BPartition Table: gptDisk Flags: Number Start End Size File system Name 标志 1 17.4kB 500MB 500MB primary(parted) mkpart logical 501 10000(parted) p Model: VMware, VMware Virtual S (scsi)Disk /dev/sdb: 21.5GBSector size (logical/physical): 512B/512BPartition Table: gptDisk Flags: Number Start End Size File system Name 标志 1 17.4kB 500MB 500MB primary 2 501MB 10.0GB 9499MB logical
fdisk -l 查看
[root@localhost ~]# fdisk -l磁盘 /dev/sda:21.5 GB, 21474836480 字节,41943040 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 512 字节I/O 大小(最小/最佳):512 字节 / 512 字节磁盘标签类型:dos磁盘标识符:0x000e0f54 设备 Boot Start End Blocks Id System/dev/sda1 * 2048 2099199 1048576 83 Linux/dev/sda2 2099200 41943039 19921920 83 LinuxWARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.磁盘 /dev/sdb:21.5 GB, 21474836480 字节,41943040 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 512 字节I/O 大小(最小/最佳):512 字节 / 512 字节磁盘标签类型:gptDisk identifier: 185D8D08-E6FF-4DAC-BED7-2D4C310FCCDA# Start End Size Type Name1 34 976562 476.8M Microsoft basic primary2 978944 19531775 8.9G Microsoft basic logical
关键词:
相关新闻
- 磁盘分区-热门看点
- 鞍山普通话水平等级证书领取时间及地点2023 当前通讯
- 国家卫健委等6部门公布81个紧密型城市医疗集团建设试点城市名单
- 绝世唐门:万年老二和菜头登场,罕见雪茄武魂,一炮轰出毁灭之源 每日热讯
- 视觉中国推出AI灵感绘图功能,付费后可在“合法合规前提下使用” 今日精选
- 【速看料】天元股份(003003.SZ):目前与茶百道、古茗、仙津饮品等茶饮及饮料公司有相关合作
- 环球动态:史莱姆与地下城新手攻略,攻略大全
- 砂石分离机的作用和用途_砂石分离机哪家好|每日短讯
- 2023《创造与魔法》6月12日礼包兑换码分享-世界焦点
- FSD完全版将试点上海?特斯拉中国:消息不实
- 6月12日广州龙雨化工磷酸二铵价格动态
- 铁路新型票制产品:怎么买 如何用 哪些要注意
- 宜宾市环境保护信息监控中心 世界要闻
- 全球最资讯丨指导帮建基层应“设身处地”
- 饶阳县气象台发布雷电黄色预警【Ⅲ级/较重】【2023-06-11】_当前速讯
- 浚县气象台发布雷暴大风黄色预警【Ⅲ级/较重】【2023-06-11】|天天通讯
- 全球热点评!中方驳斥:无中生有、信口雌黄、恶意诋毁!
- 《天空之城》:用纯真对抗贪婪_每日报道
- 全民体育健身(全民体育)
- 时讯:大腿内侧湿疹怎么办_大腿内侧湿疹
- 【环球报资讯】π等于多少rad_π等于多少
- 网暴将受严惩,依法精准打击,就问你怕不怕
- 教师专业技能方面存在问题(教师专业技能)-世界滚动
- 《修女也疯狂》主演喊话暴雪:凭啥Mac不能玩暗黑4