AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / computer / 问题 / 1843121
Accepted
Skeeve
Skeeve
Asked: 2024-05-21 15:15:55 +0800 CST2024-05-21 15:15:55 +0800 CST 2024-05-21 15:15:55 +0800 CST

是否可以使用 dd 和 gdisk 在 Mac OS 上移动分区?

  • 772

如果这个问题看起来很愚蠢,请告诉我。我对文件系统和分区没有经验。

我有一个来自 16GB SD 卡的 IMG 文件。我的问题是:我有一张 32GB 的 SD 卡,并且不希望将图像放入我的卡时 16GB 不可用。所以我的目标是扩展最后一个分区以填充卡的其余部分。

如果这个分区是最后一个分区,那不会有问题。不幸的是这是第一个。

目前的布局是这样的:

Number  Start (sector)    End (sector)  Size       Code  Name
   1           73728         8880127   4.2 GiB     0700  Roms
   2         8880128         8945663   32.0 MiB    0700  boot-resource
   3         8945664         8978431   16.0 MiB    0700  env
   4         8978432         9109503   64.0 MiB    0700  boot
   5         9109504        25886719   8.0 GiB     0700  rootfs
   6        25886720        30373887   2.1 GiB     0700  UDISK

我希望分区Roms位于最后,所以我想布局会是这样的:

Number  Start (sector)    End (sector)  Size       Code  Name
   1           73728          139263   32.0 MiB    0700  boot-resource
   2          139264          172031   16.0 MiB    0700  env
   3          172032          303103   64.0 MiB    0700  boot
   4          303104        17080319   8.0 GiB     0700  rootfs
   5        17080320        21567487   2.1 GiB     0700  UDISK
   6        21567488        30373887   4.2 GiB     0700  Roms

该分区的内容Roms不需要保留,但其他内容必须移动。

有没有办法可以移动所有当前分区的内容?

我使用的是 Mac 并安装了 gdisk(来自 Homebrew)。

partitioning
  • 1 1 个回答
  • 25 Views

1 个回答

  • Voted
  1. Best Answer
    Skeeve
    2024-05-22T04:07:42+08:002024-05-22T04:07:42+08:00

    回答我自己的问题:是的,可以。

    这就是我所做的:

    创建每个分区及其前后内容的转储:

    dd                  count=73728  bs=512 if=ORIGINAL.IMG status=progress of=aa.img 
    dd    skip=73728  count=8806400  bs=512 if=ORIGINAL.IMG status=progress of=roms.img
    dd  skip=8880128    count=65536  bs=512 if=ORIGINAL.IMG status=progress of=boot-resource.img
    dd  skip=8945664    count=32768  bs=512 if=ORIGINAL.IMG status=progress of=env.img
    dd  skip=8978432   count=131072  bs=512 if=ORIGINAL.IMG status=progress of=boot.img
    dd  skip=9109504 count=16777216  bs=512 if=ORIGINAL.IMG status=progress of=rootfs.img
    dd skip=25886720  count=4487168  bs=512 if=ORIGINAL.IMG status=progress of=UDISK.img
    dd skip=30373888                 bs=512 if=ORIGINAL.IMG status=progress of=zz.img
    

    然后使用重新排列cat:

    cat -u aa.img boot-resource.img env.img boot.img rootfs.img UDISK.img Roms.img zz.img > sorted.img
    

    计算新的分区位置:

    分割 开始(扇区) 结束(扇区) 姓名
    1 21567488 30373887 罗姆斯
    2 73728 139263 启动资源
    3 139264 172031 环境
    4 172032 303103 启动
    5 303104 17080319 根文件系统
    6 17080320 21567487 U盘

    然后进入 gdisk,删除所有分区并使用计算出的扇区重新创建它们。

    我保持分区编号与以前相同。我不确定是否需要,但它是这样工作的。

    • 0

相关问题

  • 更改分区的(类型)GUID?

  • 在未分配空间的备份硬盘中安装 ubuntu

  • 如何完全擦除笔记本电脑磁盘以进行全新的 Ubuntu 安装?

  • 分区大小 128GB 但仅检测到 64GB [重复]

  • 我应该对用于存储的辅助(非操作系统)SSD 进行分区吗?[关闭]

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何减少“vmmem”进程的消耗?

    • 11 个回答
  • Marko Smith

    从 Microsoft Stream 下载视频

    • 4 个回答
  • Marko Smith

    Google Chrome DevTools 无法解析 SourceMap:chrome-extension

    • 6 个回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Martin Hope
    Vickel Firefox 不再允许粘贴到 WhatsApp 网页中? 2023-08-18 05:04:35 +0800 CST
  • Martin Hope
    Saaru Lindestøkke 为什么使用 Python 的 tar 库时 tar.xz 文件比 macOS tar 小 15 倍? 2021-03-14 09:37:48 +0800 CST
  • Martin Hope
    CiaranWelsh 如何减少“vmmem”进程的消耗? 2020-06-10 02:06:58 +0800 CST
  • Martin Hope
    Jim Windows 10 搜索未加载,显示空白窗口 2020-02-06 03:28:26 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve