2012年7月30日 星期一

Manage Partitions of the Disk Image with loop device

loop device is a pseudo-device that makes a file accessible as a block device.
We can use loop device to manage partitions of the disk image.

Make sure you loop device driver is configured to support loop device partitions.
In my FC16 box, I manually add kernel command:
loop.max_part=63
Here is an example when I attach a disk image with losetup.

$ cat /proc/partitions
major minor  #blocks  name

   8        0   33554432 sda
   8        1     512000 sda1
   8        2   33041408 sda2
  11        0    1048575 sr0
   8       16  104857600 sdb
   8       17  104856576 sdb1
 253        0    4128768 dm-0
 253        1   28901376 dm-1

$ losetup -f disk_image
$ cat /proc/partitions
major minor  #blocks  name

   7        0    1048576 loop0
   7        1      10240 loop0p1
   7        2    1037312 loop0p2

   8        0   33554432 sda
   8        1     512000 sda1
   8        2   33041408 sda2
  11        0    1048575 sr0
   8       16  104857600 sdb
   8       17  104856576 sdb1
 253        0    4128768 dm-0
 253        1   28901376 dm-1

$ losetup -d /dev/loop0


沒有留言:

張貼留言