linux系统中如何打开察看img文件内容

༺小ʚɞ寞༻ Wiki评论33,813字数 886阅读2分57秒阅读模式
  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    Sectors Size Id Type
DS3617xs_6.17up3_virtio.img1   2048 4982527 4980480 2.4G fd Linux raid autodetect
DS3617xs_6.17up3_virtio.img2   4982528 9176831 4194304 2G fd Linux raid autodetect
DS3617xs_6.17up3_virtio.img3   9437184 10280959 843776 412M fd Linux raid autodetect
DS3617xs_6.17up3_virtio.img4  * 9177088 9437183 260096 127M 6 FAT16
    • 其中的star是32,要转换下:2048X512,这个很重要,下面的mount命令中参数offset中要用到
    • 第二,挂载分区img1,
    • mount -o loop,offset=$((2048*512)) DS3617xs_6.17up3_virtio.img /mnt
    • 第三,卸载分区
    • umount /mnt 
      

weinxin
LuckTang's Blog 站长语录
LuckTang's Blog,欢迎各位来访!这是我的QQ,扫一扫,加好友。大家一起交流博客建站技术,分享前沿资讯!
搭建 WebDAV 服务 Wiki

搭建 WebDAV 服务

迫于需要使用 Joplin 开源笔记同步功能,所以自己搭一个 WebDav 服务 Simple Go WebDAV server 下载到指定目录 wget https://github.com/hac...
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定