drakkar-lig / debootstick

Generate a bootable live image from any Debian/Ubuntu filesystem tree.
62 stars 18 forks source link

debootstick sometimes fails if the previous run was not cleaned #19

Open dmuhamedagic opened 5 years ago

dmuhamedagic commented 5 years ago

If the image generated cannot fit on the target directory debootstick fails with read (perhaps also write) errors:

I: detected target system: amd64 PC
I: generating a UEFI bootloader binary... done
I: draft image - computing a size large enough... done
I: draft image - partitioning and formatting...   Error reading device /dev/DBSTCK-c4a05a33/ROOT at 0 length 512.
  Error reading device /dev/DBSTCK-c4a05a33/ROOT at 0 length 4096.
  Error reading device /dev/DBSTCK-c4a05a33/ROOT at 0 length 512.
  Error reading device /dev/DBSTCK-c4a05a33/ROOT at 0 length 4096.
done
I: draft image - copying filesystem tree... ^C
Interrupted.

I'm not sure why is there a read error, but apparently the program doesn't check the exit code there.

It would also be good to check the amount of free space on the disk and just don't run if there's not enough of it.

eduble commented 5 years ago

debootstick shell scripts are called with set -e flag, so except for a few specific cases, failing commands should always interrupt the program. Thus, I tend to think that the command that prints those errors returns zero (erroneously). About the free space check, since debootstick may have to install missing packages (linux kernel, lvm, etc.), or not (if they are already installed), I believe it is not possible to get an accurate value of the free space size needed. But we can still make en estimate and check it.

Here is what I propose:

And we have three cases:

What do you think?

dmuhamedagic commented 5 years ago

That's great! Very thorough! Yes, programs exiting with inappropriate exit code is not so seldom.

dmuhamedagic commented 5 years ago

While we're at surprising behaviour, I noticed that the "out of space" condition on a loop device results in I/O errors. That happens as a program wants to write beyond the end. I couldn't find any information about that.

eduble commented 5 years ago

OK. I hope I will have a little time tomorrow to work on these issues.

dmuhamedagic commented 5 years ago

This seems to be a different problem. Looks like some interaction with the device mapper and the VG which debootstick creates. It seems like it happens after debootstick interrupted and the VG remains around.

dmuhamedagic commented 5 years ago

I'm not sure how to reproduce this, perhaps I pressed ctrl-C twice, before debootstick had a chance to clean up the device mapper/lvm stuff. Perhaps to ignore the signals during the cleanup?