-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Something is likely wrong when calculating the minimum block count #10
Comments
Bug discovered thanks to Romain Guinot (issue #10).
You're right, Romain. Thanks for detailed report (*) that allowed me to find a blatant omission in the code! I've already committed a fix: 7903b07. You have to know that it can still don't allow to shrink as much as you did, because zero blocks are data too, so I cannot treat them as garbage, because I have no way to know the real origin of these zeroes. And vidma doesn't allow you to resize dynamic VDI in a way that could destroy part your data. In future there will be a way to enforce such dangerous operation. (*) Still, could be better. ;-) |
Hi, Thanks for the update. distribution :
cc -v :
For vidma versions i tried the latest release 0.0.3b and git.9478881. Thanks for your explanations.
By the way here you may want to add 2012 in the copyright notice :)
Do you think it would make sense to add a --force option here, if the user knows they are only zeroes ? Let me know what you think, |
Yeah, I should.
TODOs #4 and #5 roughly show what I am aiming for in terms of flexibility. So yes, But again, it's not about knowing that there are only zeroes, because It's worth to add that relying solely on blocks with data (allocated or zeroes) is not enough, because filesystem format (rarely modifying whole partition nowadays) could simply not modify the last sector of the partition and similarly user's files could not reach that point either yet. In such case you can shrink the image more than you should, making last partition(s) geometry no longer correct, breaking file system size metadata (if stored), and so on... literally asking for lots of trouble. But unless you use such image and make the damage running it under VM, this image image is perfectly fine in terms of data stored in it and can be "cured" by enlarging it to the point where last partition ends.
Because 16370th block (counting goes from 0) has some data (possibly leftovers from before partition was resized, e.g. some file systems store super-blocks/metadata in many copies and one of them can be near the end of the file system). Below you have a patch that treats unallocated zero-filled blocks just like other unallocated blocks. If you must, use this, but with extreme care, remembering about all the things I mentioned here.
P.S. You still haven't shown your image header information (even though I mentioned it explicitly in my previous comment), i.e. the output of |
Hi, Many thanks for the details, speed of response, and thanks again for writing the tool. For reference, here is the output of vidma test.vdi : vidma test.vdi :
fake test resize, just to test the minimal detected block count :
The minimum block count seems correct (same value with or without the latest patch), and seems indeed to correspond to the last data block. also seems to be confirmed when viewing the defrag view. (btw the resize output from the previous comment was from another test VM. the two outputs in this comment are for the same VM, the one that i resized in the original comment). Cheers, |
Hi,
Thanks for the tool it is useful !
I noticed however that the minimum block count was wrong in my case, it wouldn't allow me to shrink a virtual disk size.
I commented out that check and everything worked out OK. See description below :
-- tests on Jul 28,2012 :
comment out that check in vdi.c :
works out OK :
The VM worked fine afterwards.
I had prior to the resize defragmented and shrunk the vm partition of the windows guest down with gparted live CD, to the size that i then requested with vidma.
Something must be wrong in find_last_blocks, but i have not investigated further.
Let me know what you think,
Regards,
Romain.
The text was updated successfully, but these errors were encountered: