Pārlūkot izejas kodu

Disk partitioning

Ability to create partitions on empty disks.

Change-Id: I0a71da9d62d8f7df3fa03e3f34d49bad6988ba6d
pull/118/head
Jakub Pavlik pirms 7 gadiem
vecāks
revīzija
4f74214491
4 mainītis faili ar 70 papildinājumiem un 10 dzēšanām
  1. +22
    -0
      README.rst
  2. +35
    -0
      linux/storage/disk.sls
  3. +4
    -1
      linux/storage/init.sls
  4. +9
    -9
      tests/pillar/storage.sls

+ 22
- 0
README.rst Parādīt failu

@@ -1269,6 +1269,28 @@ LVM group `vg1` with one device and `data` volume mounted into `/mnt/data`
size: 40G
mount: ${linux:storage:mount:data}

Create partitions on disk. Specify size in MB. It expects empty
disk without any existing partitions.

.. code-block:: yaml

linux:
storage:
disk:
first_drive:
name: /dev/loop1
type: gpt
partitions:
- size: 200 #size in MB
type: fat32
- size: 300 #size in MB
type: ext4
/dev/vda1:
partitions:
- size: 5
type: ext2
- size: 10
type: ext4

Multipath with Fujitsu Eternus DXL


+ 35
- 0
linux/storage/disk.sls Parādīt failu

@@ -0,0 +1,35 @@
{%- from "linux/map.jinja" import storage with context %}
{%- if storage.enabled %}

{%- for disk_name, disk in storage.disk.iteritems() %}

{%- if disk.type is defined %}
create_disk_label:
module.run:
- name: partition.mklabel
- device: {{ disk.name|default(disk_name) }}
- label_type: {{ disk.get('type', 'gpt') }}
- unless: fdisk -l | grep {{ disk.get('type', 'gpt') }}
{%- endif %}

{% set end_size = 0 -%}

{%- for partition in disk.get('partitions', []) %}

{%- if not salt['partition.exists'](disk.get('name', disk_name)+'p'~loop.index) %}
create_partition_{{ disk.name|default(disk_name) }}_{{ loop.index }}:
module.run:
- name: partition.mkpart
- device: {{ disk.name|default(disk_name) }}
- part_type: primary
- fs_type: {{ partition.type }}
- start: {{ end_size }}MB
- end: {{ end_size + partition.size }}MB
{%- endif %}

{% set end_size = end_size + partition.size -%}

{%- endfor %}
{%- endfor %}

{%- endif %}

+ 4
- 1
linux/storage/init.sls Parādīt failu

@@ -1,9 +1,12 @@
{%- from "linux/map.jinja" import storage with context %}
{%- if storage.mount|length > 0 or storage.swap|length > 0 or storage.multipath.enabled or storage.lvm|length > 0 or storage.loopback|length > 0 %}
{%- if storage.mount|length > 0 or storage.swap|length > 0 or storage.multipath.enabled or storage.disk|length > 0 or storage.lvm|length > 0 or storage.loopback|length > 0 %}
include:
{%- if storage.loopback|length > 0 %}
- linux.storage.loopback
{%- endif %}
{%- if storage.disk|length > 0 %}
- linux.storage.disk
{%- endif %}
{%- if storage.lvm|length > 0 %}
- linux.storage.lvm
{%- endif %}

+ 9
- 9
tests/pillar/storage.sls Parādīt failu

@@ -50,12 +50,12 @@ linux:
device: /dev/vg0/lv03
path: /mnt/lv03
file_system: xfs
disk1:
enabled: true
device: /dev/loop_dev4
path: /tmp/dummy
file_system: xfs
options: "noatime,nobarrier,logbufs=8"
user: nobody
group: nogroup
mode: 755
disk:
first_drive:
name: /tmp/loop_dev4
type: gpt
partitions:
- size: 5
type: fat32
- size: 5
type: fat32

Notiek ielāde…
Atcelt
Saglabāt