Advertisement
Tritonio

How to mount a partition from a full disk image

Mar 13th, 2021
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1.  
  2.  
  3. Get the partition layout of the image
  4.  
  5. $ sudo fdisk -lu sda.img
  6. ...
  7. Units = sectors of 1 * 512 = 512 bytes
  8. Sector size (logical/physical): 512 bytes / 512 bytes
  9. ...
  10. Device Boot Start End Blocks Id System
  11. sda.img1 * 56 6400000 3199972+ c W95 FAT32 (LBA)
  12.  
  13. Calculate the offset from the start of the image to the partition start
  14.  
  15. Sector size * Start = (in the case) 512 * 56 = 28672
  16.  
  17. Mount it on /dev/loop0 using the offset
  18.  
  19. sudo losetup -o 28672 /dev/loop0 sda.img
  20.  
  21. Now the partition resides on /dev/loop0. You can fsck it, mount it etc
  22.  
  23. sudo fsck -fv /dev/loop0
  24. sudo mount /dev/loop0 /mnt
  25.  
  26. Unmount
  27.  
  28. sudo umount /mnt
  29. sudo losetup -d /dev/loop0
  30.  
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement