Bug 15257 - Live installer (not live mode) partitioner: Available disk space is not computed correctly (at least in small VM disks)
Summary: Live installer (not live mode) partitioner: Available disk space is not compu...
Status: RESOLVED FIXED
Alias: None
Product: Mageia
Classification: Unclassified
Component: RPM Packages (show other bugs)
Version: Cauldron
Hardware: All Linux
Priority: release_blocker major
Target Milestone: ---
Assignee: Thomas Backlund
QA Contact:
URL:
Whiteboard:
Keywords: NEEDINFO, PATCH
Depends on:
Blocks: 14069
  Show dependency treegraph
 
Reported: 2015-02-10 17:21 CET by Rémi Verschelde
Modified: 2015-05-21 16:11 CEST (History)
9 users (show)

See Also:
Source RPM: draklive-install
CVE:
Status comment:


Attachments
Log from draklive-install-2.3.-1.mga5 on 5-beta3-LiveDVD-KDE4-x86_64 (8.28 KB, text/plain)
2015-04-12 16:46 CEST, Zoltan Balaton
Details
Patch #1 - apply to drakx (1.50 KB, text/plain)
2015-05-12 01:57 CEST, Martin Whitaker
Details
Patch #2 - apply to draklive-install (1.51 KB, patch)
2015-05-12 02:06 CEST, Martin Whitaker
Details | Diff
(getNeededMinSpace) split it out (1.41 KB, patch)
2015-05-12 10:33 CEST, Thierry Vignaud
Details | Diff
enables to get raw available space (mga15257) (926 bytes, patch)
2015-05-12 10:33 CEST, Thierry Vignaud
Details | Diff
better reporting of insufficient space (mga#15257) (1.34 KB, patch)
2015-05-12 10:33 CEST, Thierry Vignaud
Details | Diff

Description Rémi Verschelde 2015-02-10 17:21:12 CET
Test platform: VirtualBox, 64bit VM with a 8 GB disk (default settings)
ISO: Mageia 5 beta 3 LiveDVD KDE4 x86_64 (round 3)

I'm testing the live installer but started from the boot menu, not from the live mode.
The disk has two partitions from a previous Mageia 5 test install:
- sda1 (6.6 GB, /, ext4)
- sda2 (1.3 GB, swap)

When choosing either of those two partitioning options:
- "Use existing partitions" (then I choose to format sda1)
- "Erase and use entire disk"

I get the following error:
"An error occurred
Not enough space available (5.6GB available while 6.3GB are needed)"

The error message could indicate that the installer tries to create both a root partition and a new swap partition in place of sda1 (6.6 GB old root - 1.3 GB swap = 5.6 GB new root, too small).

So the bug would be that diskdrake does not reuse existing swap partitions.

What is puzzling is that I get the exact same message when using "Erase and use entire disk" that should normally also remove the previous swap partition, and then work with 8 GB and not 6.6 GB.

Reproducible: 

Steps to Reproduce:
Comment 1 Rémi Verschelde 2015-02-10 17:21:30 CET
CC'ing Thierry.

CC: (none) => thierry.vignaud

Comment 2 Rémi Verschelde 2015-02-10 17:29:48 CET
Actually I also get the same error message when setting sda1 to / and sda2 to swap in the "Custom disk partitioning" menu.

To get past the partitioning step, I had to create a / data of 7.7 GB and a swap partition of 200 MB. With smaller / partitions, it would complain that there is less than 6.3 GB available.

It seems that there is a 1.3 GB offset when checking the size of the / partition.
Comment 3 Rémi Verschelde 2015-02-12 10:09:42 CET
Similar error with Mageia 5 beta 3 LiveDVD KDE4 i586 (round 4), the minimal size is just somewhat different (probably because i586 needs less space):

"An error occurred
Not enough space available (5.6GB available while 6GB are needed)"

Priority: Normal => High
Hardware: x86_64 => All

Comment 4 Rémi Verschelde 2015-02-12 10:11:49 CET
Raising as release_blocker, currently LiveDVD install on a 8 GB virtual disk is really tricky because of this.

Priority: High => release_blocker

Rémi Verschelde 2015-02-12 10:12:43 CET

Blocks: (none) => 14069

Comment 5 Thierry Vignaud 2015-02-12 10:46:59 CET
This message comes from draklive-install

Could be a side effect of overlayfs (we'd issues with df on unionfs in the past).
Could be b/c of the 5% reserved blocks.

Can you report the output of df -h for both the / of live and the fs you want to install on it?

Keywords: (none) => NEEDINFO
CC: (none) => pterjan, tmb
Source RPM: (none) => draklive-install

Comment 6 Rémi Verschelde 2015-02-12 11:29:20 CET
Live root:
# df -h /
Filesystem      Size  Used Avail Use% Mounted on
overlay         498M   26M  472M   6% /

Target filesystem:
# df -h /dev/sda1
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       7.6G  3.9G  3.4G  54% /mnt/sda1

# fdisk -l /dev/sda
Disk /dev/sda: 8 GiB, 8589934592 bytes, 16777216 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Device     Boot    Start      End  Sectors   Size Id Type
/dev/sda1  *        2048 16338104 16336057   7.8G 83 Linux
/dev/sda2       16340940 16771859   430920 210.4M  5 Extended
/dev/sda5       16340992 16771859   430868 210.4M 82 Linux swap / Solaris


But actually this is the fs I used during my previous install where I worked around the issue as described in comment 2, so this /dev/sda1 partition is OK for draklive-install and I can install on top of it.

But if I use "Erase and use entire disk", then:
"ALL existing partitions and their data will be lost on drive sda (8GB, ATA VBOX, HARDDISK)" => OK
"An error occurred
Not enough space available (5.6GB available while 5.7GB are needed)"


(5.7 GB seems to be what the GNOME x86_64 LiveDVD needs).
Comment 7 Thomas Backlund 2015-02-12 11:37:59 CET
Yeah, we need to make the installer read the size of /run/mgalive/ovlsize,
to get the real size of the overlayfs image
Comment 8 Thomas Backlund 2015-02-12 11:38:37 CET
I use the same target to get the progress bar to work
Comment 9 Rémi Verschelde 2015-02-12 11:43:05 CET
Here I got diskdrake in installer to format my partitions with the "auto-allocate" option, so here's an updated df and fdisk output:

# df -h /dev/sda1
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       6.5G   16M  6.1G   1% /mnt/sda1

# fdisk -l /dev/sda

Device     Boot    Start      End  Sectors  Size Id Type
/dev/sda1  *        2048 14008679 14006632  6.7G 83 Linux
/dev/sda2       14012397 16771859  2759463  1.3G  5 Extended
/dev/sda5       14012416 16771859  2759444  1.3G 82 Linux swap / Solaris


When trying to install with "Reuse existing partitions", I get the same error message: 5.6GB available against 5.7GB needed. It's as if the 5% reserved blocks were applied twice.
Comment 10 Rémi Verschelde 2015-02-12 12:56:36 CET
As you already stated, I confirm that the issue is specific to draklive-install, it does not happen when the classical installer.
Comment 11 Thierry Vignaud 2015-02-12 13:00:52 CET
(In reply to Thomas Backlund from comment #7)
> Yeah, we need to make the installer read the size of /run/mgalive/ovlsize,
> to get the real size of the overlayfs image

It would be better if df behaviour on union fses would be correct :-)

Component: Installer => RPM Packages
Assignee: bugsquad => tmb

Comment 12 Thierry Vignaud 2015-02-12 13:10:00 CET
Actually get_total_size() is used in that check too so it should be good.

(In reply to Rémi Verschelde from comment #9)
> When trying to install with "Reuse existing partitions", I get the same
> error message: 5.6GB available against 5.7GB needed. It's as if the 5%
> reserved blocks were applied twice.

What is the output of the following command?
LC_ALL=C tune2fs -l /dev/sda1|grep -i reserved
Comment 13 Rémi Verschelde 2015-02-12 13:23:07 CET
# LC_ALL=C tune2fs -l /dev/sda1|grep -i reserved
Reserved block count:     96879
Reserved GDT blocks:      473
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
Comment 14 Thierry Vignaud 2015-02-12 13:57:49 CET
That amounts only to 378Mb, which roughly 5%
Comment 15 Thomas Backlund 2015-03-15 12:59:24 CET
Hm, I forgot... we've been using /run/mgalive/ovlsize since mga4.

http://gitweb.mageia.org/software/draklive-install/commit/?id=da0127bead15d00731c964efebaa21a9bca31a15
Comment 16 Thierry Vignaud 2015-03-16 09:34:41 CET
That's what I said in comment #12 :-)
Comment 17 Rémi Verschelde 2015-03-19 08:53:05 CET
Is there any additional testing that I could do to provide more info?
Comment 18 Anne Nicolas 2015-04-05 23:09:23 CEST
Proposal for explanations in errata and wait for a better solution for Mageia 6

CC: (none) => ennael1

Comment 19 Rémi Verschelde 2015-04-05 23:16:30 CEST
Fine by me.
Anne Nicolas 2015-04-05 23:26:35 CEST

Blocks: 14069 => 15527

Comment 20 Zoltan Balaton 2015-04-12 16:46:30 CEST
Created attachment 6245 [details]
Log from draklive-install-2.3.-1.mga5 on 5-beta3-LiveDVD-KDE4-x86_64

Attached is a log from the journal after selecting use free space on an empty VM image (this also reproduces the bug, not only installing over existing partitions). I don't know why is it failing but here are some observations:
du -sbx /run/mgalive/ovlsize returns 6781544982 or about 6.31GiB while the created root partition is about 6.67GiB. So the reported 5.6GiB is too small (about 83% of the raw size of the partition). I'm not sure that reserved space and journal size can account for this or are these counted correctly though. But the problem may be in getting the free space and not the size of the overlay image.

CC: (none) => balaton

Rémi Verschelde 2015-04-13 16:46:09 CEST

CC: (none) => rverschelde

Comment 21 Rémi Verschelde 2015-04-23 23:55:58 CEST
I can't seem to reproduce the issue anymore with the current set of internal ISOs for Mageia 5 RC (round 9).

@ Zoltan: If you can check it too once Mageia 5 RC is officially released (should be this week-end), it would be great.
Comment 22 Rémi Verschelde 2015-04-25 21:29:47 CEST
Actually I was able to reproduce when testing Mageia 5 RC, round 9, GNOME LiveDVD 64. The issue was not trigger in most of the tests I made, but it appeared when I attempted to do a live install after having updated some package to more recent ones (namely the drakxtools).
Comment 23 Zoltan Balaton 2015-04-27 22:32:37 CEST
I could reproduce the same with the released Mageia 5 RC Live DVD (KDE4-x86_64 version) in the install option selected from the boot menu when selecting erase and use entire disk option at partitioning. It still fails with Not enough space available (5.6GB available while 6.2GB are needed). draklive-install version still seems to be the same: 2.3-1.mga5
Comment 24 Pascal Terjan 2015-04-27 23:26:16 CEST
I just tried in VirtualBox with Mageia-5-RC-LiveDVD-GNOME-x86_64-DVD.iso and could not reproduce.
Downloading Mageia-5-RC-LiveDVD-KDE4-x86_64-DVD.iso.
Comment 25 Pascal Terjan 2015-04-27 23:31:08 CEST
OK I can reproduce with Mageia-5-RC-LiveDVD-KDE4-x86_64-DVD.iso.
Comment 26 Pascal Terjan 2015-04-27 23:57:18 CEST
Reading the code of getAvailableSpace, it returns:

    my $n = $size * 512 / 1.07;
    $n - max(0.1 * $n, 65MB);

I have no idea about the 1.07, but then it removes 10% anyway (at least 65MB).
Comment 27 Pascal Terjan 2015-04-27 23:59:47 CEST
(I also have no idea about the 512 as it seems the size is in bytes)
Comment 28 Pascal Terjan 2015-04-28 00:04:46 CEST
And there is no history for those lines before commit 126777bc019a54afb4ec51299f2cf9d2841698aa (Wed Apr 25 12:26:16 2007 +0000, "re-sync after the big svn loss").
Comment 29 Pascal Terjan 2015-04-28 00:21:44 CEST
For this partition which is 6762228 1K blocks, it gets a size of 14006632 (so it seems size is actually in 512 blocks).

14006632*512/1.07 = 6702238863

6702238863*0.9 = 6032014976.7 = 5.6G

So the problem is that we first remove 6.55% by dividing by 1.07 (for the overhead of the filesystem?) then 10% (to have enough empty space).
Comment 30 Pascal Terjan 2015-04-28 00:23:22 CEST
hmm and the size it gets is actually still strange, even in 512 blocks it should have given 13524456 not 14006632.
Comment 31 Pascal Terjan 2015-04-28 23:07:06 CEST
But in short, available disk space is computed sort of correctly, the 10% of extra space is wanted for the system to be usable afterwards.

So it seems our default partitioning on a 8GB drive is just not enough for the current LiveDVDs.

Default partitioning that applies on a disk < 50G:

6/7 of the disk for / (at least 300MB, up to 50GB)
1/7 of the disk for swap (at least 256MB, up to 4GB)
Comment 32 Zoltan Balaton 2015-04-29 12:26:18 CEST
In case the computation is correct what's confusing may be the message. It says 5.6GB available for a 6.7GB partition. Maybe instead of substracting the 10% free space from available it should add it to required so the message would say 6.2GB available but 6.9GB needed which is closer to what's the case. (The 7% for the file system reserved space and overhead is still substracted from detected free space as those are file system related, but the 10% is a requirement so it is added to needed space. It may be even less confusing to also add the 7% to the needed space so the free space is matching what's seen at partitioning even if these are filesystem overheads so that's not really correct but the least confusing.) What do you think? These are just ideas, let others decide on this.
Comment 33 Samuel Verschelde 2015-04-29 12:31:26 CEST
+1 for comment #32, let's keep available space unchanged and rather increase the requirement.
claire robinson 2015-04-29 13:15:45 CEST

CC: (none) => eeeemail

Comment 34 Pascal Terjan 2015-04-29 13:59:13 CEST
I agree.
Rémi Verschelde 2015-05-03 12:30:26 CEST

Keywords: NEEDINFO => (none)

Comment 35 Rémi Verschelde 2015-05-09 22:17:42 CEST
@Thomas or Thierry:
Pascal should still be away for ~1 week, do you think you could manage a fix based on his debugging (comments 26 to 31) and Zoltan's analysis in comment 32?
Comment 36 claire robinson 2015-05-11 23:22:56 CEST
Adding Martin too

CC: (none) => mageia

Comment 37 Martin Whitaker 2015-05-12 01:57:15 CEST
Created attachment 6517 [details]
Patch #1 - apply to drakx
Comment 38 Martin Whitaker 2015-05-12 02:06:06 CEST
Created attachment 6518 [details]
Patch #2 - apply to draklive-install

This and the previous patch implement Zoltan's suggestion in comment 32 (keeping the 7% reduction on raw space).

I've tested this by booting to a live desktop, applying the first patch to /lib/libDrakX/fs/any.pm, applying the second patch to /usr/sbin/draklive-install, then running the installer from the desktop and attempting to install into a 4GB partition.

As far as I can tell (using grep), the fs::getAvailableSpace function is only used in the live installer, so this should not affect anything else, but it would be good if Thierry or Thomas could confirm this.
Thierry Vignaud 2015-05-12 10:07:47 CEST

Keywords: (none) => PATCH

Comment 39 Thierry Vignaud 2015-05-12 10:30:07 CEST
getAvailableSpace() is widely used in stage2.
So this change doesn't only impact draklive, it can have side effect on classic installer too.
So that cannot be applied.

We could another param to tell not to account for min needed space

CC: (none) => mageia

Comment 40 Thierry Vignaud 2015-05-12 10:33:17 CEST
Created attachment 6519 [details]
(getNeededMinSpace) split it out
Comment 41 Thierry Vignaud 2015-05-12 10:33:30 CEST
Created attachment 6520 [details]
enables to get raw available space (mga15257)
Comment 42 Thierry Vignaud 2015-05-12 10:33:41 CEST
Created attachment 6521 [details]
better reporting of insufficient space (mga#15257)
Comment 43 Thierry Vignaud 2015-05-12 10:33:54 CEST
All untested of course
Comment 44 Rémi Verschelde 2015-05-14 22:43:07 CEST
(In reply to Thierry Vignaud from comment #42)
> Created attachment 6521 [details]
> better reporting of insufficient space (mga#15257)

I think there is a missing semi-colon at the end of line 179.
Comment 45 Thierry Vignaud 2015-05-14 23:23:34 CEST
Indeed.
Can someone test the patch with adding the missing ";" ?

Keywords: (none) => NEEDINFO

Comment 46 Martin Whitaker 2015-05-15 00:59:57 CEST
Tested using the 64-bit GNOME Live DVD and attempting to install onto a 4.3GB partition. Before patching, it reported 3.6GB available, 5.6GB needed. After patching, it reported 4GB available, 6GB needed. I think it's reasonable to deduct the file system overhead from the raw available space, so would say this is fixed.
Comment 47 Mageia Robot 2015-05-18 04:48:30 CEST
commit 97a7904701e5fe02af2c95c5eb0ffb83a7707b6d
Author: Thierry Vignaud <thierry.vignaud@...>
Date:   Tue May 12 04:27:38 2015 -0400

    (getNeededMinSpace) split it out
    
    needed for mga#15257
---
 Commit Link:
   http://gitweb.mageia.org/software/drakx/commit/?id=97a7904701e5fe02af2c95c5eb0ffb83a7707b6d
Comment 48 Mageia Robot 2015-05-18 04:50:12 CEST
commit e3e2771c36485dc8015947d2898e49faa38d54bd
Author: Thierry Vignaud <thierry.vignaud@...>
Date:   Tue May 12 04:31:12 2015 -0400

    better reporting of insufficient space (mga#15257)
    
    When the live installer checks if there is sufficient space on the
    chosen root partition it subtracts 10% (or 65MB) from the available
    space to give some headroom. It's better to add the headroom to the
    required space, as this gives a more accurate message when there is
    insufficient space.
---
 Commit Link:
   http://gitweb.mageia.org/software/draklive-install/commit/?id=e3e2771c36485dc8015947d2898e49faa38d54bd
Comment 49 Mageia Robot 2015-05-18 04:50:16 CEST
commit 7f9e02c8f2e5030852b7a952c8e6ad95a4cea50e
Author: Thierry Vignaud <thierry.vignaud@...>
Date:   Tue May 12 04:31:12 2015 -0400

    better reporting of insufficient space (mga#15257)
    
    When the live installer checks if there is sufficient space on the
    chosen root partition it subtracts 10% (or 65MB) from the available
    space to give some headroom. It's better to add the headroom to the
    required space, as this gives a more accurate message when there is
    insufficient space.
---
 Commit Link:
   http://gitweb.mageia.org/software/draklive-install/commit/?id=7f9e02c8f2e5030852b7a952c8e6ad95a4cea50e
Comment 50 Thierry Vignaud 2015-05-18 04:51:51 CEST
Closing

Status: NEW => RESOLVED
Resolution: (none) => FIXED

Rémi Verschelde 2015-05-21 16:10:57 CEST

Blocks: 15527 => (none)

Rémi Verschelde 2015-05-21 16:11:39 CEST

Blocks: (none) => 14069


Note You need to log in before you can comment on or make changes to this bug.