揮発性のメモ2

http://d.hatena.ne.jp/iww/

ddで吸い出したHDDイメージファイルをループバックマウントする

Vine Linux Magazine - ループバックマウントとchrootで作るなんちゃって仮想マシン
ここに書いてある手順を順に追ってみる。


まず、fdiskコマンドで中身を確認する。

$ /sbin/fdisk -l img.ddi
You must set cylinders.
You can do this from the extra functions menu.

Disk img.ddi: 0 MB, 0 bytes
255 heads, 63 sectors/track, 0 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00072872

  Device Boot      Start         End      Blocks   Id  System
img.ddi1   *           1         926     7438063+  83  Linux
img.ddi2             927         974      385560    5  Extended
img.ddi5             927         974      385528+  82  Linux swap / Solaris

ファイルが相手だとシリンダ数が分からんらしい。が、無くても困らないので気にしない。
第1パーティションの開始位置は 1*63*512=32256 なので、オフセット指定してマウントする。

$ mkdir hoge
$ sudo mount -o loop,ro,offset=32256 img.ddi hoge

$ ls hoge/
bin    dev   initrd.img      lost+found  opt   sbin     sys  var
boot   etc   initrd.img.old  media       proc  selinux  tmp  vmlinuz
cdrom  home  lib             mnt         root  srv      usr  vmlinuz.old

できた。おわり。