Skip to content

Commit

Permalink
Pad bootimage.bin so that it is a multiple of 512 byte
Browse files Browse the repository at this point in the history
VirtualBox requires 512-byte aligned disks. Reported in phil-opp/blog_os#403 (comment)
  • Loading branch information
phil-opp committed Mar 25, 2018
1 parent 0334626 commit ba6f206
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ fn main() -> io::Result<()> {
}
}

let padding_size = ((512 - (kernel_size % 512)) % 512) as usize;
let padding = [0u8; 512];
output.write_all(&padding[..padding_size])?;

Ok(())
}

Expand Down

0 comments on commit ba6f206

Please sign in to comment.