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

feature(storage): config support for generate section #1634

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 109 additions & 20 deletions doc/auto_storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ installation.

## Agama and AutoYaST

AutoYaST profiles can be used with Agama offering a 100% backward compatibility.

The `legacyAutoyastStorage` section of the Agama profile is a 1:1 representation of the XML
specification of AutoYaST. No JSON validation will be performed for it.
The Agama profile has a special `legacyAutoyastStorage` section which is a 1:1 representation of the
XML AutoYaST profile. This section supports everything offered by the *partitioning* AutoYaST
section. Note that Agama does not validate this special section, so be careful to provide valid
AutoYaST options.

~~~json
{
Expand All @@ -21,21 +21,6 @@ specification of AutoYaST. No JSON validation will be performed for it.
}
~~~

### Implementation Considerations for AutoYaST Specification

In principle, implementing the legacy AutoYaST module is as simple as converting the corresponding
section of the profile into a `Y2Storage::PartitioningSection` object and use
`Y2Storage::AutoInstProposal` to calculate the result.

But there are some special cases in which AutoYaST fallbacks to read some settings from the YaST
settings or to use some YaST mechanisms. Those cases should be taken into account during the
implementation.

For example, AutoYaST relies on the traditional YaST proposal settings when "auto" is used to
specify the size of a partition or to determine the default list of subvolumes when Btrfs is used.
See also the sections "Automatic Partitioning" and "Guided Partitioning" at the AutoYaST
documentation for situations in which AutoYaST uses the standard YaST `GuidedProposal` as fallback.

### Problems with the AutoYaST Schema

The AutoYaST schema is far from ideal and it presents some problems.
Expand Down Expand Up @@ -166,6 +151,21 @@ going to be used by.

It would be more natural to indicate the used devices directly in the RAID or logical volume drive.

### Implementation Considerations for AutoYaST Specification

In principle, implementing the legacy AutoYaST module is as simple as converting the corresponding
section of the profile into a `Y2Storage::PartitioningSection` object and use
`Y2Storage::AutoInstProposal` to calculate the result.

But there are some special cases in which AutoYaST fallbacks to read some settings from the YaST
settings or to use some YaST mechanisms. Those cases should be taken into account during the
implementation.

For example, AutoYaST relies on the traditional YaST proposal settings when "auto" is used to
specify the size of a partition or to determine the default list of subvolumes when Btrfs is used.
See also the sections "Automatic Partitioning" and "Guided Partitioning" at the AutoYaST
documentation for situations in which AutoYaST uses the standard YaST `GuidedProposal` as fallback.

## The New Storage Schema

Agama offers its own storage schema which is more semantic, comprehensive and flexible than the
Expand Down Expand Up @@ -240,7 +240,7 @@ VolumeGroup
alias [<string>]
name [<string>]
peSize [<number>]
physicalVolumes [<<string|Search>[]>]
physicalVolumes [<string|Search>[]>]
logicalVolumes [<LogicalVolume[]>]
delete [<boolean=false>]

Expand Down Expand Up @@ -855,6 +855,95 @@ space first by shrinking the partitions and deleting them only if shrinking is n
}
```

### Generating Default Volumes

Every product provides a configuration which defines the storage volumes (e.g., feasible file
systems for root, default partitions to create, etc). The default or mandatory product volumes can
be automatically generated by using a *generate* section in the *partitions* or *logicalVolumes*
sections.

```json
"storage": {
"drives": [
{
"partitions": [
{ "generate": "default" }
]
}
]
}

```

The *generate* section allows creating the product volumes without explicitly writing all of them.
The config above would be equivalent to something like this:

```json
"storage": {
"drives": [
{
"partitions": [
{ "filesystem": { "path": "/" } },
{ "filesystem": { "path": "/home" } },
{ "filesystem": { "path": "swap" } }
]
}
]
}

```

If any path is explicitly defined, then the *generate* section will not generate a volume for it.
For example, with the following config only root and swap would be automatically added:

```json
"storage": {
"drives": [
{
"partitions": [
{ "generate": "default" },
{ "filesystem": { "path": "/home" } }
]
}
]
}
```

The auto-generated volumes can be also configured. For example, for encrypting the partitions:

```json
"storage": {
"drives": [
{
"partitions": [
{
"generate": {
"partitions": "default",
"encryption": {
"luks1": { "password": "12345" }
}
}
}
]
}
]
}
```

The *mandatory* keyword can be used for only generating the mandatory partitions or logical volumes:

```json
"storage": {
"volumeGroups": [
{
"logicalVolumes": [
{ "generate": "mandatory" }
]
}
]
}
```

### Using the Automatic Proposal

On the first implementations, Agama can rely on the process known as Guided Proposal to calculate
Expand Down
24 changes: 24 additions & 0 deletions rust/agama-lib/share/examples/storage/generate_lvs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"storage": {
"drives": [
{
"partitions": [
{
"alias": "pv1",
"id": "lvm",
"size": { "min": "10 GiB" }
}
]
}
],
"volumeGroups": [
{
"name": "system",
"physicalVolumes": ["pv1"],
"logicalVolumes": [
{ "generate": "default" }
]
}
]
}
}
43 changes: 43 additions & 0 deletions rust/agama-lib/share/examples/storage/generate_lvs_extended.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"storage": {
"drives": [
{
"partitions": [
{
"alias": "pv1",
"id": "lvm",
"size": { "min": "10 GiB" }
}
]
}
],
"volumeGroups": [
{
"name": "system",
"physicalVolumes": ["pv1"],
"logicalVolumes": [
{
"generate": {
"logicalVolumes": "mandatory",
"encryption": {
"luks2": {
"password": "12345"
}
},
"stripes": 10,
"stripeSize": "4 KiB"
}
},
{
"name": "data",
"size": "5 GiB",
"filesystem": {
"path": "/data",
"type": "xfs"
}
}
]
}
]
}
}
13 changes: 13 additions & 0 deletions rust/agama-lib/share/examples/storage/generate_partitions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"storage": {
"drives": [
{
"partitions": [
{
"generate": "mandatory"
}
]
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"storage": {
"drives": [
{
"partitions": [
{
"size": "10 GiB",
"filesystem": {
"type": "vfat"
}
},
{
"generate": {
"partitions": "default",
"encryption": {
"luks2": {
"password": "12345"
}
}
}
}
]
}
]
}
}
Loading
Loading