Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
topics:disk-image-mount-partition [2017/03/26 05:20] orzfly created |
topics:disk-image-mount-partition [2017/03/26 06:15] (current) orzfly [Mounting] |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Mount Partitions in Disk Image ====== | ====== Mount Partitions in Disk Image ====== | ||
| + | |||
| + | * [[# | ||
| + | * [[# | ||
| + | * [[# | ||
| + | * [[# | ||
| + | |||
| + | ===== losetup partscan ===== | ||
| + | If you have util-linux v2.21 or higher, you can now do this with losetup. Use the -P (--partscan) option to read the partition table and create device nodes for each partition. | ||
| + | |||
| + | * http:// | ||
| + | ==== Mounting ==== | ||
| + | - Mount image as loop device< | ||
| + | # losetup -P /dev/loop0 rpool.img | ||
| + | </ | ||
| + | - Finish< | ||
| + | # ls /dev/loop0* -l | ||
| + | brw-rw---- 1 root disk 7, 0 Mar 26 13:36 /dev/loop0 | ||
| + | brw-rw---- 1 root disk 259, 2 Mar 26 13:36 / | ||
| + | brw-rw---- 1 root disk 259, 3 Mar 26 13:36 / | ||
| + | </ | ||
| + | |||
| + | ==== Unmounting ==== | ||
| + | |||
| + | - Unload loop device< | ||
| + | # losetup -d /dev/loop0 | ||
| + | </ | ||
| + | |||
| + | ===== partprobe ===== | ||
| + | If you have a recent kernel, and pass loop.max_part=63 on boot (if loop is built-in) or to modprobe (if loop is a module). | ||
| + | |||
| + | * https:// | ||
| + | ==== Mounting ==== | ||
| + | - Mount image as loop device< | ||
| + | # losetup /dev/loop0 rpool.img | ||
| + | </ | ||
| + | - Run partprobe< | ||
| + | # partprobe /dev/loop0 | ||
| + | </ | ||
| + | - Finish< | ||
| + | # ls /dev/loop0* -l | ||
| + | brw-rw---- 1 root disk 7, 0 Mar 26 13:23 /dev/loop0 | ||
| + | brw-rw---- 1 root disk 259, 0 Mar 26 13:23 / | ||
| + | brw-rw---- 1 root disk 259, 1 Mar 26 13:23 / | ||
| + | </ | ||
| + | |||
| + | ==== Unmounting ==== | ||
| + | |||
| + | - Unload loop device< | ||
| + | # losetup -d /dev/loop0 | ||
| + | </ | ||
| ===== kpartx ===== | ===== kpartx ===== | ||
| Line 19: | Line 69: | ||
| </ | </ | ||
| - Finish< | - Finish< | ||
| - | # ls /dev/mapper -l | + | # ls /dev/mapper/ |
| - | total 0 | + | |
| - | crw------- 1 root root 10, 236 Feb 7 17:52 control | + | |
| lrwxrwxrwx 1 root root 7 Mar 26 13:16 loop0p1 -> ../dm-0 | lrwxrwxrwx 1 root root 7 Mar 26 13:16 loop0p1 -> ../dm-0 | ||
| lrwxrwxrwx 1 root root 7 Mar 26 13:16 loop0p9 -> ../dm-1 | lrwxrwxrwx 1 root root 7 Mar 26 13:16 loop0p9 -> ../dm-1 | ||
| Line 27: | Line 75: | ||
| ==== Unmounting ==== | ==== Unmounting ==== | ||
| - | |||
| - Disconnect the device map files using kpartx< | - Disconnect the device map files using kpartx< | ||
| Line 38: | Line 85: | ||
| </ | </ | ||
| + | ===== losetup offset / sizelimit ===== | ||
| + | * https:// | ||
| + | ==== Mounting ==== | ||
| + | |||
| + | - Get partition details< | ||
| + | # fdisk -l rpool.img | ||
| + | Disk rpool.img: 21 GiB, 22548578304 bytes, 44040192 sectors | ||
| + | Units: sectors of 1 * 512 = 512 bytes | ||
| + | Sector size (logical/ | ||
| + | I/O size (minimum/ | ||
| + | Disklabel type: gpt | ||
| + | Disk identifier: B37248EB-F1D7-DA47-A42D-4C42AF20D328 | ||
| + | |||
| + | Device | ||
| + | rpool.img1 | ||
| + | rpool.img9 44021760 44038143 | ||
| + | </ | ||
| + | - Setup loop device< | ||
| + | # losetup /dev/loop0 rpool.img --offset $((512 * 2048)) --sizelimit $((512 * 44019712)) | ||
| + | </ | ||
| + | ==== Unmounting ==== | ||
| + | |||
| + | - Unload loop device< | ||
| + | # losetup -d /dev/loop0 | ||
| + | </ | ||
| + | {{tag> | ||