无需安装即可将文件添加到VFAT映像

kay*_*kay 10 linux filesystems command-line fat32

我想创建一个新的VFAT图像并添加一些文件.

# Create file of 1MB size:
dd if=/dev/zero of=my-image.fat count=1 bs=1M
# Format file as VFAT:
mkfs.vfat ./my-image.fat
Run Code Online (Sandbox Code Playgroud)

现在我想将文件./abc,./ def和./ghi添加到图像中.

没有 mount -o loop或我怎么办fusermount?我只想写一个新的,空的,原始的VFAT图像.我不需要删除附加或任何"复杂"操作.

我试过,7z -a因为7zip可以读取VFAT图像,但它不知道如何写入它.

Ant*_*ony 28

我想做与嵌入式系统的图像构建的一部分完全相同的事情.令人讨厌的是整个构建需要大约3小时才能完全无人看管,除了最后一步需要密码才能安装VFAT图像.幸运的是,我找到了一套解决问题的工具.

你想要mcopyGNU mtools提供.

Mtools是一组实用程序,用于从GNU和Unix访问MS-DOS磁盘而无需安装它们.

它还支持磁盘映像,如VFAT映像文件.

例如,以下命令将文件hello.txt从当前目录复制到subdirVFAT文件系统的子目录中~/images/fat_file.img:

mcopy -i ~/images/fat_file.img hello.txt ::subdir/hello.txt
Run Code Online (Sandbox Code Playgroud)

mtools中有更多有用的包含,例如mdir,mtype它们非常适合检查图像文件而无需安装它.

mdir -i ~/images/fat_file.img ::
mdir -i ~/images/fat_file.img ::subdir
mtype -i ~/imags/fat_file.img ::subdir/hello.txt
Run Code Online (Sandbox Code Playgroud)

  • 这真是太棒了,我会赞成百倍! (4认同)
  • 还有 fatcat 实用程序,它可以列出 fat32.img 内的文件。例如,`fatcat my_fat32.img -l /`。请参阅此处的手册http://manpages.ubuntu.com/manpages/bionic/man1/fatcat.1.html (2认同)