Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blockdev: support installing to DM devices #285

Merged
merged 3 commits into from
Jul 6, 2020
Merged

blockdev: support installing to DM devices #285

merged 3 commits into from
Jul 6, 2020

Conversation

bgilbert
Copy link
Contributor

@bgilbert bgilbert commented Jun 30, 2020

Handle partitioning with kpartx, and rely on the lsblk + holders busy-partition check to ensure exclusivity.

Fixes #91. Alternative to #211.

@nikita-dubrovskii
Copy link
Contributor

LGTM.
Did test it on s390x

src/blockdev.rs Outdated Show resolved Hide resolved
src/blockdev.rs Show resolved Hide resolved
src/blockdev.rs Outdated Show resolved Hide resolved
src/blockdev.rs Show resolved Hide resolved
src/blockdev.rs Show resolved Hide resolved
@bgilbert
Copy link
Contributor Author

bgilbert commented Jul 2, 2020

Updated.

Copy link
Contributor

@lucab lucab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM, but I did not manually test the logic.

@jlebon
Copy link
Member

jlebon commented Jul 3, 2020

Hadn't paid a lot of attention to this, but coreos/fedora-coreos-config#503 is related here. I think it's possible to support this, but then it's the user's responsibility to make sure they add any necessary kargs (via --append-karg) for the machine to activate the right DM devices on boot. Because of this, I'm wondering if this should be gated behind some switch to make sure users understand this?

Copy link
Member

@jlebon jlebon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! LGTM though interested in people's thoughts re. #285 (comment) before we commit to supporting this transparently.

src/blockdev.rs Outdated Show resolved Hide resolved
@bgilbert
Copy link
Contributor Author

bgilbert commented Jul 3, 2020

FWIW, #91 gives a case where FCOS can support this transparently: a DM device used as the boot disk for a VM. The installer is run from the host, and the target device is non-partitionable from the host's perspective but partitionable from the guest's.

See also coreos/fedora-coreos-tracker#321.

kpartx creates a separate DM device for each partition.  Those device
nodes aren't real partitions but we can handle them anyway.
The rereadpt ioctl check is safest but it only works on partitionable
devices, which excludes device-mapper volumes such as multipath.  On
DM volumes, rely exclusively on our lsblk and holders checks.
Use kpartx for device-mapper devices and BLKRRPART otherwise.  Handle
two operations:

- Rereading the partition table after changing it.
- In the kpartx case, if the partition devices do not already exist at
  startup, tear them down again on the way out.
Copy link
Member

@jlebon jlebon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, #91 gives a case where FCOS can support this transparently: a DM device used as the boot disk for a VM. The installer is run from the host, and the target device is non-partitionable from the host's perspective but partitionable from the guest's.

Right, yup. Hmm OK, LGTM as is. I guess we can just expect users doing this to know what they're doing. Maybe in the future we can print a notice or something if some people get confused.

@bgilbert bgilbert merged commit 446673a into coreos:master Jul 6, 2020
@bgilbert bgilbert deleted the dm branch July 6, 2020 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Non-partitionable target devices are not supported
4 participants