User Tools

Site Tools


parted

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
parted [2021/09/12 09:32] – normanparted [2025/06/20 13:35] (current) – [Attach IMG file] norman
Line 1: Line 1:
 +====== Mount single partition from image of entire disk (device) ======
 +
 +Get the partition layout of the image
 +
 +<code>fdisk -lu sda.img</code>
 +
 +
 +<code>...
 +Units = sectors of 1 * 512 = 512 bytes
 +Sector size (logical/physical): 512 bytes / 512 bytes
 +...
 +  Device Boot      Start         End      Blocks   Id  System
 +sda.img1   *          56     6400000     3199972+   c  W95 FAT32 (LBA)</code>
 +
 +
 +Calculate the offset from the start of the image to the partition start
 +
 +Sector size * Start = (in the case) 512 * 56 = 28672
 +
 +Mount it on /dev/loop0 using the offset
 +
 +<code>losetup -o 28672 /dev/loop0 sda.img</code>
 +
 +Now the partition resides on /dev/loop0. You can fsck it, mount it etc
 +
 +<code>fsck -fv /dev/loop0
 +mount /dev/loop0 /mnt</code>
 +
 +
 +Unmount
 +
 +<code>umount /mnt
 +losetup -d /dev/loop0</code>
 +
 +
 +Source: [[https://askubuntu.com/questions/69363/mount-single-partition-from-image-of-entire-disk-device|External Link]]
 +
 +====== Attach IMG file ======
 +
 +<code>
 +losetup --find --show --partscan fred.image.dd
 +</code>
 +there should be partitions ( /dev/loopXpY )
 +Find one, You need:
 +<code>
 +cat /proc/partitions
 +ls -l /dev/loop*
 +</code>
 +
 +<code>
 +mdadm -A -R /dev/md9 /dev/loop1p4
 +</code>
 +
 +<code>
 +mount /dev/md9 /mnt/loop
 +</code>
 ====== Parted Use ====== ====== Parted Use ======
  
Line 28: Line 84:
 mkpart primary fat32 1 101 # or 257 for non-GRUB mkpart primary fat32 1 101 # or 257 for non-GRUB
 name 1 esp name 1 esp
 +
 +SWAP MISSING
 +
 +
 mkpart primary ext4 101 -1 # or 257 for non-GRUB mkpart primary ext4 101 -1 # or 257 for non-GRUB
 name 2 rootfs name 2 rootfs
parted.1631439152.txt.gz · Last modified: by norman