2018/02/08
Raw Disk Image file を Ubuntu でマウントする方法
Ubuntu 16.04 LTS 上で VDI を Raw Disk Image に変換したもので確認。
参考
パーティション情報を確認する
parted
を使ってパーティション情報を確認します。
print
で情報を表示するだけなのですが、u
を使ってユニットを byte にしておくと後で計算しなくて良いので楽です。
以下の例だと 1つめのパーティションは ext4 フォーマットで 1048576 byte から始まっていることがわかります。
$ file image.img image.img: DOS/MBR boot sector $ parted image.img WARNING: You are not superuser. Watch out for permissions. GNU Parted 3.2 Using /home/yusuke/Documents/Ubuntu/image.img Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) u Unit? [compact]? B (parted) print Model: (file) Disk /home/yusuke/Documents/Ubuntu/image.img: 53687091200B Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 1048576B 52612300799B 52611252224B primary ext4 boot 2 52613349376B 53687091199B 1073741824B extended 5 52614397952B 53684994047B 1070596096B logical linux-swap(v1) (parted) q |
マウント
以下のように offset
を指定することで対象のパーティションをマウントすることが出来ます。
$ sudo mount -t ext4 -o loop,rw,offset=1048576 image.img ~/tmp |
fdisk でも確認出来る
fdisk
を使ってもパーティション情報を確認できます。
ただ、fdisk は sector 情報1の表示になるので、自分で byte に変換しなければなりません。
以下の例だと 2048 sectors から開始しているので、 2048 × 512 = 1048576 bytes です2。
1 2 3 4 5 6 7 8 9 10 11 12 | $ fdisk --units=sectors -l image.img Disk image.img: 50 GiB, 53687091200 bytes, 104857600 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 Disklabel type: dos Disk identifier: 0x3139074e Device Boot Start End Sectors Size Id Type image.img1 * 2048 102758399 102756352 49G 83 Linux image.img2 102760448 104857599 2097152 1G 5 Extended image.img5 102762496 104853503 2091008 1021M 82 Linux swap / Solaris |
0 件のコメント:
コメントを投稿