Skip to contentSkip to conversation

fdisk give wrong number for losetup

Qemu-devel octane indice 3 participants 5 messages Jul 7, 2005 – Jul 11, 2005

lore
Share & tools
lore
#0 lore raw

Hello

I have some trouble using losetup to mount partitions from the host.

root@zipslack:/usr/src/qemu-test# fdisk -l zipslack.img
Vous devez initialiser cylindres.
Vous pouvez faire cela à partir du menu des fonctions additionnelles.

Disque zipslack.img: 0 Mo, 0 octets
16 têtes, 63 secteurs/piste, 0 cylindres
Unités = cylindres de 1008 * 512 = 516096 octets

Périphérique Amorce Début Fin Blocs Id Système

zipslack.img1               1          49       24664+  82  Linux swap
zipslack.img2              50         253      102816   83  Linux
zipslack.img3             254         609      179424   83  Linux
root@zipslack:/usr/src/qemu-test#losetup -f
/dev/loop1
root@zipslack:/usr/src/qemu-test# losetup -o $((50*512)) /dev/loop1 zipslack.img
root@zipslack:/usr/src/qemu-test# mount -t ext2 /dev/loop1 /mnt/hd
mount: wrong fs type, bad option, bad superblock on /dev/loop1,
       missing codepage or other error
       In some cases useful info is found in syslog - try
       dmesg | tail  or so
root@zipslack:/usr/src/qemu-test# sfdisk zipslack.img
AVERTISSEMENT: zipslack.img n'est pas un périphérique fonctionnant par blocs
Disque zipslack.img: ne peut obtenir la géométrie

Disque zipslack.img: 0 cylindres, 0 têtes, 0 secteurs/piste
Vieille situation:
AVERTISSEMENT: la table de partitions semble avoir été créée
pour C/H/S=*/16/63 (au lieu de 0/0/0).
Pour ce rapport, la géométrie suivante sera assumée.
Unités= cylindres de 516096 octets, blocs de 1024 octets, décompte à partir de 0

Périph Amor Début Fin #cyls #blocs Id Système

zipslack.img1          0+     48      49-     24664+  82  Linux swap
zipslack.img2         49     252     204     102816   83  Linux
zipslack.img3        253     608     356     179424   83  Linux
zipslack.img4          0       -       0          0    0  Vide

L'entrée utiliser un des formats suivants; les champs absents prennent la valeur par défaut:
<début> <taille> <type [E,S,L,X,hex]> <amorçable [-,*]> <c,h,s> <c,h,s> Habituellement vous n'avez besoin que de spécifier:
<début> et <taille> (et parfois <type>).

zipslack.img1 :
root@zipslack:/usr/src/qemu-test#

root@zipslack:/usr/src/qemu-test# losetup -f
/dev/loop2
root@zipslack:/usr/src/qemu-test# losetup -o $((49*516096)) /dev/loop2
zipslack.img
root@zipslack:/usr/src/qemu-test# mount -t ext2 /dev/loop2 /mnt/hd/
root@zipslack:/usr/src/qemu-test# ls /mnt/hd/
bin/   cdrom/  etc/     home/     lib/         mnt/   root/  tmp/  var/
boot/  dev/    faq.txt  install/  lost+found/  proc/  sbin/  usr/  vmlinuz
root@zipslack:/usr/src/qemu-test#

And now, my questions: why this?

fdisk doesn't give the good values?
what's this number given by sfdisk: 516096 ?

thanks

---------------------------------------------
Etes vous un consom'Acteur ? Toutes les saveurs équitables sont sur http://www.epicerie-equitable.com

#1 lore raw
Quoted 5 lines · octane indice

Hello

I have some trouble using losetup to mount partitions from the host.

I never realized how difficult it was to interpret error messages written in a foreign language.

Quoted 3 lines

And now, my questions: why this?

Because you were passing the wrong value as the offset. You have to multipy the cylinder with the number of heads and number of sectors per head and such.

Quoted 1 line

what's this number given by sfdisk: 516096 ?

Apparently, head*sectors per head*bytes per sector ... my fdisk doesn't show that number though.

Quoted 3 lines

fdisk doesn't give the good values?

thanks

It does, but they are hard to interpret unless you understand disk geometries.

I really recommend using lomount or some similar tool to figure out these offsets for you. (Incidently, lomount doesn't care about disk geometry - it uses the absolute sector values in the partition table.)

Quoted 10 lines

---------------------------------------------
Etes vous un consom'Acteur ? Toutes les saveurs ?quitables sont sur http://www.epicerie-equitable.com

_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel

Signature · 2 lines
Infinite complexity begets infinite beauty.
Infinite precision begets infinite perfection.
author
#2 lore raw
Quoted 10 lines · Jim C. Brown
Quoted 4 lines

I have some trouble using losetup to mount partitions from the host.

I never realized how difficult it was to interpret error messages written in a foreign language.

Ok, sorry, in plain english messages are:

root@zipslack:/usr/src/qemu-test# fdisk -l zipslack.img
You must set cylinders.
You can do this from the extra functions menu.

Disk zipslack.img: 0 MB, 0 bytes
16 heads, 63 sectors/track, 0 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

Device Boot Start End Blocks Id System

zipslack.img1               1          66       33232+  82  Linux swap
zipslack.img2              67         609      273672   83  Linux

root@zipslack:/usr/src/qemu-test#

and mounting the file with an offset of $((67*512)) doesn't work

root@zipslack:/usr/src/qemu-test# sfdisk zipslack.img
Warning: zipslack.img is not a block device
Disk zipslack.img: cannot get geometry

Disk zipslack.img: 0 cylinders, 0 heads, 0 sectors/track
Old situation:
Warning: The partition table looks like it was made
for C/H/S=*/16/63 (instead of 0/0/0).
For this listing I'll assume that geometry.
Units = cylinders of 516096 bytes, blocks of 1024 bytes, counting from 0

Device Boot Start End #cyls #blocks Id System

zipslack.img1          0+     65      66-     33232+  82  Linux swap
zipslack.img2         66     608     543     273672   83  Linux
zipslack.img3          0       -       0          0    0  Empty
zipslack.img4          0       -       0          0    0  Empty

Input in the following format; absent fields get a default value. <start> <size> <type [E,S,L,X,hex]> <bootable [-,*]> <c,h,s> <c,h,s> Usually you only need to specify <start> and <size> (and perhaps <type>).

zipslack.img1 :

And mounting with $((66*516096)) is ok.

Quoted 22 lines
Quoted 3 lines

And now, my questions: why this?

Because you were passing the wrong value as the offset. You have to multipy the cylinder with the number of heads and number of sectors per head and such.

Quoted 13 lines

what's this number given by sfdisk: 516096 ?

Apparently, head*sectors per head*bytes per sector ... my fdisk doesn't show that number though.

fdisk doesn't give the good values?

thanks

Quoted 7 lines

It does, but they are hard to interpret unless you understand disk geometries.

I really recommend using lomount or some similar tool to figure out these offsets for you. (Incidently, lomount doesn't care about disk geometry - it uses the absolute sector values in the partition table.)

I receive a mail that says:
fdisk -l zipslack.img is not the same as fdisk- lu zipslack :

root@zipslack:/usr/src/qemu-test# fdisk -lu zipslack.img
You must set cylinders.
You can do this from the extra functions menu.

Disk zipslack.img: 0 MB, 0 bytes
16 heads, 63 sectors/track, 0 cylinders, total 0 sectors Units = sectors of 1 * 512 = 512 bytes

Device Boot Start End Blocks Id System

zipslack.img1              63       66527       33232+  82  Linux swap
zipslack.img2           66528      613871      273672   83  Linux

and incidently $((66*516096))=$((66528*512))

thanks.

#3 lore raw
Quoted 19 lines · octane
Quoted 8 lines · Jim C. Brown
Quoted 3 lines

I have some trouble using losetup to mount partitions from the host.

I never realized how difficult it was to interpret error messages written in a foreign language.

Ok, sorry, in plain english messages are:

root@zipslack:/usr/src/qemu-test# fdisk -l zipslack.img
You must set cylinders.
You can do this from the extra functions menu.

Disk zipslack.img: 0 MB, 0 bytes
16 heads, 63 sectors/track, 0 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

Quoted 6 lines

Device Boot Start End Blocks Id System

zipslack.img1               1          66       33232+  82  Linux swap
zipslack.img2              67         609      273672   83  Linux

root@zipslack:/usr/src/qemu-test#

and mounting the file with an offset of $((67*512)) doesn't work

The offset if 67*516096, as this partition table is printed in cylinders, not sectors.

When calculating partition offsets it is always best to look at the partition table in sectors, not cylinders, especially considering that partitions does not need to start exactly on a cylinder boundary. For example the first partition doesn't start at cylinder 1, it starts at cylinder 1 head 2, or sector 64. Both fdisk and sfdisk supports viewing the sector based partition values, maintaining sanity.

Quoted 3 lines
Quoted 3 lines

I really recommend using lomount or some similar tool to figure out these offsets for you. (Incidently, lomount doesn't care about disk geometry - it uses the absolute sector values in the partition table.)

Nearly nobody except for DOS (and the parts of BIOS used by DOS) cares about geometry..

Quoted 10 lines

I receive a mail that says:
fdisk -l zipslack.img is not the same as fdisk- lu zipslack :

root@zipslack:/usr/src/qemu-test# fdisk -lu zipslack.img
You must set cylinders.
You can do this from the extra functions menu.

Disk zipslack.img: 0 MB, 0 bytes
16 heads, 63 sectors/track, 0 cylinders, total 0 sectors Units = sectors of 1 * 512 = 512 bytes

Quoted 5 lines

Device Boot Start End Blocks Id System

zipslack.img1              63       66527       33232+  82  Linux swap
zipslack.img2           66528      613871      273672   83  Linux

and incidently $((66*516096))=$((66528*512))

Correct, from the cylinders/heads/sectors geometry. If you look at the swap partition then things is more interesting.. (also why sfdisk printed a + there, and probably what the + in the blocks column of fdisk refers to...)

Regards
Henrik

#4 lore raw
In reply to octane indice
Quoted 9 lines · octane indice

Hello

I have some trouble using losetup to mount partitions from the host.

root@zipslack:/usr/src/qemu-test# fdisk -l zipslack.img
Vous devez initialiser cylindres.
Vous pouvez faire cela à partir du menu des fonctions additionnelles.
Quoted 8 lines

Disque zipslack.img: 0 Mo, 0 octets
16 têtes, 63 secteurs/piste, 0 cylindres
Unités = cylindres de 1008 * 512 = 516096 octets

Périphérique Amorce Début Fin Blocs Id Système

zipslack.img1               1          49       24664+  82  Linux swap
zipslack.img2              50         253      102816   83  Linux
zipslack.img3             254         609      179424   83  Linux

fdisk -l -u zipslack.img

or

sfdisk -d zipslack.img

gives a much better view of the partition table.. (blocks, not cylinders)

Regards
Henrik