Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
installer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
redox-os
installer
Commits
b724e714
Verified
Commit
b724e714
authored
2 years ago
by
Jeremy Soller
Browse files
Options
Downloads
Patches
Plain Diff
Move EFI partition to second megabyte
parent
c6d7cf16
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/lib.rs
+24
-22
24 additions, 22 deletions
src/lib.rs
with
24 additions
and
22 deletions
src/lib.rs
+
24
−
22
View file @
b724e714
...
...
@@ -408,19 +408,19 @@ pub fn with_whole_disk<P, F, T>(disk_path: P, bootloader_bios: &[u8], bootloader
// Calculate partition offsets
let
gpt_reserved
=
34
*
512
;
// GPT always reserves 34 512-byte sectors
let
mibi
=
1024
*
1024
;
// First megabyte of the disk is reserved for BIOS partition, wich includes GPT tables
let
bios_size
=
1024
*
1024
;
let
bios_start
=
gpt_reserved
/
block_size
;
let
bios_end
=
(
bi
os_size
/
block_size
)
-
1
;
// End at 1 MiB
let
bios_end
=
(
mi
bi
/
block_size
)
-
1
;
// Last megabyte of the disk is reserved for EFI partition
let
efi_size
=
1024
*
1024
;
let
efi_end
=
((
disk_size
-
gpt_reserved
)
/
block_size
)
-
1
;
let
efi_start
=
(
disk_size
-
efi_size
)
/
block_size
;
// 1 MiB from end of disk
// Second megabyte of the disk is reserved for EFI partition
let
efi_start
=
bios_end
+
1
;
let
efi_end
=
efi_start
+
(
mibi
/
block_size
)
-
1
;
let
redoxfs_start
=
bios_end
+
1
;
let
redoxfs_end
=
efi_start
-
1
;
// The rest of the disk is RedoxFS, reserving the GPT table mirror at the end of disk
let
redoxfs_start
=
efi_end
+
1
;
let
redoxfs_end
=
((((
disk_size
-
gpt_reserved
)
/
mibi
)
*
mibi
)
/
block_size
)
-
1
;
// Format and install BIOS partition
{
...
...
@@ -455,6 +455,17 @@ pub fn with_whole_disk<P, F, T>(disk_path: P, bootloader_bios: &[u8], bootloader
});
partition_id
+=
1
;
// Add EFI boot partition
partitions
.insert
(
partition_id
,
gpt
::
partition
::
Partition
{
part_type_guid
:
gpt
::
partition_types
::
EFI
,
part_guid
:
uuid
::
Uuid
::
new_v4
(),
first_lba
:
efi_start
,
last_lba
:
efi_end
,
flags
:
0
,
// TODO
name
:
"EFI"
.to_string
(),
});
partition_id
+=
1
;
// Add RedoxFS partition
partitions
.insert
(
partition_id
,
gpt
::
partition
::
Partition
{
//TODO: Use REDOX_REDOXFS type (needs GPT crate changes)
...
...
@@ -465,17 +476,6 @@ pub fn with_whole_disk<P, F, T>(disk_path: P, bootloader_bios: &[u8], bootloader
flags
:
0
,
name
:
"REDOX"
.to_string
(),
});
partition_id
+=
1
;
// Add EFI boot partition
partitions
.insert
(
partition_id
,
gpt
::
partition
::
Partition
{
part_type_guid
:
gpt
::
partition_types
::
EFI
,
part_guid
:
uuid
::
Uuid
::
new_v4
(),
first_lba
:
efi_start
,
last_lba
:
efi_end
,
flags
:
0
,
// TODO
name
:
"EFI"
.to_string
(),
});
eprintln!
(
"Writing GPT tables: {:#?}"
,
partitions
);
...
...
@@ -488,13 +488,15 @@ pub fn with_whole_disk<P, F, T>(disk_path: P, bootloader_bios: &[u8], bootloader
// Format and install EFI partition
{
let
disk_efi_start
=
efi_start
*
block_size
;
let
disk_efi_end
=
(
efi_end
+
1
)
*
block_size
;
let
mut
disk_efi
=
fscommon
::
StreamSlice
::
new
(
&
mut
disk_file
,
efi_start
*
block_size
,
(
efi_end
+
1
)
*
block_size
,
disk_
efi_start
,
disk_
efi_end
,
)
?
;
eprintln!
(
"Formatting EFI partition with size {:#x}"
,
efi_size
);
eprintln!
(
"Formatting EFI partition with size {:#x}"
,
disk_efi_end
-
disk_efi_start
);
fatfs
::
format_volume
(
&
mut
disk_efi
,
fatfs
::
FormatVolumeOptions
::
new
())
?
;
eprintln!
(
"Opening EFI partition"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment