Bug 1635252 - anaconda: Ignore errors activating unknown swap partitions
Summary: anaconda: Ignore errors activating unknown swap partitions
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: anaconda
Version: rawhide
Hardware: x86_64
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Anaconda Maintenance Team
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard: AcceptedFreezeException abrt_hash:f44...
Depends On: 1573016
Blocks: F29FinalFreezeException 1634016 1635253 1654309
TreeView+ depends on / blocked
 
Reported: 2018-10-02 13:10 UTC by Robert Richter (Marvell)
Modified: 2019-03-07 15:49 UTC (History)
20 users (show)

Fixed In Version: anaconda-29.24.4-1 anaconda-29.24.7-1.fc29
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 1573016
: 1635253 (view as bug list)
Environment:
Last Closed: 2018-10-22 16:13:54 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Robert Richter (Marvell) 2018-10-02 13:10:50 UTC
Note: Found in RHEL8, but filing against Fedora as this is affected too.

Anaconda fails if there is an existing swap partition that can not be enabled, e.g. if it was created for 4k page size. For RHEL8 an error signature can be found in bug 1573016. In RHEL7 this is working as the error while enabling the swap is ignored. In RHEL8 the errors should be ignored as in RHEL7, a patch like the following should fix the issue: 

commit b5c02df8b86616f1c5e7aa51aa30a0e7ed39ecd7
Author: Brian C. Lane <bcl>
Date:   Thu May 12 09:09:38 2016 -0700

    Ignore errors activating unknown swap partitions (#1330763)


The should be applied also to the master branch.


Details (see also bug 1573016):

I did some research in why bug 1573016 did not occur in RHEL7 but in RHEL8:

Code in RHEL8:

https://github.com/rhinstaller/anaconda.git
b76e72bbdaf0 New version - 29.19.0.14
pyanaconda/storage/osinstall.py:turn_on_swap()
https://github.com/rhinstaller/anaconda/blob/b76e72bbdaf0a5b9b1d51195c01ae24920b36ec2/pyanaconda/storage/osinstall.py#L664

Code in RHEL7:

https://github.com/storaged-project/blivet.git
ba6b6ccb784d New version: 0.61.15.72
blivet/__init__.py:turnOnSwap()
https://github.com/storaged-project/blivet/blob/ba6b6ccb784df605a64f1fe8b5c9646be330ce89/blivet/__init__.py#L2640

The difference is in the exception handler. In RHEL7 the device is *skipped* on errors when enabling the swap:

 https://github.com/storaged-project/blivet/blob/ba6b6ccb784df605a64f1fe8b5c9646be330ce89/blivet/__init__.py#L2663

This is missing in RHEL8, instead an exception is thrown.

I think we need to restore the RHEL7 exception handling to be less strict when enabling swap devices. This needs to be changed in the anaconda package. It should be something like:

commit b5c02df8b86616f1c5e7aa51aa30a0e7ed39ecd7
Author: Brian C. Lane <bcl>
Date:   Thu May 12 09:09:38 2016 -0700

    Ignore errors activating unknown swap partitions (#1330763)

https://github.com/storaged-project/blivet/commit/b5c02df8b86616f1c5e7aa51aa30a0e7ed39ecd7

This fix never made it into the master branch.




+++ This bug was initially created as a clone of Bug #1573016 +++

Version-Release number of selected component:
anaconda-core-27.20.4-4.fc27.x86_64

The following was filed automatically by anaconda:
anaconda 27.20.4-1 exception report
Traceback (most recent call first):
  File "/usr/lib64/python3.6/site-packages/gi/overrides/BlockDev.py", line 824, in wrapped
    raise transform[1](msg)
  File "/usr/lib/python3.6/site-packages/blivet/formats/swap.py", line 165, in _setup
    blockdev.swap.swapon(self.device, priority=self.priority)
  File "/usr/lib/python3.6/site-packages/blivet/threads.py", line 45, in run_with_lock
    return m(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/blivet/formats/__init__.py", line 604, in setup
    self._setup(**kwargs)
  File "/usr/lib/python3.6/site-packages/blivet/threads.py", line 45, in run_with_lock
    return m(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/blivet/osinstall.py", line 574, in turn_on_swap
    device.format.setup()
  File "/usr/lib/python3.6/site-packages/blivet/blivet.py", line 1479, in turn_on_swap
    self.fsset.turn_on_swap(root_path=get_sysroot())
  File "/usr/lib/python3.6/site-packages/blivet/threads.py", line 45, in run_with_lock
    return m(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/blivet/osinstall.py", line 1119, in turn_on_filesystems
    storage.turn_on_swap()
  File "/usr/lib64/python3.6/site-packages/pyanaconda/installation_tasks.py", line 438, in run_task
    self._task(*self._task_args, **self._task_kwargs)
  File "/usr/lib64/python3.6/site-packages/pyanaconda/installation_tasks.py", line 472, in start
    self.run_task()
  File "/usr/lib64/python3.6/site-packages/pyanaconda/installation_tasks.py", line 304, in start
    item.start()
  File "/usr/lib64/python3.6/site-packages/pyanaconda/installation_tasks.py", line 304, in start
    item.start()
  File "/usr/lib64/python3.6/site-packages/pyanaconda/installation.py", line 366, in doInstall
    installation_queue.start()
  File "/usr/lib64/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib64/python3.6/site-packages/pyanaconda/threading.py", line 252, in run
    threading.Thread.run(self)
gi.overrides.BlockDev.SwapError: Unknown swap space format, cannot activate.

Additional info:
addons:         com_redhat_kdump
blivet-gui-utils.log: 
cmdline:        /usr/libexec/system-python  /sbin/anaconda --liveinst --method=livecd:///dev/mapper/live-base
cmdline_file:   BOOT_IMAGE=vmlinuz initrd=initrd.img root=live:CDLABEL=Fedora-WS-Live-27-1-6 rd.live.image quiet
executable:     /sbin/anaconda
hashmarkername: anaconda
kernel:         4.13.9-300.fc27.x86_64
other involved packages: python3-blockdev-2.12-1.fc27.x86_64, python3-blivet-2.1.11-3.fc27.noarch, python3-libs-3.6.2-13.fc27.x86_64
product:        Fedora
release:        Fedora release 27 (Twenty Seven)
type:           anaconda
version:        27

--- Additional comment from Koumb on 2018-04-29 15:52:18 EDT ---



--- Additional comment from Koumb on 2018-04-29 15:52:22 EDT ---



--- Additional comment from Koumb on 2018-04-29 15:52:24 EDT ---



--- Additional comment from Koumb on 2018-04-29 15:52:40 EDT ---



--- Additional comment from Koumb on 2018-04-29 15:52:42 EDT ---



--- Additional comment from Koumb on 2018-04-29 15:52:45 EDT ---



--- Additional comment from Koumb on 2018-04-29 15:52:47 EDT ---



--- Additional comment from Koumb on 2018-04-29 15:52:49 EDT ---



--- Additional comment from Koumb on 2018-04-29 15:53:01 EDT ---



--- Additional comment from Koumb on 2018-04-29 15:53:16 EDT ---



--- Additional comment from Koumb on 2018-04-29 15:53:18 EDT ---



--- Additional comment from Jiri Konecny on 2018-05-02 04:45:53 EDT ---

Based on the traceback this looks like an issue in our storage library. Changing component.

--- Additional comment from Vratislav Podzimek on 2018-09-28 09:34:55 EDT ---

Is this issue reproducible? It's really weird because it is failing to activate swap that was created with mkswap right before.

--- Additional comment from Robert Richter on 2018-09-28 10:33:33 EDT ---

(In reply to Vratislav Podzimek from comment #13)
> Is this issue reproducible? It's really weird because it is failing to
> activate swap that was created with mkswap right before.

I think in my case there is another existing swap partition that fails being activated, RHEL-7.6 is working fine in the same setup.

--- Additional comment from Vratislav Podzimek on 2018-09-28 10:45:26 EDT ---

(In reply to Robert Richter from comment #14)
> (In reply to Vratislav Podzimek from comment #13)
> > Is this issue reproducible? It's really weird because it is failing to
> > activate swap that was created with mkswap right before.
> 
> I think in my case there is another existing swap partition that fails being
> activated, RHEL-7.6 is working fine in the same setup.

Could you please attach the first 2048 bytes of that partition? Does 'blkid /dev/YOUR_PARTITION' recognize it as swap?

--- Additional comment from Robert Richter on 2018-10-01 05:04:17 EDT ---

[anaconda root@localhost ~]# parted /dev/sda print free
Model: ATA INTEL SSDSC2BB24 (scsi)
Disk /dev/sda: 240GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system     Name                  Flags
        17.4kB  1049kB  1031kB  Free Space
 1      1049kB  1075MB  1074MB  fat32           EFI System Partition  boot, esp
 2      1075MB  22.5GB  21.5GB  ext4            primary
 8      22.5GB  44.0GB  21.5GB  ext4
 9      44.0GB  45.1GB  1074MB  xfs                                   msftdata
10      45.1GB  47.2GB  2149MB  linux-swap(v1)                        swap
11      47.2GB  65.5GB  18.3GB  xfs                                   msftdata
12      65.5GB  87.0GB  21.5GB  ext4
13      87.0GB  88.0GB  1074MB  xfs
14      88.0GB  90.2GB  2149MB  linux-swap(v1)                        swap
15      90.2GB  108GB   18.3GB  xfs
 3      108GB   216GB   107GB                   primary               msftdata
 4      216GB   217GB   1074MB  ext4
 5      217GB   219GB   2382MB                                        swap
 6      219GB   235GB   16.1GB  xfs
 7      235GB   240GB   4672MB                  primare

[anaconda root@localhost ~]# blkid /dev/sda5
/dev/sda5: UUID="ba1ed1a7-b3e7-4ac3-9672-4e96a66bc247" TYPE="swap" PARTUUID="1b1a333b-8153-4478-a57b-953edf4c3cb8"

[anaconda root@localhost ~]# blkid /dev/sda10
/dev/sda10: UUID="86a58d82-f07f-4779-8036-db9feac0a030" TYPE="swap" PARTUUID="c6f3e6ed-b55d-4e2a-8f11-d067a0be00b9"

[anaconda root@localhost ~]# blkid /dev/sda14
/dev/sda14: UUID="0b72db53-713d-485c-9a42-49bf1fdcc6b8" TYPE="swap" PARTUUID="cbde0046-76e5-4c0f-a23b-e2e686c851d3"

--- Additional comment from Robert Richter on 2018-10-01 05:12:19 EDT ---

From storage.log:

12:29:05,731 DBG blivet:                PartitionDevice.setup: sda10 ; orig: False ; status: True ; controllable: True ;
12:29:05,734 DBG blivet:                SwapSpace.setup: device: /dev/sda10 ; type: swap ; status: False ;
12:29:05,737 DBG blivet:                  SwapSpace._setup: device: /dev/sda10 ; type: swap ; status: False ;
12:29:05,749 DBG blivet:                PartitionDevice.setup: sda14 ; orig: False ; status: True ; controllable: True ;
12:29:05,751 DBG blivet:                SwapSpace.setup: device: /dev/sda14 ; type: swap ; status: False ;
12:29:05,754 DBG blivet:                  SwapSpace._setup: device: /dev/sda14 ; type: swap ; status: False ;
12:29:05,756 DBG blivet:                PartitionDevice.setup: sda5 ; orig: False ; status: True ; controllable: True ;
12:29:05,759 DBG blivet:                SwapSpace.setup: device: /dev/sda5 ; type: swap ; status: False ;
12:29:05,762 DBG blivet:                  SwapSpace._setup: device: /dev/sda5 ; type: swap ; status: False ;

From anaconda.log:

12:28:54,591 INF installation: Task started: Activate filesystems (5/18)
12:29:01,820 INF progress: Creating swap on /dev/sda14
12:29:02,850 INF progress: Creating xfs on /dev/sda15
12:29:04,889 INF progress: Creating xfs on /dev/sda13
12:29:05,527 INF storage: setting boot flag on sda1
12:29:05,531 INF storage: Setting label on existing 1024 MiB partition sda1 (602) with existing efi filesystem mounted at /boot/efi to 'EFI System Partition'
12:29:05,762 INF threading: Thread Failed: AnaInstallThread (281472810545632)
12:29:05,763 DBG exception: running handleException
12:29:05,764 CRT exception: Traceback (most recent call last):

  File "/usr/lib64/python3.6/site-packages/gi/overrides/BlockDev.py", line 967, in wrapped
    ret = orig_obj(*args, **kwargs)

  File "/usr/lib64/python3.6/site-packages/gi/overrides/BlockDev.py", line 712, in swap_swapon
    return _swap_swapon(device, priority)

GLib.GError: g-bd-swap-error-quark: Unknown swap space format, cannot activate. (1)


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "/usr/lib64/python3.6/site-packages/pyanaconda/threading.py", line 286, in run
    threading.Thread.run(self)

  File "/usr/lib64/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)

  File "/usr/lib64/python3.6/site-packages/pyanaconda/installation.py", line 375, in doInstall
    installation_queue.start()

  File "/usr/lib64/python3.6/site-packages/pyanaconda/installation_tasks.py", line 304, in start
    item.start()

  File "/usr/lib64/python3.6/site-packages/pyanaconda/installation_tasks.py", line 304, in start
    item.start()

  File "/usr/lib64/python3.6/site-packages/pyanaconda/installation_tasks.py", line 472, in start
    self.run_task()

  File "/usr/lib64/python3.6/site-packages/pyanaconda/installation_tasks.py", line 438, in run_task
    self._task(*self._task_args, **self._task_kwargs)

  File "/usr/lib64/python3.6/site-packages/pyanaconda/storage/osinstall.py", line 2190, in turn_on_filesystems
    storage.turn_on_swap()

  File "/usr/lib/python3.6/site-packages/blivet/threads.py", line 53, in run_with_lock
    return m(*args, **kwargs)

  File "/usr/lib64/python3.6/site-packages/pyanaconda/storage/osinstall.py", line 2035, in turn_on_swap
    self.fsset.turn_on_swap(root_path=util.getSysroot())

  File "/usr/lib64/python3.6/site-packages/pyanaconda/storage/osinstall.py", line 683, in turn_on_swap
    device.format.setup()

  File "/usr/lib/python3.6/site-packages/blivet/threads.py", line 53, in run_with_lock
    return m(*args, **kwargs)

  File "/usr/lib/python3.6/site-packages/blivet/formats/__init__.py", line 606, in setup
    self._setup(**kwargs)

  File "/usr/lib/python3.6/site-packages/blivet/threads.py", line 53, in run_with_lock
    return m(*args, **kwargs)

  File "/usr/lib/python3.6/site-packages/blivet/formats/swap.py", line 165, in _setup
    blockdev.swap.swapon(self.device, priority=self.priority)

  File "/usr/lib64/python3.6/site-packages/gi/overrides/BlockDev.py", line 993, in wrapped
    raise transform[1](msg)

gi.overrides.BlockDev.SwapError: Unknown swap space format, cannot activate.

12:29:06,343 DBG exception: Gtk cannot be initialized
12:29:06,344 DBG exception: In a non-main thread, sending a message with exception data
12:29:06,344 DBG simpleline: New signal ExceptionSignal enqueued with source ScreenScheduler
12:29:06,345 INF threading: Thread Done: AnaInstallThread (281472810545632)
12:29:06,890 DBG simpleline: Executing inner loop
12:29:06,891 DBG simpleline: New signal ExceptionSignal enqueued with source ScreenScheduler
12:29:06,891 ERR ui.tui: 
======= Screen stack =======
----------- TOP ------------
ScreenData(ProgressSpoke,None,False)
============================

12:29:06,892 DBG exception: running handleException
12:29:06,893 CRT exception: Traceback (most recent call last):

  File "/usr/lib64/python3.6/site-packages/gi/overrides/BlockDev.py", line 967, in wrapped
    ret = orig_obj(*args, **kwargs)

  File "/usr/lib64/python3.6/site-packages/gi/overrides/BlockDev.py", line 712, in swap_swapon
    return _swap_swapon(device, priority)

GLib.GError: g-bd-swap-error-quark: Unknown swap space format, cannot activate. (1)


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "/usr/lib64/python3.6/site-packages/pyanaconda/threading.py", line 286, in run
    threading.Thread.run(self)

  File "/usr/lib64/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)

  File "/usr/lib64/python3.6/site-packages/pyanaconda/installation.py", line 375, in doInstall
    installation_queue.start()

  File "/usr/lib64/python3.6/site-packages/pyanaconda/installation_tasks.py", line 304, in start
    item.start()

  File "/usr/lib64/python3.6/site-packages/pyanaconda/installation_tasks.py", line 304, in start
    item.start()

  File "/usr/lib64/python3.6/site-packages/pyanaconda/installation_tasks.py", line 472, in start
    self.run_task()

  File "/usr/lib64/python3.6/site-packages/pyanaconda/installation_tasks.py", line 438, in run_task
    self._task(*self._task_args, **self._task_kwargs)

  File "/usr/lib64/python3.6/site-packages/pyanaconda/storage/osinstall.py", line 2190, in turn_on_filesystems
    storage.turn_on_swap()

  File "/usr/lib/python3.6/site-packages/blivet/threads.py", line 53, in run_with_lock
    return m(*args, **kwargs)

  File "/usr/lib64/python3.6/site-packages/pyanaconda/storage/osinstall.py", line 2035, in turn_on_swap
    self.fsset.turn_on_swap(root_path=util.getSysroot())

  File "/usr/lib64/python3.6/site-packages/pyanaconda/storage/osinstall.py", line 683, in turn_on_swap
    device.format.setup()

  File "/usr/lib/python3.6/site-packages/blivet/threads.py", line 53, in run_with_lock
    return m(*args, **kwargs)

  File "/usr/lib/python3.6/site-packages/blivet/formats/__init__.py", line 606, in setup
    self._setup(**kwargs)

  File "/usr/lib/python3.6/site-packages/blivet/threads.py", line 53, in run_with_lock
    return m(*args, **kwargs)

  File "/usr/lib/python3.6/site-packages/blivet/formats/swap.py", line 165, in _setup
    blockdev.swap.swapon(self.device, priority=self.priority)

  File "/usr/lib64/python3.6/site-packages/gi/overrides/BlockDev.py", line 993, in wrapped
    raise transform[1](msg)

gi.overrides.BlockDev.SwapError: Unknown swap space format, cannot activate.

12:29:06,894 DBG exception: Gtk cannot be initialized
12:29:06,894 DBG exception: In the main thread, running exception handler
12:29:20,254 INF core.util: Running kickstart %%onerror script(s)
12:29:20,256 INF core.util: All kickstart %%onerror script(s) have been run
12:29:20,256 INF kickstart.script: Running kickstart %%traceback script(s)
12:29:20,257 INF kickstart.script: All kickstart %%traceback script(s) have been run

--- Additional comment from Robert Richter on 2018-10-01 05:15:26 EDT ---

Package versions:

python3-blockdev-2.19-3.el8.aarch64
python3-blivet-3.1.0-3.el8.noarch

--- Additional comment from Vratislav Podzimek on 2018-10-01 05:24 EDT ---

Thanks for the data Robert! Could you please try to deactivate the problematic swap device (the one that failed to activate for you) and then activate it with the script I just attached like:

  sudo python3 bd_swapon.py /dev/YOUR_DEVICE

Please note that you need to have the 'python3-blockdev' and 'libblockdev-swap' packages installed.

Thanks!

--- Additional comment from Robert Richter on 2018-10-01 05:38:03 EDT ---

+ dd bs=2048 count=1 if=/dev/sda5
+ hexdump
0000000 0000 0000 0000 0000 0000 0000 0000 0000
*
0000400 0001 0000 dfff 0008 0000 0000 1eba a7d1
0000410 e7b3 c34a 7296 964e 6ba6 47c2 0000 0000
0000420 0000 0000 0000 0000 0000 0000 0000 0000
*
0000800
+ dd bs=2048 count=1 if=/dev/sda10
+ hexdump
0000000 0000 0000 0000 0000 0000 0000 0000 0000
*
0000400 0001 0000 800f 0000 0000 0000 a586 828d
0000410 7ff0 7947 3680 9fdb c0ea 30a0 0000 0000
0000420 0000 0000 0000 0000 0000 0000 0000 0000
*
0000800
+ dd bs=2048 count=1 if=/dev/sda14
+ hexdump
0000000 0000 0000 0000 0000 0000 0000 0000 0000
*
0000400 0001 0000 800f 0000 0000 0000 720b 53db
0000410 3d71 5c48 429a bf49 dc1f b8c6 0000 0000
0000420 0000 0000 0000 0000 0000 0000 0000 0000
*
0000800

--- Additional comment from Vratislav Podzimek on 2018-10-01 05:41:22 EDT ---

Oh, sorry, Robert, we actually need to see the first `getconf PAGESIZE` (probably 4096) bytes on those devices.

--- Additional comment from Vratislav Podzimek on 2018-10-01 05:42:24 EDT ---

(In reply to Vratislav Podzimek from comment #21)
> Oh, sorry, Robert, we actually need to see the first `getconf PAGESIZE`
> (probably 4096) bytes on those devices.

And if you use 'od -c' instead of 'hexdump', you should see:

0007760  \0  \0  \0  \0  \0  \0   S   W   A   P   S   P   A   C   E   2

--- Additional comment from Robert Richter on 2018-10-01 06:55:32 EDT ---

Right, swap on /dev/sda5 is failing:

[anaconda root@localhost ~]# cat /proc/swaps
Filename                                Type            Size    Used    Priority
[anaconda root@localhost ~]# python3 bd_swapon.py /dev/sda5
Traceback (most recent call last):
  File "/usr/lib64/python3.6/site-packages/gi/overrides/BlockDev.py", line 967, in wrapped

    ret = orig_obj(*args, **kwargs)
  File "/usr/lib64/python3.6/site-packages/gi/overrides/BlockDev.py", line 712, in swap_swapon

    return _swap_swapon(device, priority)
GLib.Error: g-bd-swap-error-quark: Unknown swap space format, cannot activate. (1)


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "bd_swapon.py", line 14, in <module>
    BlockDev.swap.swapon(device)
  File "/usr/lib64/python3.6/site-packages/gi/overrides/BlockDev.py", line 993, in wrapped

    raise transform[1](msg)  
gi.overrides.BlockDev.SwapError: Unknown swap space format, cannot activate.
[anaconda root@localhost ~]# python3 bd_swapon.py /dev/sda10
Swap on /dev/sda10 activated successfully
[anaconda root@localhost ~]# python3 bd_swapon.py /dev/sda14
Swap on /dev/sda14 activated successfully
[anaconda root@localhost ~]# cat /proc/swaps
Filename                                Type            Size    Used    Priority
/dev/sda10                              partition       2098112 0       -2
/dev/sda14                              partition       2098112 0       -3

--- Additional comment from Robert Richter on 2018-10-01 06:56:25 EDT ---

Here is the problem, the failing cache was initialized with a different page size:

[anaconda root@localhost ~]# swapon /dev/sda5 
swapon: /dev/sda5: swap format pagesize does not match. (Use --fixpgsz to reinitialize it.)

swapon: /dev/sda5: swapon failed: Invalid argument
[anaconda root@localhost ~]# swapon --fixpgsz /dev/sda5 
swapon: /dev/sda5: swap format pagesize does not match.
swapon: /dev/sda5: reinitializing the swap.
mkswap: /dev/sda5: warning: wiping old swap signature.
Setting up swapspace version 1, size = 2.2 GiB (2382299136 bytes)
no label, UUID=ba1ed1a7-b3e7-4ac3-9672-4e96a66bc247
[anaconda root@localhost ~]# cat /proc/swaps 
Filename                                Type            Size    Used    Priority
/dev/sda10                              partition       2098112 0       -2
/dev/sda14                              partition       2098112 0       -3
/dev/sda5                               partition       2326464 0       -4
[anaconda root@localhost ~]# swapoff /dev/sda5
[anaconda root@localhost ~]# python3 bd_swapon.py /dev/sda5
Swap on /dev/sda5 activated successfully

--- Additional comment from Vratislav Podzimek on 2018-10-01 07:07:46 EDT ---

Great work, Robert! Thanks a lot for this debugging!

--- Additional comment from Vratislav Podzimek on 2018-10-01 07:10:01 EDT ---

What I still don't understand, though, is how could the 'mkswap' command shortly before the 'swapon' attempt create a format with non-matching pagesize.

--- Additional comment from Robert Richter on 2018-10-01 07:19:18 EDT ---

(In reply to Vratislav Podzimek from comment #26)
> What I still don't understand, though, is how could the 'mkswap' command
> shortly before the 'swapon' attempt create a format with non-matching
> pagesize.

The other swap was used/created by another installation with a 4k page size kernel. It was already existing when starting the installation (I chose to install in free space).

--- Additional comment from Robert Richter on 2018-10-01 07:39:59 EDT ---

(In reply to Robert Richter from comment #24)
> [anaconda root@localhost ~]# swapon --fixpgsz /dev/sda5 
> swapon: /dev/sda5: swap format pagesize does not match.
> swapon: /dev/sda5: reinitializing the swap.
> mkswap: /dev/sda5: warning: wiping old swap signature.
> Setting up swapspace version 1, size = 2.2 GiB (2382299136 bytes)
> no label, UUID=ba1ed1a7-b3e7-4ac3-9672-4e96a66bc247

Fixing the swap's page size made anaconda work.

--- Additional comment from Robert Richter on 2018-10-01 07:46:23 EDT ---

Btw, I also noticed anaconda failing, if a swap is already enabled:

---
  File "/usr/lib64/python3.6/site-packages/pyanaconda/installation_tasks.py", line 304, in start
    item.start()
  File "/usr/lib64/python3.6/site-packages/pyanaconda/installation.py", line 375, in doInstall
    installation_queue.start()
  File "/usr/lib64/python3.6/threading.py", line 864, in run                   
    self._target(*self._args, **self._kwargs)                                  
  File "/usr/lib64/python3.6/site-packages/pyanaconda/threading.py", line 286, in run
    threading.Thread.run(self)
gi.overrides.BlockDev.SwapError: Failed to activate swap on /dev/sda10: Device or resource busy

What do you want to do now?
1) Report Bug
2) Debug
3) Run shell
4) Quit

Please make your choice from above:
----

I noticed that when continuing the installation after I enabled the swap in the shell already.

--- Additional comment from Vratislav Podzimek on 2018-10-02 04:52:12 EDT ---

(In reply to Robert Richter from comment #29)
> Btw, I also noticed anaconda failing, if a swap is already enabled:
> ...
> I noticed that when continuing the installation after I enabled the swap in
> the shell already.

This is expected or I should say "not supported". Whenever you modify the storage state you need to trigger a rescan in anaconda. Otherwise it assumes the storage is still in the same state as it was in when anaconda probed it.

--- Additional comment from Vratislav Podzimek on 2018-10-02 04:56:34 EDT ---

vtrefny submitted a PR that should at least result in nicer/more precise error messages in the future:
https://github.com/storaged-project/libblockdev/pull/404

Other than that I don't think anything else should be done here. This falls down into the "anaconda/blivet tears down and fails to setup devices it doesn't fully understand" category. In this particular case, the old swap device (not formatted in the installation process) should have not been touched by anaconda/blivet at all.

Assigning this to vtrefny, I think this should be closed once the above PR is merged and the changes from it propagated to Fedora.

--- Additional comment from Robert Richter on 2018-10-02 06:13:42 EDT ---

(In reply to Vratislav Podzimek from comment #31)
> Other than that I don't think anything else should be done here. This falls
> down into the "anaconda/blivet tears down and fails to setup devices it
> doesn't fully understand" category. In this particular case, the old swap
> device (not formatted in the installation process) should have not been
> touched by anaconda/blivet at all.

Vratislav, I did some research in why it did not fail in RHEL7:

Code in RHEL8:

https://github.com/rhinstaller/anaconda.git
b76e72bbdaf0 New version - 29.19.0.14
pyanaconda/storage/osinstall.py:turn_on_swap()
https://github.com/rhinstaller/anaconda/blob/b76e72bbdaf0a5b9b1d51195c01ae24920b36ec2/pyanaconda/storage/osinstall.py#L664

Code in RHEL7:

https://github.com/storaged-project/blivet.git
ba6b6ccb784d New version: 0.61.15.72
blivet/__init__.py:turnOnSwap()
https://github.com/storaged-project/blivet/blob/ba6b6ccb784df605a64f1fe8b5c9646be330ce89/blivet/__init__.py#L2640

The difference is in the exception handler. In RHEL7 the device is *skipped* on errors when enabling the swap:

 https://github.com/storaged-project/blivet/blob/ba6b6ccb784df605a64f1fe8b5c9646be330ce89/blivet/__init__.py#L2663

This is missing in RHEL8, instead an exception is thrown.

I think we need to restore the RHEL7 exception handling to be less strict when enabling swap devices. This needs to be changed in the anaconda package. It should be something like:

commit b5c02df8b86616f1c5e7aa51aa30a0e7ed39ecd7
Author: Brian C. Lane <bcl>
Date:   Thu May 12 09:09:38 2016 -0700

    Ignore errors activating unknown swap partitions (#1330763)

https://github.com/storaged-project/blivet/commit/b5c02df8b86616f1c5e7aa51aa30a0e7ed39ecd7

This fix never made it into the master branch.

--- Additional comment from Vratislav Podzimek on 2018-10-02 08:48:08 EDT ---

Another piece of outstanding work, Robert! Could you please create a separate bug report for anaconda for the above issue? It must have been some error in backporting (policies) that caused that commit to never make it to master. Thanks!

Comment 1 Vojtech Trefny 2018-10-04 09:04:17 UTC
Upstream PR: https://github.com/rhinstaller/anaconda/pull/1636

Comment 2 Fedora Blocker Bugs Application 2018-10-08 12:06:28 UTC
Proposed as a Freeze Exception for 29-final by Fedora user vtrefny using the blocker tracking app because:

 Anaconda will crash if system contains an "unsupported" swap partition that cannot be activated. For example old swap, swap with different pagesize or with hibernated system (from another distribution running in dualboot).
Fix for this is quite simple, we just ignore errors when trying to activate these swap partitions instead of raising them. Fixes for both Anaconda and libblockdev (low level storage library used by Anaconda) are already available upstream.

Comment 3 František Zatloukal 2018-10-08 18:05:24 UTC
Discussed during the 2018-10-08 blocker review meeting: [1]

The decision to classify this bug as an AcceptedFreezeException was made:

"This clearly can cause inconvenience during install in some cases and cannot be fixed with an update"

[1] https://meetbot-raw.fedoraproject.org/fedora-blocker-review/2018-10-08/f29-blocker-review.2018-10-08-16.00.log.txt

Comment 4 Adam Williamson 2018-10-10 20:21:31 UTC
Martin, can you please submit an update for this and blivet soonish? We're in freeze now and I'd like to line up blocker/FE fixes as soon as possible. Thanks.

Comment 5 Fedora Update System 2018-10-18 14:05:16 UTC
anaconda-29.24.6-1.fc29 dnf-4.0.4-1.fc29 dnf-plugins-core-4.0.0-2.fc29 libblockdev-2.20-2.fc29 libdnf-0.22.0-2.fc29 has been submitted as an update to Fedora 29. https://bodhi.fedoraproject.org/updates/FEDORA-2018-2789f6b6e7

Comment 6 Fedora Update System 2018-10-18 14:07:22 UTC
anaconda-29.24.6-1.fc29 dnf-4.0.4-1.fc29 dnf-plugins-core-4.0.0-2.fc29 libblockdev-2.20-2.fc29 libdnf-0.22.0-2.fc29 has been submitted as an update to Fedora 29. https://bodhi.fedoraproject.org/updates/FEDORA-2018-2789f6b6e7

Comment 7 Fedora Update System 2018-10-20 19:22:52 UTC
anaconda-29.24.7-1.fc29, dnf-4.0.4-1.fc29, dnf-plugins-core-4.0.0-2.fc29, libblockdev-2.20-2.fc29, libdnf-0.22.0-5.fc29 has been pushed to the Fedora 29 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-2789f6b6e7

Comment 8 Fedora Update System 2018-10-22 16:13:54 UTC
anaconda-29.24.7-1.fc29, dnf-4.0.4-1.fc29, dnf-plugins-core-4.0.0-2.fc29, libblockdev-2.20-2.fc29, libdnf-0.22.0-5.fc29 has been pushed to the Fedora 29 stable repository. If problems still persist, please make note of it in this bug report.


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