Geometry Problem (Debian 1.3 on VirtualBox ≥ 7.1.2)

Spoiler: As it’s always the case with tutorial, it happens that some update break everything. We must then search the root cause and then fix it.

Some days ago, we recieved a mail from a trainee student in digital archeology, that looks at the impact of old time technologies (i.e. from the 90’s). He stepped into our tutorial on how to install a Debian 1.3 on a Virtualbox and reached a fatal error when partitionning the disk. The system tell him that it was not able to read the geometry. Why ?

TL;DR: The fix is at the end of this page.

We then start by reproducing the problem. With a Windows 10 (22h02) and VirtualBox 7.1.6, we step into the tutorial without problem until partitioning and then, it happens…

FATAL ERROR: Cannot read disk drive geometry.

We’re pretty sure of our tutorial because we always test them, but maybe an error went unnoticed in this one… So we go back to the original setup (VirtualBox 6.0) and this time everything goes perfectly; the system installs and works.

We could have stopped there and replied, as an IT support service would have done: it’s not from our side. After all, it’s not our problem. But we’re judokas; Jita Kyoei. After replying to our reader, we wrote this article.

Initial searchs, VirtualBox

When we discover the proble, there’s no point in searching the Internet to find some solution. We are not enough to already have encountered this situation, solved it and documented the process. We’ll have to find it by ourselves.

And as always, there is multiple potential solutions. We know in advance that only some of them will work, but in order to know which ones, we need to try and check them out. Here is a list of things tbowan have tried:

With no surprise for you, none of those solutions made any difference. It’s normal and that explains why it’s always more difficult (and longer) to find why something does not work than to make it works (perhaps an NP-Hard problem?).

In parallel, aryliin is searching which VirtualBox version have introduced the bug. There are 53 of them between the 6.0 and the 7.1.6. One installation and check at a time, she finally find that the first to bug with debian 1.3 is is the 7.1.2 (published the september 26th 2024).

There is no mention to IDE or disk management in the changelog. In order to find the root cause, we’ll need to search in the source code… But at some point, we must be able to stop searching and go resolving more important stuffs.

Secondary Searchs, Debian

Instead of digging the VirtualBox’s source code, we turned our attention to Debian 1.3 and it’s installation process. More specifically toward cfdisk which is the tool used to partition the disk and which generate the error message. It won’t solve the error, but solve the problem.

If you start typing man cfdisk on some search engine, you may end up in some old manual pages (e.g. man-linux-magique.net or linux.die.net) which write a bit about geometry and tells that cfdisk looks first at the partition table, then ask the kernel, then uses some default values (255 heads, 63 sectors and compute the cylinders from the size). Except if you provides the tools with your own geometry (short options -c, -h and -s).

But on a more recent version, this behaviour differs: cfdisk no longer manage those options about cylinders, heads and sectors. Why? because it does not use this old addressing scheme any more.

Since version 2.25 cfdisk […] no longer provides any functionality for CHS (Cylinder-Head-Sector) addressing.

man cfdisk, Karel Zak.

For the sake of curiosity, we then checked the source code (see the git repository) and indeed, before version 2.25-rc1 (June 2014), or more precisely the commit 8c3a5a440 (march 2014), the decide_on_geometry() function was in charge of determining the disk geometry. Here is its code:

static void
decide_on_geometry(void) {
    heads = (user_heads ? user_heads :
         pt_heads ? pt_heads :
         kern_heads ? kern_heads : 255);
    sectors = (user_sectors ? user_sectors :
           pt_sectors ? pt_sectors :
           kern_sectors ? kern_sectors : 63);
    cylinder_size = heads*sectors;
    cylinders = actual_size/cylinder_size;
    if (user_cylinders > 0)
        cylinders = user_cylinders;

    if (cylinder_size * cylinders > actual_size)
        print_warning(_("You specified more cylinders than fit on disk"));
}

But was that the case on our Debian 1.3? This function and its B-Plan system was added in version 2.9v (december 2006) et more precisely in commit 7eda085c4. Thus, it was not the case when Debian 1.3 was published.

The version we find on our Debian 1.3 (see this repository) is more simple. cfdisk ask the kernel and uses the returned values if none where provided on command line. The relevant function (fill_p_info()) is quite long so here are the interresting parts:

#define BAD_GEOMETRY "Cannot read disk drive geometry"

/* ... */

void fill_p_info(void)
{
    /* ... */

    if (!ioctl(fd, HDIO_GETGEO, &geometry)) {
        if (!heads)
            heads = geometry.heads;
        if (!sectors)
            sectors = geometry.sectors;
        if (!cylinders)
            cylinders = geometry.cylinders;
    }

    if (!heads || !sectors || !cylinders)
        fatal(BAD_GEOMETRY);

    /* ... */
}

When we wrote our tutorial with VirtualBox 6.0, the Linux kernel was able to ask the device to get its geometry and provided the amount of cylinders, heads and sectors. cfdisk was able to proceed.

The 7.1.2 update thus introduced some change that makes the kernel return null values. cfdisk thus ignore what to do and fails with an [hopefully usefull] error message.

Hopefully, that historic version of cfdisk accept option to set the geometry. We only need a way to pass those option when installing Debian 1.3.

And we are lucky, the install process provides us, at each step, an option to execute a shell (which come back to the installer when closed). When partitionning, we go to that option, run cfdisk with the relevant geometry and proceed to the next step of the tutorial.

We check it works (this is the case), we reply to the trainee student which validates on its side that is works. We can then begin to write this article.

Final searchs, Virtualbox

When writing the article, we recieved another email from the trainee. After having tried other ideas, he ended up with a working setup using a 1 GB disk (which interrested us since we already tested that size).

Since he kindly send us his OVA, we can test it (it works) and, one parameter at a time, change ours to meet his values and see which one makes a difference…

None of them resolve the issues. Until we comes to the SATA Controller. It’s useless here and nothing is plugged in but our virtual machines had one (by default) and the trainee’s machine does not.

We delete this useless controller and it works 🎉 We change the other parameters backs and it still works. We then check other disk sizes and it works with all of them (except that cfdisk only see the first 8GB of them). That the component that broke our beautiful tutorial.

But, why this comes from the 7.1.2 update? Mystery.

Solving it

We now have two workaround when one want to install a Debian 1.3 on a VirtualBox ≥ 7.1.2.

Virtualbox Side

Once the virtual machine is created, go the the parameters, then the storage part. Click on the SATA controller and delete it (icon in the bottom with a red cross).

Debian Side

At the partition step, chose Execute a Shell (in the bottom of the list), and then once in the shell, run cfdisk with the relevant geometry options. Here is an example for an 8GB disk:

cfdisk -c 1024 -h 255 -s 63
Executing a Shell then running cfdisk by hand.

The partitioning is done as usual and once we wrote the partition and exit cfdisk, we must exit the shell (command exit). The installation process then proceed as usual (e.g. the remaining of our tutorial).

And after?

After having found the solution, we wondered how these mighty generatives AI, which are going to save the world, would have solved it…

We wrote we followed the tutorial (and which one it is), that is was about installing a Debian 1.3 on a VirtualBox machine and what is the error message. Here are the answer we got:

We might have compared those IA to interns who don’t know how to do anything. Well, today we proved, by example, that they don’t even reached the intern’s level. Since the interne, by himself, found a solution (ask the arsouyes remove the SATA controller).

This article’s conclusion is straightforward: if you want to save the world, hire some interns.