oriolrius.cat

Des del 2000 compartiendo sobre…

Tag: mount

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

Trick PSP: com montar la MMC amb Linux

Reading time: < 1 minute

Fa uns quants mesos em van regalar una PSP, però encara quasi no l’he pogut ni tocar. De fet, aviat us explicaré les poques coses que he aconseguit fer amb la PSP en les meves poques hores de proves. La qüestió és que hi ha una línia que no vull perdre de vista, que són els paràmetres que calen per poder montar bé el sistema de fitxers vFAT de la targeta MMC. Així que l’apunto aquí per no perdre-la:

mount -t vfat -o noauto,noatime,users,shortname=win95,check=s,uid=1000 /dev/sda1 /mnt/psp