Skip to content

Commit

Permalink
Add support for IBM s390x dasd disks
Browse files Browse the repository at this point in the history
Installation on s390 dasd disks is a bit tricky,
this patch makes coreos-installer able to format,
create partitions, and finally install CoreOS on s390.

Signed-off-by: Nikita Dubrovskii <nikita@linux.ibm.com>
  • Loading branch information
nikita-dubrovskii committed Apr 6, 2020
1 parent 7bbb525 commit 272b3eb
Show file tree
Hide file tree
Showing 8 changed files with 814 additions and 5 deletions.
223 changes: 223 additions & 0 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ path = "src/main.rs"
[profile.release]
lto = true

[target.'cfg(target_arch = "s390x")'.dependencies]
dd-lib = "0.2.1"
walkdir = "2.3.1"
fdisk="^0.1.0"
tempfile = "^3.1.0"

[dependencies]
byte-unit = "^3.0"
clap = "^2.33"
Expand Down
25 changes: 20 additions & 5 deletions src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,25 @@ fn write_disk(
dest: &mut File,
ignition: Option<File>,
) -> Result<()> {
// Get sector size of destination, for comparing with image
let sector_size = get_sector_size(dest)?;

// copy the image
write_image(source, dest, true, Some(sector_size))?;
if cfg!(target_arch = "s390x") && config.device.contains("dasd") {
#[cfg(target_arch = "s390x")]
crate::s390x::dasd::write_image_s390(config, source)?;
} else {
// Get sector size of destination, for comparing with image
let sector_size = get_sector_size(dest)?;
write_image(source, dest, true, Some(sector_size))?;
}

reread_partition_table(dest)?;
udev_settle()?;

// postprocess
if ignition.is_some() || config.firstboot_kargs.is_some() || config.platform.is_some() {
if ignition.is_some()
|| config.firstboot_kargs.is_some()
|| config.platform.is_some()
|| cfg!(target_arch = "s390x")
{
let mount = mount_partition_by_label(&config.device, "boot", mount::MsFlags::empty())?;
if let Some(ignition) = ignition {
write_ignition(mount.mountpoint(), ignition)?;
Expand All @@ -122,6 +131,12 @@ fn write_disk(
if let Some(platform) = config.platform.as_ref() {
write_platform(mount.mountpoint(), platform)?;
}
#[cfg(target_arch = "s390x")]
crate::s390x::zipl::install_bootloader(
mount.mountpoint(),
&config.device,
&config.firstboot_kargs,
)?;
}

Ok(())
Expand Down
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ mod download;
mod errors;
mod install;
mod iso;
#[cfg(target_arch = "s390x")]
mod s390x;
mod source;
mod verify;

Expand Down
10 changes: 10 additions & 0 deletions src/s390x/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# CoreOS installation on IBM Z

IBM s390x machines usually have DASD (Direct Access Storage Devices) disks.

To use DASD as a Linux harddisk we have to pass thru several steps:
1) Using `dasdfmt` tool we have to low-level format it
2) Using `fdasd` tool we have to create partition(s) on it
3) Copy each partition from CoreOS image to corresponding partition on DASD)
4) Using `zipl` tool install boot loader
5) Using `chreipl` tool mark DASD as next boot devcie
Loading

0 comments on commit 272b3eb

Please sign in to comment.