1. 可以把img的文件理解成一个磁盘,一个以文件的二进制形式存在的磁盘。
  2. 磁盘里面肯定有一些分区。

因此可直接mount进行挂载磁盘里面的分区。

  • 第一,要知道img磁盘文件,对应分区的开始位置。
    用分区程序察看img对于分区信息比如ubuntu linux系统的fdisk,或者parted fdisk直接如下,然后p打印img文件的分区信息

    $ fdisk noogie.img
    
    Command (m for help): p
    
    Disk noogie.img: 79 MB, 79691776 bytes
    128 heads, 32 sectors/track, 38 cylinders, total 155648 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
    Disk identifier: 0x00000000
    
         Device Boot      Start         End      Blocks   Id  System
    noogie.img1   *          32      155647       77808    c  W95 FAT32 (LBA)

    其中的star是32,要转换下:32X512=16384B,这个很重要,下面的mount命令中参数offset中要用到

  • 第二,挂载分区

    ```
     sudo mount -o loop,offset=16384 noogie.img /mnt/
    ```
    
GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:1 个月前 )
186a802e added ecosystem file for PM2 4 年前
5def40a3 Add host customization support for the NodeJS version 4 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐