* 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 <[email protected]>
include $(TOPDIR)/rules.mk
PKG_NAME:=uvol
-PKG_VERSION:=0.5
+PKG_VERSION:=0.6
PKG_RELEASE:=$(AUTORELEASE)
$(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))
uuid="${uuid:5}"
case "$uciname" in
- "_uxc")
- target="/var/run/uxc"
+ "_meta")
+ target="/var/run/uvol/.meta"
;;
"_"*)
return 1
local volname="$1"
local uciname
- uciname="${volname//-/_}"
+ uciname="${volname//[-.]/_}"
uciname="${uciname//[!([:alnum:]_)]}"
if [ -e "${UCI_SPOOLDIR}/add-$1" ]; then
rm "${UCI_SPOOLDIR}/add-$1"
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
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
}
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{"
}
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
esac
volmode="${volname:5:2}"
volname="${volname:8}"
+ [ "${volname:0:1}" = "." ] && continue
if [ "$json_output" = "1" ]; then
[ "$json_notfirst" = "1" ] && echo ","
echo -e "\t{"
#!/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