uvol: update to 0.6

* auto-created meta volume
Automatically create volume '.meta' sized 0.01% of the total space
managed by uvol, the minimum size being 4 MiB.
This volume should be used to keep metadata about stored volumes, such
as container runtime configuration (in /var/run/uvol/.meta/uxc) or
the database of installed container packages.

 * configurable LVM volume group
Allow setting volume group to be used by uvol using UCI.
This is useful on devices which do not boot off the device which
should be used for uvol and hence cannot make use of autopart and
physical volume detection based on kernel cmdline.
Use option vg_name in uvol section of fstab UCI config package.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
This commit is contained in:
Daniel Golle 2021-12-19 23:13:58 +00:00
parent 6243a17250
commit f8f5960e76
No known key found for this signature in database
GPG Key ID: 5A8F39C31C3217CA
5 changed files with 29 additions and 9 deletions

View File

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=uvol
PKG_VERSION:=0.5
PKG_VERSION:=0.6
PKG_RELEASE:=$(AUTORELEASE)
PKG_MAINTAINER:=Daniel Golle <daniel@makrotopia.org>
@ -70,7 +70,7 @@ define Package/uvol/install
$(INSTALL_BIN) ./files/ubi.sh $(1)/usr/libexec/uvol/20-ubi.sh
$(INSTALL_BIN) ./files/lvm.sh $(1)/usr/libexec/uvol/50-lvm.sh
$(INSTALL_BIN) ./files/uvol $(1)/usr/sbin
$(INSTALL_BIN) ./files/uvol.defaults $(1)/etc/uci-defaults/90-uvol-restore-uci
$(INSTALL_BIN) ./files/uvol.defaults $(1)/etc/uci-defaults/90-uvol-init
endef
$(eval $(call BuildPackage,autopart))

View File

@ -23,8 +23,8 @@ uvol_uci_add() {
uuid="${uuid:5}"
case "$uciname" in
"_uxc")
target="/var/run/uxc"
"_meta")
target="/var/run/uvol/.meta"
;;
"_"*)
return 1
@ -50,7 +50,7 @@ uvol_uci_remove() {
local volname="$1"
local uciname
uciname="${volname//-/_}"
uciname="${volname//[-.]/_}"
uciname="${uciname//[!([:alnum:]_)]}"
if [ -e "${UCI_SPOOLDIR}/add-$1" ]; then
rm "${UCI_SPOOLDIR}/add-$1"

View File

@ -62,8 +62,12 @@ existvol() {
vg_name=
exportpv() {
local reports rep pv pvs
vg_name=
config_load fstab
local uvolsect="$(config_foreach echo uvol)"
[ -n "$uvolsect" ] && config_get vg_name "$uvolsect" vg_name
[ -n "$vg_name" ] && return
local reports rep pv pvs
json_init
json_load "$(pvs -o vg_name -S "pv_name=~^/dev/$rootdev.*\$")"
json_select report
@ -152,7 +156,7 @@ getdev() {
for dms in /sys/devices/virtual/block/dm-* ; do
[ "$dms" = "/sys/devices/virtual/block/dm-*" ] && break
read -r dm_name < "$dms/dm/name"
[ $(basename "$lv_dm_path") = "$dm_name" ] && echo "$(basename "$dms")"
[ "$(basename "$lv_dm_path")" = "$dm_name" ] && basename "$dms"
done
}
@ -316,6 +320,7 @@ listvols() {
lv_mode="${lv_name:0:2}"
lv_name="${lv_name:3}"
lv_size=${lv_size%B}
[ "${lv_name:0:1}" = "." ] && continue
if [ "$json_output" = "1" ]; then
[ "$json_notfirst" = "1" ] && echo ","
echo -e "\t{"
@ -340,7 +345,7 @@ listvols() {
}
detect() {
local reports rep lv lvs lv_name lv_full_name lv_mode volname devname lv_skip_activation
local reports rep lv lvs lv_name lv_full_name lv_mode volname devname
local temp_up=""
json_init

View File

@ -212,6 +212,7 @@ listvols() {
esac
volmode="${volname:5:2}"
volname="${volname:8}"
[ "${volname:0:1}" = "." ] && continue
if [ "$json_output" = "1" ]; then
[ "$json_notfirst" = "1" ] && echo ","
echo -e "\t{"

View File

@ -1,3 +1,17 @@
#!/bin/sh
uci -q get fstab.@uvol[0].initialized >/dev/null || uvol detect || true
uvol_init() {
local metasz freesz totalsz
uvol detect
metasz="$(uvol size .meta 2>/dev/null)"
[ "$((metasz))" -gt 0 ] && return
totalsz="$(uvol total)"
freesz="$(uvol free)"
metasz="$((totalsz / 10240))"
[ "$metasz" -lt 4194304 ] && metasz=4194304
[ "$metasz" -gt "$freesz" ] && return
uvol create .meta "$metasz" rw
uvol up .meta
}
uci -q get fstab.@uvol[0].initialized >/dev/null || uvol_init