mirror of
https://github.com/home-assistant/operating-system.git
synced 2025-07-24 13:36:31 +00:00
Allow easy move data partition (#651)
* Allow easy move data partition * Cleanup handling systemd * Improve handling * fix pipeline * pipeline * fix shell handling * fix scripts * Add bin folder * fix lint * Fix service handling * Fix loading * hide output * Fix handling
This commit is contained in:
parent
ba9d1bac1e
commit
b3530d1ce1
@ -38,11 +38,15 @@ jobs:
|
||||
sudo docker pull koalaman/shellcheck:$(versionShellCheck)
|
||||
displayName: 'Install ShellCheck'
|
||||
- script: |
|
||||
set -e
|
||||
|
||||
# Check build script
|
||||
sudo docker run --rm -i \
|
||||
-v $(pwd):/mnt:ro koalaman/shellcheck:$(versionShellCheck) \
|
||||
scripts/*.sh \
|
||||
buildroot-external/scripts/*.sh \
|
||||
buildroot-external/board/**/*.sh \
|
||||
buildroot-external/rootfs-overlay/usr/bin/* \
|
||||
buildroot-external/rootfs-overlay/usr/sbin/* \
|
||||
buildroot-external/rootfs-overlay/usr/libexec/* \
|
||||
buildroot-external/rootfs-overlay/usr/lib/rauc/*
|
||||
|
@ -0,0 +1,39 @@
|
||||
From 81b290367d59103d1f041709c56a3de1c360e102 Mon Sep 17 00:00:00 2001
|
||||
From: Jerome Brunet <jbrunet@baylibre.com>
|
||||
Date: Mon, 13 May 2019 14:45:31 +0200
|
||||
Subject: [PATCH] FROMLIST: clk: meson: g12a: fix gp0 and hifi ranges
|
||||
|
||||
While some SoC samples are able to lock with a PLL factor of 55, others
|
||||
samples can't. ATM, a minimum of 60 appears to work on all the samples
|
||||
I have tried.
|
||||
|
||||
Even with 60, it sometimes takes a long time for the PLL to eventually
|
||||
lock. The documentation says that the minimum rate of these PLLs DCO
|
||||
should be 3GHz, a factor of 125. Let's use that to be on the safe side.
|
||||
|
||||
With factor range changed, the PLL seems to lock quickly (enough) so far.
|
||||
It is still unclear if the range was the only reason for the delay.
|
||||
|
||||
Fixes: 085a4ea93d54 ("clk: meson: g12a: add peripheral clock controller")
|
||||
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
|
||||
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
|
||||
---
|
||||
drivers/clk/meson/g12a.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/drivers/clk/meson/g12a.c b/drivers/clk/meson/g12a.c
|
||||
index b3af61cc6fb9..66cf791bfc8c 100644
|
||||
--- a/drivers/clk/meson/g12a.c
|
||||
+++ b/drivers/clk/meson/g12a.c
|
||||
@@ -1591,7 +1591,7 @@ static struct clk_regmap g12b_cpub_clk_trace = {
|
||||
};
|
||||
|
||||
static const struct pll_mult_range g12a_gp0_pll_mult_range = {
|
||||
- .min = 55,
|
||||
+ .min = 125,
|
||||
.max = 255,
|
||||
};
|
||||
|
||||
--
|
||||
2.17.1
|
||||
|
@ -24,7 +24,6 @@ define BLUETOOTH_BCM43XX_INSTALL_TARGET_CMDS
|
||||
$(INSTALL) -d $(TARGET_DIR)/etc/systemd/system/hassos-hardware.target.wants
|
||||
$(INSTALL) -m 0644 $(@D)/bluetooth-bcm43xx.service $(TARGET_DIR)/usr/lib/systemd/system/
|
||||
$(INSTALL) -m 0644 $(@D)/bthelper@.service $(TARGET_DIR)/usr/lib/systemd/system/
|
||||
ln -fs /usr/lib/systemd/system/bluetooth-bcm43xx.service $(TARGET_DIR)/etc/systemd/system/hassos-hardware.target.wants/
|
||||
|
||||
$(INSTALL) -d $(TARGET_DIR)/usr/bin
|
||||
$(INSTALL) -m 0755 $(@D)/btuart $(TARGET_DIR)/usr/bin/
|
||||
|
@ -21,7 +21,6 @@ define BLUETOOTH_RTL8723_INSTALL_TARGET_CMDS
|
||||
$(INSTALL) -d $(TARGET_DIR)/etc/systemd/system/hassos-hardware.target.wants
|
||||
$(INSTALL) -m 0755 $(@D)/bluetooth-rtl8723 $(TARGET_DIR)/usr/sbin/
|
||||
$(INSTALL) -m 0644 $(@D)/bluetooth-rtl8723.service $(TARGET_DIR)/usr/lib/systemd/system/
|
||||
ln -fs /usr/lib/systemd/system/bluetooth-rtl8723.service $(TARGET_DIR)/etc/systemd/system/hassos-hardware.target.wants/
|
||||
|
||||
$(INSTALL) -d $(TARGET_DIR)/lib/firmware/rtlbt
|
||||
$(INSTALL) -m 0644 $(@D)/rtl8723b_* $(TARGET_DIR)/lib/firmware/rtlbt/
|
||||
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/etc-NetworkManager-system\x2dconnections.mount
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/etc-docker.mount
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/etc-dropbear.mount
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/etc-hostname.mount
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/etc-hosts.mount
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/etc-modules\x2dload.d.mount
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/etc-systemd-timesyncd.conf.mount
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/etc-udev-rules.d.mount
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/hassos-user-rules-udev-trigger.service
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/root-.docker.mount
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/root-.ssh.mount
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/var-lib-NetworkManager.mount
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/var-lib-bluetooth.mount
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/var-lib-docker.mount
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/var-lib-systemd.mount
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/var-log-journal.mount
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/zram-swap.service
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/zram-tmp.service
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/zram-var.service
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/hassos-expand.service
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/hassos-overlay.service
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/mnt-boot.mount
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/mnt-data.mount
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/mnt-overlay.mount
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/busybox-acpid.service
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/hassos-apparmor.service
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/hassos-bind.target
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/hassos-config.service
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/hassos-hardware.target
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/hassos-persists.service
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/hassos-supervisor.service
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/hassos-zram.target
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/rauc.service
|
@ -1 +0,0 @@
|
||||
/usr/lib/systemd/system/dev-zram0.swap
|
31
buildroot-external/rootfs-overlay/usr/bin/datactl
Executable file
31
buildroot-external/rootfs-overlay/usr/bin/datactl
Executable file
@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
# ==============================================================================
|
||||
# HassOS data partition handling
|
||||
# ==============================================================================
|
||||
set -e
|
||||
|
||||
OPTION_FILE=/mnt/overlay/data.opt
|
||||
DATA_DEVICE_CHILD="$(findfs LABEL="hassos-data")"
|
||||
DATA_DEVICE_ROOT="/dev/$(lsblk -no pkname "${DATA_DEVICE_CHILD}")"
|
||||
|
||||
# Move command
|
||||
if [ "${1}" = "move" ] && [ -e "${2}" ]; then
|
||||
DEVICE="${2}"
|
||||
|
||||
# Check device
|
||||
if ! lsblk "${DEVICE}" | grep disk > /dev/null 2>&1; then
|
||||
echo "[ERROR] Is not disk!"
|
||||
exit 1
|
||||
elif [ "${DEVICE}" = "${DATA_DEVICE_ROOT}" ]; then
|
||||
echo "[ERROR] Can't be the same disk!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Flag device
|
||||
echo "WARNING: ${DEVICE} will be reset on next restart!"
|
||||
echo "Press a key to move forward"
|
||||
read -r
|
||||
|
||||
echo "${DEVICE}" > ${OPTION_FILE}
|
||||
fi
|
||||
|
@ -2,3 +2,6 @@
|
||||
Description=HassOS overlay targets
|
||||
Documentation=man:systemd.target(5)
|
||||
Before=sysinit.target
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
@ -0,0 +1,17 @@
|
||||
[Unit]
|
||||
Description=HassOS data partition
|
||||
DefaultDependencies=no
|
||||
RefuseManualStart=true
|
||||
RefuseManualStop=true
|
||||
Requires=mnt-overlay.mount dev-disk-by\x2dlabel-hassos\x2ddata.device
|
||||
Wants=hassos-expand.service
|
||||
After=mnt-overlay.mount dev-disk-by\x2dlabel-hassos\x2ddata.device
|
||||
Before=hassos-expand.service
|
||||
ConditionPathExists=/mnt/overlay/data.opt
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/libexec/hassos-data
|
||||
|
||||
[Install]
|
||||
WantedBy=local-fs.target
|
@ -10,7 +10,6 @@ After=dev-disk-by\x2dlabel-hassos\x2ddata.device
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/libexec/hassos-expand
|
||||
RemainAfterExit=true
|
||||
|
||||
[Install]
|
||||
WantedBy=local-fs.target
|
||||
|
@ -1,3 +1,6 @@
|
||||
[Unit]
|
||||
Description=HassOS hardware targets
|
||||
Documentation=man:systemd.target(5)
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
@ -1,3 +1,6 @@
|
||||
[Unit]
|
||||
Description=HassOS zram targets
|
||||
Documentation=man:systemd.target(5)
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
68
buildroot-external/rootfs-overlay/usr/libexec/hassos-data
Executable file
68
buildroot-external/rootfs-overlay/usr/libexec/hassos-data
Executable file
@ -0,0 +1,68 @@
|
||||
#!/bin/sh
|
||||
# shellcheck disable=SC2039
|
||||
# ==============================================================================
|
||||
# HassOS data partition handler
|
||||
# ==============================================================================
|
||||
set -e
|
||||
|
||||
OPTION_FILE=/mnt/overlay/data.opt
|
||||
|
||||
# New data partition exits
|
||||
if ! [ -e "${OPTION_FILE}" ]; then
|
||||
echo "[INFO] No data option found"
|
||||
exit 0
|
||||
else
|
||||
NEW_DEVICE_ROOT="$(cat ${OPTION_FILE})"
|
||||
rm ${OPTION_FILE}
|
||||
fi
|
||||
|
||||
# Get device information
|
||||
OLD_DEVICE_CHILD="$(findfs LABEL="hassos-data")"
|
||||
OLD_DEVICE_ROOT="/dev/$(lsblk -no pkname "${OLD_DEVICE_CHILD}")"
|
||||
OLD_PART_NUM="${OLD_DEVICE_CHILD: -1}"
|
||||
|
||||
# Create new partition
|
||||
echo "[INFO] Create new hassos-data partition"
|
||||
sgdisk -o "${NEW_DEVICE_ROOT}"
|
||||
sgdisk \
|
||||
-n "0:0:0" \
|
||||
-c "0:hassos-data" \
|
||||
-t "0:0FC63DAF-8483-4772-8E79-3D69D8477DE4" \
|
||||
-u "0:a52a4597-fa3a-4851-aefd-2fbe9f849079" \
|
||||
"${NEW_DEVICE_ROOT}"
|
||||
sgdisk -v "${NEW_DEVICE_ROOT}"
|
||||
partx -u "${NEW_DEVICE_ROOT}"
|
||||
|
||||
NEW_DEVICE_CHILD="$(fdisk -l "${NEW_DEVICE_ROOT}" | grep '^/dev' | cut -d' ' -f1 | head -n 1)"
|
||||
|
||||
echo "[INFO] Move hassos-data from ${OLD_DEVICE_CHILD} to ${NEW_DEVICE_CHILD}"
|
||||
if ! dd if="${OLD_DEVICE_CHILD}" of="${NEW_DEVICE_CHILD}" status=none; then
|
||||
echo "[ERROR] Data copy fails!"
|
||||
|
||||
# Reset new data partition
|
||||
sgdisk -o "${NEW_DEVICE_ROOT}"
|
||||
partx -u "${NEW_DEVICE_ROOT}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[INFO] Remove old hassos-data partition ${OLD_PART_NUM} / ${OLD_DEVICE_ROOT}"
|
||||
if sfdisk -dq "${OLD_DEVICE_ROOT}" | grep -q 'label: gpt'; then
|
||||
sgdisk -d "${OLD_PART_NUM}" "${OLD_DEVICE_ROOT}"
|
||||
sgdisk -v "${OLD_DEVICE_ROOT}"
|
||||
|
||||
else
|
||||
sfdisk --delete "${OLD_PART_NUM}" "${OLD_DEVICE_ROOT}" --force
|
||||
sfdisk -V "${OLD_DEVICE_ROOT}"
|
||||
fi
|
||||
|
||||
echo "[INFO] fix filesystem & layout"
|
||||
|
||||
# Fix filesystem
|
||||
e2fsck -y "${NEW_DEVICE_CHILD}"
|
||||
resize2fs -f "${NEW_DEVICE_CHILD}"
|
||||
|
||||
# Fix partition layout
|
||||
partx -d "${OLD_DEVICE_CHILD}"
|
||||
partx -u "${NEW_DEVICE_ROOT}"
|
||||
|
||||
echo "[INFO] Finish hassos data movement"
|
@ -1,5 +1,8 @@
|
||||
#!/bin/sh
|
||||
# shellcheck disable=SC2039
|
||||
# ==============================================================================
|
||||
# HassOS partition expander
|
||||
# ==============================================================================
|
||||
set -e
|
||||
|
||||
DEVICE_CHILD="$(findfs LABEL="hassos-data")"
|
||||
@ -13,11 +16,15 @@ if [ -z "${UNUSED}" ] || [ "${UNUSED}" -le "2048" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "[INFO] Update hassos-data partition ${PART_NUM}"
|
||||
if sfdisk -dq "${DEVICE_ROOT}" | grep -q 'label: gpt'; then
|
||||
# Resize & Reload partition
|
||||
echo "[INFO] Update hassos-data partition ${PART_NUM}"
|
||||
sgdisk -e "${DEVICE_ROOT}"
|
||||
sgdisk -d "${PART_NUM}" -n "${PART_NUM}:0:0" -c "${PART_NUM}:hassos-data" -t "${PART_NUM}:0FC63DAF-8483-4772-8E79-3D69D8477DE4" -u "${PART_NUM}:a52a4597-fa3a-4851-aefd-2fbe9f849079" "${DEVICE_ROOT}"
|
||||
sgdisk -d "${PART_NUM}" \
|
||||
-n "${PART_NUM}:0:0" \
|
||||
-c "${PART_NUM}:hassos-data" \
|
||||
-t "${PART_NUM}:0FC63DAF-8483-4772-8E79-3D69D8477DE4" \
|
||||
-u "${PART_NUM}:a52a4597-fa3a-4851-aefd-2fbe9f849079" \
|
||||
"${DEVICE_ROOT}"
|
||||
sgdisk -v "${DEVICE_ROOT}"
|
||||
else
|
||||
echo ", +" | sfdisk -N "${PART_NUM}" "${DEVICE_ROOT}" --force
|
||||
|
@ -9,10 +9,10 @@ if [ -e /usr/sbin/fw_setenv ]; then
|
||||
|
||||
# machine-id
|
||||
if [ "$(fw_printenv -n MACHINE_ID)" != "${MACHINE_ID}" ]; then
|
||||
echo "[info] set machine-id to ${MACHINE_ID}"
|
||||
echo "[INFO] set machine-id to ${MACHINE_ID}"
|
||||
fw_setenv MACHINE_ID "${MACHINE_ID}"
|
||||
else
|
||||
echo "[info] machine-id is okay"
|
||||
echo "[INFO] machine-id is okay"
|
||||
fi
|
||||
|
||||
###
|
||||
@ -21,10 +21,10 @@ else
|
||||
|
||||
# machine-id
|
||||
if [ "$(barebox-state -g state.machine_id -i /etc/barebox-state.dtb)" != "${MACHINE_ID}" ]; then
|
||||
echo "[info] set machine-id to ${MACHINE_ID}"
|
||||
echo "[INFO] set machine-id to ${MACHINE_ID}"
|
||||
barebox-state -s "state.machine_id=${MACHINE_ID}" -i /etc/barebox-state.dtb
|
||||
else
|
||||
echo "[info] machine-id is okay"
|
||||
echo "[INFO] machine-id is okay"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
@ -45,3 +45,6 @@ install_hassos_cli
|
||||
write_rauc_config
|
||||
install_rauc_certs
|
||||
install_bootloader_config
|
||||
|
||||
# Fix overlay presets
|
||||
"${HOST_DIR}/bin/systemctl" --root="${TARGET_DIR}" preset-all
|
||||
|
Loading…
x
Reference in New Issue
Block a user