← Back to team overview

ubuntu-phone team mailing list archive

Re: [PATCH] Create swap file on first boot

 

On 03/12/2013 12:28 PM, Oliver Grawert wrote:
hi,
On Di, 2013-03-12 at 12:15 +0100, f69m wrote:
Sorry for the late answer!

On 03/05/2013 06:02 AM, Ricardo Salveti de Araujo wrote:
On 03/01/2013 04:09 PM, f69m wrote:
Hi everyone,

Please find attached a small patch that will create /data/swapfile on
first boot.
If you don't want a swapfile, just create an empty /data/swapfile.

Pros:

   * The swap file can be removed from the rootfs, which makes that
     significantly smaller and faster to flash.
   * Once created, the swap file persists updates and does not need to be
     recreated.

Cons:

   * Can't think of any.

Details:

   * The patch should be applied to
git://phablet.ubuntu.com/ubuntu/uchroot.
   * Creates /data/swapfile, if it does not exist yet.
   * Runs swapon, if the file exists and is not empty.

Hope this patch is acceptable and can be included for everyone.
There's already a SWAP file at the ubuntu side (check
/data/ubuntu/SWAP.swap).
Yes, I know. My goal was to remove it from the rootfs distribution.

But your solution might work better as we can remove this step from
image build time.
Well, and from flash time. Though it probably compresses well, it is an
extra 100 MB to be flashed each time you extract a new rootfs.

Removing both SWAP.swap and the redundant
usr/share/demo-assets/pictures.tgz (same files unpacked in home) reduces
the ZIP size to about 390 MB. This is a reduction of more than 20 %. And
the speed-up for flashing is probably much more, as the swap file is
likely to compress really well in the ZIP.

I'd just like an extra check in case there's not enough disk space
before creating the swapfile.
That is a great idea, thanks!
I'll have a look into that.

we used to do that with jasper-initramfs [1] for preinstalled images in
the past. the problem is that you can not create swap files as sparse
files so you actually have to write 512M zeros to the eMMC which takes a
good bunch longer than just copying a pre-made swapfile in place. you
have a time penalty either way (either it takes long to flash or it
takes long to create a swap file in place) ...
i doubt the time for the enduser will make a difference ...
for the former images we had we finally decided to keep it in the form
we have on the phablet images too now, it would be interesting if
someone could measure the time both ways take and compare them.

ciao
	oli

[1] https://code.launchpad.net/~canonical-arm/jasper-initramfs/trunk
...
http://bazaar.launchpad.net/~canonical-arm/jasper-initramfs/trunk/view/head:/scripts/local-bottom/jasper_setup



Hmm, dd from /dev/zero takes longer than unpacking the same amount of data from a tar? That sounds really weird to me, as exactly the same amount of data is written to the device; though I have to admit I am not really a specialist on flash-based storage.
Is there a known technical reason for this or is it empirical data?

Anyhow, in the current state of Ubuntu Touch, I prefer running dd *once* and have the swap file persistent under /data/, instead of reflashing it with each update under /data/ubuntu/. That's how it will stay for now in my customized rootfs image for Asus TF300T (needs libc replacement).

But I will sure do some time measurements myself and may change it, once re-flashing the rootfs is no longer a major part of development. ;)

Thanks for your input!


Follow ups

References