首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用parted正确设置分区类型

无法使用parted正确设置分区类型
EN

Unix & Linux用户
提问于 2014-07-03 14:28:17
回答 1查看 3.4K关注 0票数 1

我正试图在CentOS6.5中使用FreeDos为BIOS更新创建一个可引导的U盘,下面是chtaube.de的说明。

我使用dd创建了空的30 img文件:

代码语言:javascript
复制
[root@dumbledore freedos_boot]# dd if=/dev/zero of=FreeDos-image.img bs=1M 
count=30
30+0 records in
30+0 records out
31457280 bytes (31 MB) copied, 0.0756911 s, 416 MB/s

上述文章的作者说,这个命令应该复制30 of,我得到31 of。这有问题吗?

然后,我使用parted在生成的FreeDos-image.img文件中创建分区。

代码语言:javascript
复制
root@dumbledore freedos_boot]# parted FreeDos-image.img 
GNU Parted 2.1
Using /home/dthacker/freedos_boot/FreeDos-image.img
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) unit %
(parted) mklabel msdos                                                     
(parted) mkpart primary fat16 0 100%
Warning: The resulting partition is not properly aligned for best performance. 
Ignore/Cancel? C                                                          
(parted) mkpart primary fat32 0 100%
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? I                                                          
(parted) set 1 boot on                                                    
(parted) p                                                                  
Model:  (file)
Disk /home/dthacker/freedos_boot/FreeDos-image.img: 100%
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start  End   Size  Type     File system  Flags
1      0.00%  100%  100%  primary               boot, lba                                                                                                               

文件系统类型应该是FAT16,但没有设置。

为了正确地设置它,我需要做什么不同的操作?

EN

回答 1

Unix & Linux用户

回答已采纳

发布于 2014-07-03 19:15:44

我是chtaube.eu上这些说明的作者:)

当涉及到大小时,dd有点不一致:bs=1M定义了一个1 倍字节的块大小,意思是1024*1024字节。30兆字节是30*1024*1024 = 31457280字节。dd的S最终输出使用了十进制兆字节,1MB= 1000*1000字节。这就是为什么它显示为31 MB的原因。所以没什么好担心的。我保守地选择了稍微小于32兆字节的大小,以确保它适合被广告为"32 MB“的USB闪存盘。

我刚刚在Arch和Debian上用parted检查了这个问题,并且能够重现这个问题。

在我看来,这似乎是parted的一个总体问题,因为p (print)命令的输出显示了一个“空白”文件系统,而分区实际上被正确地创建为FAT16。

您可以使用fdisk -l FreeDos-image.img进行检查,就像我在下面的打字本中所做的那样:

代码语言:javascript
复制
ct@darkstar ~/tmp % dd if=/dev/zero of=Freedos.img bs=1M count=30
30+0 records in
30+0 records out
31457280 bytes (31 MB) copied, 0.150141 s, 210 MB/s
ct@darkstar ~/tmp % parted Freedos.img 
WARNING: You are not superuser.  Watch out for permissions.
GNU Parted 3.1
Using /home/ct/tmp/Freedos.img
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) unit %                                                           
(parted) mklabel msdos                                                    
(parted) mkpart primary fat16 0 100%                                      
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? i                                                          
(parted) set 1 boot on                                                    
(parted) p                                                                
Model:  (file)
Disk /home/ct/tmp/Freedos.img: 100%
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start  End   Size  Type     File system  Flags
 1      0.00%  100%  100%  primary               boot, lba

(parted) q                                                                
ct@darkstar ~/tmp % fdisk -l Freedos.img 

Disk Freedos.img: 30 MiB, 31457280 bytes, 61440 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: 0x0007cae1

Device       Boot Start       End Blocks  Id System
Freedos.img1 *        1     61439  30719+  e W95 FAT16 (LBA)

ct@darkstar ~/tmp % 

所以你这边应该没什么不对的。不管怎样,谢谢你指出这个。我将深入了解parted的S行为,并相应地更新我页面上的手册。

票数 2
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/140568

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档