Difference between revisions of "Disk mounting"
(→fdisk) |
|||
Line 10: | Line 10: | ||
</pre> | </pre> | ||
− | == mount individual partitions in a whole disk image == | + | == losetup -- mount individual partitions in a whole disk image == |
If you have a while disk image and you want to mount partitions inside that image then use `losetup` to create a loopback device for the image. | If you have a while disk image and you want to mount partitions inside that image then use `losetup` to create a loopback device for the image. | ||
Line 20: | Line 20: | ||
</pre> | </pre> | ||
− | You can later create a | + | You can later create a loop device for it and see its partitions with `fdisk` and mount those partitions individually with `mount`. Note that `fdisk -l` does not normally show loop devices. You must add an explicit path to the loop device that you want to list. |
<pre> | <pre> | ||
Line 26: | Line 26: | ||
fdisk -l /dev/loop0 | fdisk -l /dev/loop0 | ||
</pre> | </pre> | ||
+ | |||
+ | The previous example assumed that /dev/loop0 was free. You can you the '-f' option to automatically find a free loop device. In this example we first use the '-f' option to associate the image file with the next available loop device; then we use the '-j' option to see what loop device was associated with the file: | ||
+ | |||
+ | <pre> | ||
+ | losetup -f disk.img | ||
+ | losetup -j disk.img | ||
+ | <pre> | ||
+ | |||
+ | === mounting partitions inside a disk image without loop device === | ||
It is also possible to mount partitions inside a disk image file directly with `mount` using the 'offset' option, but I have not had luck with this. | It is also possible to mount partitions inside a disk image file directly with `mount` using the 'offset' option, but I have not had luck with this. |
Revision as of 14:39, 15 February 2009
fdisk
This will list all the disks that Linux sees. This will not show loop devices. See `losetup` example for more information:
fdisk -l
losetup -- mount individual partitions in a whole disk image
If you have a while disk image and you want to mount partitions inside that image then use `losetup` to create a loopback device for the image.
For example, if you copied an entire disk using `dd` like this:
dd if=/dev/sda of=disk.img bs=32768
You can later create a loop device for it and see its partitions with `fdisk` and mount those partitions individually with `mount`. Note that `fdisk -l` does not normally show loop devices. You must add an explicit path to the loop device that you want to list.
losetup /dev/loop0 disk.img fdisk -l /dev/loop0
The previous example assumed that /dev/loop0 was free. You can you the '-f' option to automatically find a free loop device. In this example we first use the '-f' option to associate the image file with the next available loop device; then we use the '-j' option to see what loop device was associated with the file:
losetup -f disk.img losetup -j disk.img <pre> === mounting partitions inside a disk image without loop device === It is also possible to mount partitions inside a disk image file directly with `mount` using the 'offset' option, but I have not had luck with this. <pre> mount -o loop,ro,offset=1025 disk.img /media/adhoc