add mdev conf, links NVMEe devs to EBS xvd/sd devs

This commit is contained in:
Jake Buchholz 2018-12-30 12:29:27 -08:00 committed by Mike Crute
parent 80807fa647
commit b669fc0a21
4 changed files with 38 additions and 0 deletions

View File

@ -53,6 +53,12 @@ builders:
provisioners:
- type: "file"
source: "nvme-ebs-links.sh"
destination: "/tmp/"
- type: "file"
source: "nvme-ebs-mdev.conf"
destination: "/tmp/"
- type: "shell"
script: "make_ami.sh"
environment_vars:

View File

@ -133,6 +133,7 @@ install_core_packages() {
chroot "$target" apk --no-cache add \
linux-virt \
alpine-mirrors \
nvme-cli \
chrony \
openssh \
sudo \
@ -153,6 +154,13 @@ install_core_packages() {
sed -i "s/^export PS1='/&\\\\u@/" "$target"/etc/profile
}
setup_mdev() {
local target="$1"
cp -a /tmp/nvme-ebs-links.sh "$target"/lib/mdev
sed -n -i -e '/# fallback/r /tmp/nvme-ebs-mdev.conf' -e 1x -e '2,${x;p}' -e '${x;p}' "$target"/etc/mdev.conf
}
create_initfs() {
local target="$1"
@ -327,6 +335,7 @@ main() {
install_extlinux "$target"
einfo "Configuring system"
setup_mdev "$target"
setup_fstab "$target"
setup_networking "$target"
enable_services "$target"

20
nvme-ebs-links.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/sh
[ -x /usr/sbin/nvme ] || exit
case $ACTION in
add|"")
BASE=$(echo $MDEV | sed -re 's/^(nvme[0-9]+n[0-9]+).*/\1/')
PART=$(echo $MDEV | sed -re 's/nvme[0-9]+n[0-9]+p?//g')
EBS=$(/usr/sbin/nvme id-ctrl "/dev/$BASE" -b 2>/dev/null | dd bs=32 skip=96 count=1 2>/dev/null | tr -d ' ')
EBS=${EBS#/dev/}$PART
ln -sf $MDEV ${EBS/xvd/sd}
ln -sf $MDEV ${EBS/sd/xvd}
;;
remove)
for TARGET in sd* xvd*
do
[ "$(readlink $TARGET 2>/dev/null)" = $MDEV ] && rm -f $TARGET
done
;;
esac

3
nvme-ebs-mdev.conf Normal file
View File

@ -0,0 +1,3 @@
# ebs nvme links
nvme[0-9]+n[0-9]+.* root:root 0660 */lib/mdev/nvme-ebs-links.sh