-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mdadm tool in root filesystem. Signed-off-by: Serge Logvinov <[email protected]>
- Loading branch information
1 parent
067c3b7
commit a4915ec
Showing
11 changed files
with
208 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# mdadm | ||
|
||
## Installation | ||
|
||
See [Installing Extensions](https://github.com/siderolabs/extensions#installing-extensions). | ||
|
||
## Usage | ||
|
||
```yaml | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# do not edit this file, it will be overwritten on update | ||
|
||
SUBSYSTEM!="block", GOTO="md_end" | ||
|
||
# handle md arrays | ||
ACTION!="add|change", GOTO="md_end" | ||
KERNEL!="md*", GOTO="md_end" | ||
|
||
# partitions have no md/{array_state,metadata_version}, but should not | ||
# for that reason be ignored. | ||
ENV{DEVTYPE}=="partition", GOTO="md_ignore_state" | ||
|
||
# container devices have a metadata version of e.g. 'external:ddf' and | ||
# never leave state 'inactive' | ||
ATTR{md/metadata_version}=="external:[A-Za-z]*", ATTR{md/array_state}=="inactive", GOTO="md_ignore_state" | ||
TEST!="md/array_state", GOTO="md_end" | ||
ATTR{md/array_state}=="clear*|inactive", GOTO="md_end" | ||
LABEL="md_ignore_state" | ||
|
||
IMPORT{program}="/sbin/mdadm --detail --no-devices --export $devnode" | ||
ENV{DEVTYPE}=="disk", ENV{MD_NAME}=="?*", SYMLINK+="disk/by-id/md-name-$env{MD_NAME}", OPTIONS+="string_escape=replace" | ||
ENV{DEVTYPE}=="disk", ENV{MD_UUID}=="?*", SYMLINK+="disk/by-id/md-uuid-$env{MD_UUID}" | ||
ENV{DEVTYPE}=="disk", ENV{MD_DEVNAME}=="?*", SYMLINK+="md/$env{MD_DEVNAME}" | ||
ENV{DEVTYPE}=="partition", ENV{MD_NAME}=="?*", SYMLINK+="disk/by-id/md-name-$env{MD_NAME}-part%n", OPTIONS+="string_escape=replace" | ||
ENV{DEVTYPE}=="partition", ENV{MD_UUID}=="?*", SYMLINK+="disk/by-id/md-uuid-$env{MD_UUID}-part%n" | ||
ENV{DEVTYPE}=="partition", ENV{MD_DEVNAME}=="*[^0-9]", SYMLINK+="md/$env{MD_DEVNAME}%n" | ||
ENV{DEVTYPE}=="partition", ENV{MD_DEVNAME}=="*[0-9]", SYMLINK+="md/$env{MD_DEVNAME}p%n" | ||
|
||
IMPORT{builtin}="blkid" | ||
OPTIONS+="link_priority=100" | ||
OPTIONS+="watch" | ||
ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}" | ||
ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_PART_ENTRY_UUID}=="?*", SYMLINK+="disk/by-partuuid/$env{ID_PART_ENTRY_UUID}" | ||
ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}" | ||
|
||
LABEL="md_end" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# do not edit this file, it will be overwritten on update | ||
|
||
# assemble md arrays | ||
SUBSYSTEM!="block", GOTO="md_inc_end" | ||
|
||
# handle potential components of arrays (the ones supported by md) | ||
ENV{ID_FS_TYPE}=="linux_raid_member", GOTO="md_inc" | ||
|
||
# "noiswmd" on kernel command line stops mdadm from handling | ||
# "isw" (aka IMSM - Intel RAID). | ||
# "nodmraid" on kernel command line stops mdadm from handling | ||
# "isw" or "ddf". | ||
IMPORT{cmdline}="noiswmd" | ||
IMPORT{cmdline}="nodmraid" | ||
|
||
ENV{nodmraid}=="?*", GOTO="md_inc_end" | ||
ENV{ID_FS_TYPE}=="ddf_raid_member", GOTO="md_inc" | ||
ENV{noiswmd}=="?*", GOTO="md_inc_end" | ||
ENV{ID_FS_TYPE}=="isw_raid_member", ACTION!="change", GOTO="md_inc" | ||
GOTO="md_inc_end" | ||
|
||
LABEL="md_inc" | ||
|
||
# remember you can limit what gets auto/incrementally assembled by | ||
# mdadm.conf(5)'s 'AUTO' and selectively whitelist using 'ARRAY' | ||
ACTION=="add|change", IMPORT{program}="/sbin/mdadm --incremental --export $devnode --offroot $env{DEVLINKS}" | ||
ACTION=="remove", ENV{ID_PATH}=="?*", RUN+="/sbin/mdadm -If $name --path $env{ID_PATH}" | ||
ACTION=="remove", ENV{ID_PATH}!="?*", RUN+="/sbin/mdadm -If $name" | ||
|
||
LABEL="md_inc_end" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: v1alpha1 | ||
metadata: | ||
name: mdadm | ||
version: "$VERSION" | ||
author: Serge Logvinov | ||
description: | | ||
This system extension provides mdadm binary. | ||
compatibility: | ||
talos: | ||
version: ">= v1.5.0" |
25 changes: 25 additions & 0 deletions
25
storage/mdadm/patches/exit-gracefully-when-md-device-not-found.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Description: Exit gracefully when md device not found | ||
Author: Felix Lechner <[email protected]> | ||
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=970329 | ||
Forwarded: no | ||
--- | ||
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ | ||
--- a/Monitor.c | ||
+++ b/Monitor.c | ||
@@ -539,8 +539,14 @@ static int check_array(struct state *st, | ||
if (fd < 0) | ||
goto disappeared; | ||
|
||
- if (st->devnm[0] == 0) | ||
- strcpy(st->devnm, fd2devnm(fd)); | ||
+ if (st->devnm[0] == 0) { | ||
+ char *found = fd2devnm(fd); | ||
+ if (!found) { | ||
+ alert("DeviceDisappeared", dev, NULL, ainfo); | ||
+ goto out; | ||
+ } | ||
+ strcpy(st->devnm, found); | ||
+ } | ||
|
||
for (mse2 = mdstat; mse2; mse2 = mse2->next) | ||
if (strcmp(mse2->devnm, st->devnm) == 0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
From: Michael Tokarev <[email protected]> | ||
Subject: do not #include ansidecl.h from sha1.h, use system headers | ||
|
||
In 3.2.5 version of mdadm, new sha1 implementation has been included | ||
which tries to include ansidecl.h header which is internal to some | ||
other project. But this #include isn't really necessary, since this | ||
implementation does not actually use any defines from ansidecl.h. So | ||
just remove the #include, instead of adding a new external dependency. | ||
|
||
References: http://www.spinics.net/lists/raid/msg38859.html | ||
|
||
While at it, unconditionally include system headers like limits.h and | ||
stdint.h, since on a Linux system these headers are available, and | ||
these contains definitive information about real system types than | ||
any guesses. | ||
|
||
--- a/sha1.h | ||
+++ b/sha1.h | ||
@@ -22,7 +22,7 @@ | ||
|
||
#include <stdio.h> | ||
|
||
-#if defined HAVE_LIMITS_H || _LIBC | ||
+#if 1 /* defined HAVE_LIMITS_H || _LIBC */ | ||
# include <limits.h> | ||
#endif | ||
|
||
@@ -33,9 +33,9 @@ | ||
the resulting executable. Locally running cross-compiled executables | ||
is usually not possible. */ | ||
|
||
-#ifdef _LIBC | ||
-# include <sys/types.h> | ||
-typedef u_int32_t sha1_uint32; | ||
+#if 1 /* def _LIBC */ | ||
+# include <stdint.h> | ||
+typedef uint32_t sha1_uint32; | ||
typedef uintptr_t sha1_uintptr; | ||
#else | ||
# define INT_MAX_32_BITS 2147483647 |
17 changes: 17 additions & 0 deletions
17
storage/mdadm/patches/strcat-look-for-md-device-in-dev-md.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Description: Look for md device in /dev/md | ||
Author: Martin Mares <[email protected]> | ||
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=958060 | ||
Forwarded: no | ||
--- | ||
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ | ||
--- a/Monitor.c | ||
+++ b/Monitor.c | ||
@@ -188,7 +188,7 @@ int Monitor(struct mddev_dev *devlist, | ||
st->devname = xstrdup(mdlist->devname); | ||
else { | ||
st->devname = xmalloc(8+strlen(mdlist->devname)+1); | ||
- strcpy(strcpy(st->devname, "/dev/md/"), | ||
+ strcat(strcpy(st->devname, "/dev/md/"), | ||
mdlist->devname); | ||
} | ||
st->next = statelist; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: mdadm | ||
variant: scratch | ||
shell: /toolchain/bin/bash | ||
dependencies: | ||
- stage: base | ||
- image: "{{ .PKGS_PREFIX }}/eudev:{{ .BUILD_ARG_PKGS }}" | ||
- image: "{{ .PKGS_PREFIX }}/util-linux:{{ .BUILD_ARG_PKGS }}" | ||
steps: | ||
- sources: | ||
- url: http://www.kernel.org/pub/linux/utils/raid/mdadm/mdadm-4.2.tar.gz | ||
destination: mdadm.tar.gz | ||
sha256: c83447797cccc772d1c389b1917a2bfda59bd7545480bdccd792b57b310b428e | ||
sha512: 112a897c6943d7343f44ffe32a8d7ef11e1f1624f51385c0f1d27458d661202bb378678a3ddc78ed2e24533be234441ea15cf33769345d5709b72b72ad9ec540 | ||
prepare: | ||
- | | ||
tar -xzf mdadm.tar.gz --strip-components=1 | ||
- | | ||
patch -p1 < /pkg/patches/exit-gracefully-when-md-device-not-found.patch | ||
patch -p1 < /pkg/patches/sha1-includes.diff | ||
patch -p1 < /pkg/patches/strcat-look-for-md-device-in-dev-md.patch | ||
build: | ||
- | | ||
mkdir -p /run/mdadm | ||
CXFLAGS=-D_LARGEFILE64_SOURCE \ | ||
make -j $(nproc) mdadm | ||
install: | ||
- | | ||
mkdir -p /rootfs/sbin/ /rootfs/usr/etc/udev/rules.d | ||
cp mdadm /rootfs/sbin/mdadm | ||
cp /pkg/files/udev-md-raid-arrays.rules /rootfs/usr/etc/udev/rules.d/63-md-raid-arrays.rules | ||
cp /pkg/files/udev-md-raid-assembly.rules /rootfs/usr/etc/udev/rules.d/64-md-raid-assembly.rules | ||
finalize: | ||
- from: /rootfs | ||
to: /rootfs | ||
- from: /pkg/manifest.yaml | ||
to: / |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
VERSION: "{{ .BUILD_ARG_TAG }}" |