Please use os.truncate() instead of dd when creating the file

Bug #1619351 reported by Michael Vogt
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu Image
Invalid
Undecided
Unassigned

Bug Description

The current use of "dd" to create the image means that a real 4gb file is created. The previous ubuntu-device-flash would use a sparse file for this. This is important for the snappy project because we take the image, load it into ram and write it to a test machine to do the testing of the actual machine. However this only works if the file fits in ram. with a sparse file it does, with a real 4gb file it does not.

I started working on this but got stuck in mkfs.ext4 not creating a partition apparently.

Revision history for this message
Steve Langasek (vorlon) wrote :

We should switch to native Python operations wherever feasible, but I can't see the problem you're describing. I've tested the sparseness at every stage and while ls shows a 4GB image, du consistently shows it occupying 300M on disk. What are you seeing that suggests this is not sparse?

Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Things look fine to me too; the file is indeed a sparse file:

[14:13:55] mtrudel@demeter:~git $ ls -latr
total 417584
[...]
drwxrwxr-x 53 mtrudel mtrudel 4096 sep 1 12:45 ./
-rw-rw-r-- 1 mtrudel mtrudel 4000000000 sep 1 12:48 toto.img
drwxrwxr-x 9 mtrudel mtrudel 4096 sep 1 14:05 ubuntu-image/
[14:13:56] mtrudel@demeter:~git $ du -hs toto.img
396M toto.img

Changed in ubuntu-image:
status: New → Incomplete
Revision history for this message
Barry Warsaw (barry) wrote :

See also the discussion in LP: #1619362 although I'm not going to dupe this bug to that one.

summary: - Please use os.trunacte() instead of dd when creating the file
+ Please use os.truncate() instead of dd when creating the file
Revision history for this message
Michael Vogt (mvo) wrote :

This is fixed with the latest master.

Changed in ubuntu-image:
status: Incomplete → Fix Committed
Revision history for this message
Michael Vogt (mvo) wrote :

Fwiw, I think what happend to me was exactly the cross-device copy. When testing my "fix" I used a named working directory to inspect things and stuff magically works. So sorry for the incorrect report.

Changed in ubuntu-image:
status: Fix Committed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.