oriolrius.cat

Des del 2000 compartiendo sobre…

Tag: fdisk

Linux: Mounting file as a partition

Reading time: 1 – 2 minutes

When we have a file with a ‘dd’ of a full disk and we want to mount a partition of that disk, we have to use an offset for jumping to the beginning of the partition that we want to mount.
Using ‘fdisk’ command we can find the partitions of that disk copied inside a file.

fdisk -l FILE_WITH_DISK_INSIDE

Once partition table is shown there is a column called ‘Start’ using the corresponding number in this column for the partition that we want we can obtain the offset required for our mounting point. Reasoning behind that is multiply start sector per number of bytes per sector.

# OFFSET = START * 512
mount -o ro,loop,offset=OFFSET FILE_WITH_DISK_INSIDE /mnt

I hope thanks to this technical note next time that I forget how to get the offset I find it fastly.

UPDATE 2018/08/29:

If you don’t want to do that manually, there is a small tool called losetup which maps the partitions of a disk image on a file.


# example, attaching partitions to loopback devices
losetup -P /dev/loop0 DISK_IMAGE
# just mount the devices now, they are /dev/loop0pX where X is the number of the partition
# dettach this assignament:
losetup -d /dev/loop0

DiskPART – creant particions per windows des de la línia de comandes

Reading time: 1 – 2 minutes

Quan volem fer un deployment de software en windows potser el més difícil, almenys per mi, era saber com podia particonar els discos de forma automàtica i si és a través d’un batch process encara millor així ho podem automatitzar tot igual que en linux. Doncs bé des de fa un temps estic sindicat al blog Windows XP Embedded Team i a finals de l’any passant varen parlar d’aquesta eina i en van posar alguns exemples de funcionament, concretament l’article que parla del tema és: Using DISKPART to Improve Deployment Efficiency. Per cert, aquesta eina (DiskPART) la podeu trobar en el CD de WinXP Professional, així doncs no heu d’anar a buscar cap third party software i pagar per fer un deployment d’XP. A les pàgines de suport de M$ també podem trovar informació sobre aquesta eina concretament hi ha un manual interessant a A Description of the Diskpart Command-Line Utility.