Tails Cloner fails installing to/upgrading devices with other mounted partitions
Discovered while testing !1359 (merged).
(BTW, it is a mostly poor design choice for Tails' use cases that the Cloner sometimes lists partitions as targets, like /dev/sda1
and /dev/sda2
. In particular when installing it should only list devices, like /dev/sda
, because we are not installing to the partition. No matter if I select /dev/sda1
or /dev/sda2
the same thing happens: it installs to /dev/sda
, destroying all partitions along the way. Maybe it isn't nonsense to list upgradeable partitions, but we don't gain anything compared to just listing the device. This is clearly an artifact from liveusb-creator
that actually supported partition targets.)
So Tails Cloner is very bad at installing to/upgrading devices with mounted partitions, which results in failures in many scenarios, all tested in Tails 5.21:
Upgrade a Tails installations when its persistent partition is mounted
Installation fails with the console saying:
[... upgrade succeeded so far ...]
Installing bootloader...
Synchronizing data on disk...
Unmounting mounted filesystems on "/dev/sda1"
Synchronizing data on disk...
Resetting Master Boot Record of /dev/sda
udisks-error-quark: GDBus.Error:org.freedesktop.UDisks2.Error.Failed: Error opening device /dev/sda: Device or resource busy (0)
Tails installation failed!
udisks-error-quark: GDBus.Error:org.freedesktop.UDisks2.Error.Failed: Error opening device /dev/sda: Device or resource busy (0)
After this failure TailsData
indeed remains mounted, so it is expected that there were problems when messing with the MBR.
If I apply !1359 (merged) the exact same failure occurs.
Install to a mounted partition, no other partitions on device
I prepared the device like this:
sudo parted --align=none --script /dev/sda mklabel gpt mkpart primary fat32 0 100% print
sudo mkfs.vfat /dev/sda1
So this is the same as our automated test suite's scenario Installing Tails with Tails Installer to a used USB drive
, i.e. what #20139 (closed) is about.
Installation fails with the console saying:
Unmounting mounted filesystems on "/dev/sda1"
Unmounting mounted filesystems on "/dev/sda1"
'NoneType' object has no attribute 'props'
Tails installation failed!
'NoneType' object has no attribute 'props'
The --verbose
log says:
2024-01-26 11:03:45,494 [creator.py:756 (unmount_device)] INFO: Unmounting mounted filesystems on "/dev/sda1"
2024-01-26 11:03:50,340 [creator.py:756 (unmount_device)] INFO: Unmounting mounted filesystems on "/dev/sda1"
2024-01-26 11:03:50,341 [gui.py:199 (run)] ERROR: 'NoneType' object has no attribute 'props'
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/tails_installer/gui.py", line 128, in run
self.live.unmount_device()
File "/usr/lib/python3/dist-packages/tails_installer/creator.py", line 766, in unmount_device
filesystem = self._get_object(udi).props.filesystem
AttributeError: 'NoneType' object has no attribute 'props'
If I apply !1359 (merged) the above issue is fixed and installation is successful.
Install to a device with two partitions that both are mounted
I prepared the device like this (also in the remaining scenarios):
sudo parted --align=none --script /dev/sda mklabel gpt mkpart primary fat32 0 50% mkpart primary fat32 50% 100% print
sudo mkfs.vfat /dev/sda1
sudo mkfs.vfat /dev/sda2
Tails Cloner fails in the same way no matter if I select the first or second partitions as target, and it fails exactly like in the "Install to a mounted partition, no other partitions on device" scenario above.
If I apply !1359 (merged) it works around the above error, the target partition is successfully unmounted, but the other partition remains mounted so installation eventually fails while attempting to partition the device, which is expected.
Install to a device with two partitions, target is mounted, the other is not
This also fails exactly like the "Install to a mounted partition, no other partitions on device" scenario above. It also doesn't matter if it is the first or second partition that is mounted and the target.
If I apply !1359 (merged) it works around the above error and installation is successful.
Install to a device with two partitions, target is unmounted, the other is mounted
This immediately starts partitioning the device, which fails since no attempt was made to unmount the "other" partition so it remains mounted.
If I apply !1359 (merged) the exact same failure occurs.
Summary
These of the above scenarios are fixed by !1359 (merged):
- Install to a mounted partition, no other partitions on device
- Install to a device with two partitions, target is mounted, the other is not
These scenarios still fails, and is what this issue is about (given that !1359 (merged) is merged):
- Upgrade a Tails installations when its persistent partition is mounted
- Install to a device with two partitions that both are mounted
- Install to a device with two partitions, target is unmounted, the other is mounted
The common thing here very clearly is: failure occurs when a non-target partition on the same device is mounted. The problem is that unmount_device()
fails to unmount other partitions on the same device as the target partition.