GNU/Linux >> Linux の 問題 >  >> Linux

Imgファイルのタイプを見つけてマウントする方法は?

.imgファイルをマウントする必要がありますが、それがどのタイプの.imgかわかりません。 .imgファイルの種類を確認するにはどうすればよいですか?

# mount -t auto -o ro,loop gmapsupp.img /mnt/iso/
mount: you must specify the filesystem type
# file -k gmapsupp.img 
gmapsupp.img: x86 boot sector, code offset 0x0
#

承認された回答:

コマンドfdisk -l <img file>を実行してみてください 。通常、.imgの場合 ファイルは、たとえばKVM VMのディスク全体であり、技術的には仮想ディスクです。

fileでそのように表示されるCentOSKVMVMがあります コマンド:

$ file centostest.img 
centostest.img: x86 boot sector; partition 1: ID=0x83, active, starthead 1, startsector 63, 208782 sectors; partition 2: ID=0x8e, starthead 0, startsector 208845, 20755980 sectors, code offset 0x48

fdiskを実行しています それで:

$ sudo /sbin/fdisk -lu /kvm/centostest.img
last_lba(): I don't know how to handle files with mode 81ed
You must set cylinders.
You can do this from the extra functions menu.

Disk /kvm/centostest.img: 0 MB, 0 bytes
255 heads, 63 sectors/track, 0 cylinders, total 0 sectors
Units = sectors of 1 * 512 = 512 bytes

              Device Boot      Start         End      Blocks   Id  System
/kvm/centostest.img1   *          63      208844      104391   83  Linux
/kvm/centostest.img2          208845    20964824    10377990   8e  Linux LVM
Partition 2 has different physical/logical endings:
     phys=(1023, 254, 63) logical=(1304, 254, 63)

これらのパーティションの1つをマウントする場合は、次のように実行できます。

fdisk(シリンダー出力)

  • ブロックサイズは512バイトで、開始ブロックは63です。
  • オフセットは512*63=32256です。

fdisk(セクター出力)

  • ブロックサイズは512バイトで、開始ブロックは1です。
  • オフセットは512*1=512です。

したがって、mountコマンドは次のようになります。

シリンダー内

$ mount -o loop,offset=32256 centostest.img /mnt/tmp

他のパーティションをマウントするには(512 * 208845 =106928640):

$ mount -o loop,offset=106928640 centostest.img /mnt/tmp

セクター内

$ mount -o loop,offset=512 centostest.img /mnt/tmp

他のパーティションをマウントするには(512 * 14 =7168):

$ mount -o loop,offset=7168 centostest.img /mnt/tmp

これは、マウントしようとしている「パーティション」内のファイルシステムのタイプをマウントが判別できる場合にのみ機能します。 -t autoを含める必要がある場合があります 、または具体的にmountに伝えます それは-t ext4です たとえば。

参考資料

  • .imgファイルをマウントする方法

Linux
  1. CD / DVDのファイルシステムを見つけて自動的にマウントする方法:[Linux]

  2. LinuxでMimeタイプのアプリケーションを見つける方法は?

  3. ファイルを作成してファイルシステムとしてマウントする方法は?

  1. Python でファイルまたはディレクトリの所有者を見つける方法

  2. ファイルを gunzip して .gz ファイルを保持するにはどうすればよいですか?

  3. ディレクトリツリーで最も古いファイルを見つけるにはどうすればよいですか

  1. Linuxのディレクトリツリーで最も古いファイルを見つける方法

  2. Linux でファイルシステムを作成してマウントする方法

  3. Linux でファイルシステムをマウントおよびアンマウントする方法