关于fdisk问题

Ticket #66 (assigned 缺陷(BUG))

Opened 20 months ago

Last modified 20 months ago

关于fdisk问题

Reported by:hu33407285Owned by:lintel
Priority:重要(major)Milestone: 
Component:内核(Kernel)Severity: 
Keywords:fdisk,system,paratitionCc: 

Description

利用trunk源编译的固件不能正确挂载朗科的onlydisk盘,磁盘信息如下:

Disk /dev/sda: 4002 MB, 4002414592 bytes
124 heads, 62 sectors/track, 1016 cylinders
Units = cylinders of 7688 * 512 = 3936256 bytes
Disk identifier: 0x6f20736b

This doesn't look like a partition table
Probably you selected the wrong device.

Device Boot Start End Blocks Id System

/dev/sda1 ? 101215 249694 570754815+ 72 Unknown
Partition 1 has different physical/logical beginnings (non-Linux?):

phys=(357, 116, 40) logical=(101214, 43, 11)

Partition 1 has different physical/logical endings:

phys=(357, 32, 45) logical=(249693, 92, 51)

Partition 1 does not end on cylinder boundary.
/dev/sda2 ? 21942 273767 968014120 65 Novell Netware 386
Partition 2 has different physical/logical beginnings (non-Linux?):

phys=(288, 115, 43) logical=(21941, 114, 47)

Partition 2 has different physical/logical endings:

phys=(367, 114, 50) logical=(273766, 76, 42)

Partition 2 does not end on cylinder boundary.
/dev/sda3 ? 243221 495046 968014096 79 Unknown
Partition 3 has different physical/logical beginnings (non-Linux?):

phys=(366, 32, 33) logical=(243220, 98, 30)

Partition 3 has different physical/logical endings:

phys=(357, 32, 43) logical=(495045, 59, 39)

Partition 3 does not end on cylinder boundary.
/dev/sda4 ? 375349 375356 27749+ d Unknown
Partition 4 has different physical/logical beginnings (non-Linux?):

phys=(372, 97, 50) logical=(375348, 92, 25)

Partition 4 has different physical/logical endings:

phys=(0, 10, 0) logical=(375355, 119, 33)

Partition 4 does not end on cylinder boundary.

Partition table entries are not in disk order
我觉得可能是fdisk对分区表的读写问题或者是e2fsprogs格盘的问题,请问下该怎样修改源码?另外多问一句网上贴中关于“openwrt挂载usb”中提到要挂载cifs,这个有必要吗?

Change History

comment:1 Changed 20 months ago by lintel

建议你先清空你的MBR:

dd if=/dev/zero of=/dev/sda bs=512 count=1

然后重新分区。

comment:2 Changed 20 months ago by lintel

  • Owner changed from hu33407285 to lintel
  • Status changed from new to assigned

comment:3 Changed 20 months ago by hu33407285

lintel大大,再请问下这个除了重新分区还有别的办法没?(这个盘再ubuntu系统下可正常读取)请问修改哪个配置文件来满足能正常读取这类USB设备呢?
### fdisk命令的用法及常见问题解决 fdisk 是 Linux 系统中用于磁分区管理的一个常用工具,它可以创建、删除、调整分区大小以及更改分区类型。以下是关于 `fdisk` 命令的基本用法及相关问题的详细说明。 #### 1. 查看磁分区信息 使用以下命令可以查看当前系统中的磁及其分区信息: ```bash sudo fdisk -l ``` 该命令会列出所有磁设备及其分区的详细信息,包括磁容量、分区大小、文件系统类型等[^1]。 #### 2. 创建新分区 要创建新的磁分区,首先需要进入交互模式: ```bash sudo fdisk /dev/sdX ``` 其中 `/dev/sdX` 是目标磁设备名称。在交互模式下,可以通过输入以下命令完成操作: - 输入 `n` 创建新分区。 - 根据提示选择主分区(primary)或扩展分区(extended),并指定分区号和起始扇区。 - 输入 `w` 将更改写入磁并退出。 #### 3. 删除现有分区 如果需要删除某个分区,可以执行以下步骤: ```bash sudo fdisk /dev/sdX ``` 在交互模式下: - 输入 `d` 删除分区。 - 根据提示选择要删除的分区号。 - 输入 `w` 确认保存更改。 #### 4. 更改分区类型 有时需要更改分区的文件系统类型,例如将分区类型设置为 Linux Swap 或 EFI System Partition。具体步骤如下: ```bash sudo fdisk /dev/sdX ``` 在交互模式下: - 输入 `t` 更改分区类型。 - 指定分区号。 - 输入对应的分区类型代码(如 82 表示 Swap,ef 表示 EFI 系统分区)。 - 输入 `w` 保存更改。 #### 5. 显示帮助信息 在 `fdisk` 的交互模式下,可以输入 `m` 查看所有可用命令及其功能说明。 --- #### 解决与 fdisk 相关的常见问题 **问题 1: 执行 fdisk 时无法识别磁设备** 如果在运行 `fdisk` 时遇到类似“无法打开设备”的错误,可能是因为设备路径不正确或磁未被系统检测到。可以尝试以下方法: - 使用 `lsblk` 或 `dmesg | grep sd` 检查磁是否已被正确挂载[^2]。 - 如果磁是通过 USB 接口连接的,确保驱动程序已加载。 **问题 2: 分区表损坏或不一致** 当磁分区表出现问题时,可能会导致 `fdisk` 报错。可以使用以下工具修复: - 使用 `parted` 工具重新创建分区表:`sudo parted /dev/sdX mklabel gpt`。 - 或者使用 `testdisk` 工具尝试恢复丢失的分区[^3]。 **问题 3: 新建分区后无法挂载** 新建分区后需要格式化并挂载才能正常使用。例如: ```bash sudo mkfs.ext4 /dev/sdX1 sudo mkdir /mnt/new_partition sudo mount /dev/sdX1 /mnt/new_partition ``` --- #### 示例代码 以下是一个完整的流程示例,展示如何使用 `fdisk` 创建新分区并挂载: ```bash # 进入交互模式 sudo fdisk /dev/sdX # 在交互模式下依次输入以下命令 Command (m for help): n # 创建新分区 Command action: p # 选择主分区 Partition number: 1 # 指定分区号 First sector: [默认值] # 使用默认起始扇区 Last sector: +1G # 设置分区大小为 1GB Command (m for help): w # 写入更改并退出 # 格式化分区 sudo mkfs.ext4 /dev/sdX1 # 创建挂载点并挂载 sudo mkdir /data sudo mount /dev/sdX1 /data ``` ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值