Initial commit from Ventoy@7cbdc5c
This commit is contained in:
@@ -0,0 +1,150 @@
|
||||
# Copyright (C) 2009 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This file is part of LVM2.
|
||||
|
||||
# Udev rules for device-mapper devices.
|
||||
#
|
||||
# These rules create a DM control node in /dev/mapper directory.
|
||||
# The rules also create nodes named dm-x (x is a number) in /dev
|
||||
# directory and symlinks to these nodes with names given by
|
||||
# the actual DM names. Some udev environment variables are set
|
||||
# for use in later rules:
|
||||
# DM_NAME - actual DM device's name
|
||||
# DM_UUID - UUID set for DM device (blank if not specified)
|
||||
# DM_SUSPENDED - suspended state of DM device (0 or 1)
|
||||
# DM_UDEV_RULES_VSN - DM udev rules version
|
||||
#
|
||||
# These rules cover only basic device-mapper functionality in udev.
|
||||
#
|
||||
# Various DM subsystems may contain further subsystem-specific rules
|
||||
# in 11-dm-<subsystem_name>.rules which should be installed together
|
||||
# with the DM subsystem and which extend these basic rules.
|
||||
# For example:
|
||||
# 11-dm-lvm.rules for LVM subsystem
|
||||
# 11-dm-mpath.rules for multipath subsystem (since version 0.6.0, recommended!)
|
||||
#
|
||||
# Even more specific rules may be required by subsystems so always
|
||||
# check subsystem's upstream repository for recent set of rules.
|
||||
# Also, keep in mind that recent rules may also require recent
|
||||
# subsystem-specific binaries.
|
||||
|
||||
KERNEL=="device-mapper", NAME="mapper/control"
|
||||
|
||||
SUBSYSTEM!="block", GOTO="dm_end"
|
||||
KERNEL!="dm-[0-9]*", GOTO="dm_end"
|
||||
|
||||
|
||||
# Device created, major and minor number assigned - "add" event generated.
|
||||
# Table loaded - no event generated.
|
||||
# Device resumed (or renamed) - "change" event generated.
|
||||
# Device removed - "remove" event generated.
|
||||
#
|
||||
# The dm-X nodes are always created, even on "add" event, we can't suppress
|
||||
# that (the node is created even earlier with devtmpfs). All the symlinks
|
||||
# (e.g. /dev/mapper) are created in right time after a device has its table
|
||||
# loaded and is properly resumed. For this reason, direct use of dm-X nodes
|
||||
# is not recommended.
|
||||
ACTION!="add|change", GOTO="dm_end"
|
||||
|
||||
# Decode udev control flags and set environment variables appropriately.
|
||||
# These flags are encoded in DM_COOKIE variable that was introduced in
|
||||
# kernel version 2.6.31. Therefore, we can use this feature with
|
||||
# kernels >= 2.6.31 only. Cookie is not decoded for remove event.
|
||||
ENV{DM_COOKIE}=="?*", IMPORT{program}="/usr/sbin/dmsetup udevflags $env{DM_COOKIE}"
|
||||
|
||||
# Rule out easy-to-detect inappropriate events first.
|
||||
ENV{DISK_RO}=="1", GOTO="dm_disable"
|
||||
|
||||
# There is no cookie set nor any flags encoded in events not originating
|
||||
# in libdevmapper so we need to detect this and try to behave correctly.
|
||||
# For such spurious events, regenerate all flags from current udev database content
|
||||
# (this information would normally be inaccessible for spurious ADD and CHANGE events).
|
||||
ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}=="1", ENV{DM_ACTIVATION}="1", GOTO="dm_flags_done"
|
||||
IMPORT{db}="DM_UDEV_DISABLE_DM_RULES_FLAG"
|
||||
IMPORT{db}="DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG"
|
||||
IMPORT{db}="DM_UDEV_DISABLE_DISK_RULES_FLAG"
|
||||
IMPORT{db}="DM_UDEV_DISABLE_OTHER_RULES_FLAG"
|
||||
IMPORT{db}="DM_UDEV_LOW_PRIORITY_FLAG"
|
||||
IMPORT{db}="DM_UDEV_DISABLE_LIBRARY_FALLBACK_FLAG"
|
||||
IMPORT{db}="DM_UDEV_PRIMARY_SOURCE_FLAG"
|
||||
IMPORT{db}="DM_UDEV_FLAG7"
|
||||
IMPORT{db}="DM_UDEV_RULES_VSN"
|
||||
LABEL="dm_flags_done"
|
||||
|
||||
# Normally, we operate on "change" events. But when coldplugging, there's an
|
||||
# "add" event present. We have to recognize this and do our actions in this
|
||||
# particular situation, too. Also, we don't want the nodes to be created
|
||||
# prematurely on "add" events while not coldplugging. We check
|
||||
# DM_UDEV_PRIMARY_SOURCE_FLAG to see if the device was activated correctly
|
||||
# before and if not, we ignore the "add" event totally. This way we can support
|
||||
# udev triggers generating "add" events (e.g. "udevadm trigger --action=add" or
|
||||
# "echo add > /sys/block/<dm_device>/uevent"). The trigger with "add" event is
|
||||
# also used at boot to reevaluate udev rules for all existing devices activated
|
||||
# before (e.g. in initrd). If udev is used in initrd, we require the udev init
|
||||
# script to not remove the existing udev database so we can reuse the information
|
||||
# stored at the time of device activation in the initrd.
|
||||
ACTION!="add", GOTO="dm_no_coldplug"
|
||||
ENV{DM_UDEV_RULES_VSN}!="1", ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}!="1", GOTO="dm_disable"
|
||||
ENV{DM_ACTIVATION}="1"
|
||||
LABEL="dm_no_coldplug"
|
||||
|
||||
# Putting it together, following table is used to recognize genuine and spurious events.
|
||||
# N.B. Spurious events are generated based on use of the WATCH udev
|
||||
# rule or by triggering an event manually by "udevadm trigger" call
|
||||
# or by "echo <event_name> > /sys/block/dm-X/uevent".
|
||||
#
|
||||
# EVENT DM_UDEV_PRIMARY_SOURCE_FLAG DM_ACTIVATION
|
||||
# ======================================================================
|
||||
# add event (genuine) 0 0
|
||||
# change event (genuine) 1 1
|
||||
# add event (spurious)
|
||||
# |_ dev still not active 0 0
|
||||
# \_ dev already active 1 1
|
||||
# change event (spurious)
|
||||
# |_ dev still not active 0 0
|
||||
# \_ dev already active 1 0
|
||||
|
||||
# "dm" sysfs subdirectory is available in newer versions of DM
|
||||
# only (kernels >= 2.6.29). We have to check for its existence
|
||||
# and use dmsetup tool instead to get the DM name, uuid and
|
||||
# suspended state if the "dm" subdirectory is not present.
|
||||
# The "suspended" item was added even later (kernels >= 2.6.31),
|
||||
# so we also have to call dmsetup if the kernel version used
|
||||
# is in between these releases.
|
||||
TEST=="dm", ENV{DM_NAME}="$attr{dm/name}", ENV{DM_UUID}="$attr{dm/uuid}", ENV{DM_SUSPENDED}="$attr{dm/suspended}"
|
||||
TEST!="dm", IMPORT{program}="/usr/sbin/dmsetup info -j %M -m %m -c --nameprefixes --noheadings --rows -o name,uuid,suspended"
|
||||
ENV{DM_SUSPENDED}!="?*", IMPORT{program}="/usr/sbin/dmsetup info -j %M -m %m -c --nameprefixes --noheadings --rows -o suspended"
|
||||
|
||||
# dmsetup tool provides suspended state information in textual
|
||||
# form with values "Suspended"/"Active". We translate it to
|
||||
# 0/1 respectively to be consistent with sysfs values.
|
||||
ENV{DM_SUSPENDED}=="Active", ENV{DM_SUSPENDED}="0"
|
||||
ENV{DM_SUSPENDED}=="Suspended", ENV{DM_SUSPENDED}="1"
|
||||
|
||||
# This variable provides a reliable way to check that device-mapper
|
||||
# rules were installed. It means that all needed variables are set
|
||||
# by these rules directly so there's no need to acquire them again
|
||||
# later. Other rules can alternate the functionality based on this
|
||||
# fact (e.g. fallback to rules that behave correctly even without
|
||||
# these rules installed). It also provides versioning for any
|
||||
# possible future changes.
|
||||
# VSN 1 - original rules
|
||||
# VSN 2 - add support for synthesized events
|
||||
ENV{DM_UDEV_RULES_VSN}="2"
|
||||
|
||||
ENV{DM_UDEV_DISABLE_DM_RULES_FLAG}!="1", ENV{DM_NAME}=="?*", SYMLINK+="mapper/$env{DM_NAME}"
|
||||
|
||||
# Avoid processing and scanning a DM device in the other (foreign)
|
||||
# rules if it is in suspended state. However, we still keep 'disk'
|
||||
# and 'DM subsystem' related rules enabled in this case.
|
||||
ENV{DM_SUSPENDED}=="1", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1"
|
||||
|
||||
GOTO="dm_end"
|
||||
|
||||
LABEL="dm_disable"
|
||||
ENV{DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG}="1"
|
||||
ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}="1"
|
||||
ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1"
|
||||
OPTIONS:="nowatch"
|
||||
|
||||
LABEL="dm_end"
|
||||
@@ -0,0 +1,42 @@
|
||||
# Copyright (C) 2009 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This file is part of LVM2.
|
||||
|
||||
# Udev rules for device-mapper devices.
|
||||
#
|
||||
# These rules create symlinks in /dev/disk directory.
|
||||
# Symlinks that depend on probing filesystem type,
|
||||
# label and uuid are created only if the device is not
|
||||
# suspended.
|
||||
|
||||
# "add" event is processed on coldplug only!
|
||||
ACTION!="add|change", GOTO="dm_end"
|
||||
ENV{DM_UDEV_RULES_VSN}!="?*", GOTO="dm_end"
|
||||
ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}=="1", GOTO="dm_end"
|
||||
|
||||
SYMLINK+="disk/by-id/dm-name-$env{DM_NAME}"
|
||||
ENV{DM_UUID}=="?*", SYMLINK+="disk/by-id/dm-uuid-$env{DM_UUID}"
|
||||
|
||||
ENV{DM_SUSPENDED}=="1", GOTO="dm_end"
|
||||
ENV{DM_NOSCAN}=="1", GOTO="dm_watch"
|
||||
|
||||
IMPORT{builtin}="blkid"
|
||||
ENV{DM_UDEV_LOW_PRIORITY_FLAG}=="1", OPTIONS="link_priority=-100"
|
||||
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_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}"
|
||||
ENV{ID_PART_ENTRY_UUID}=="?*", SYMLINK+="disk/by-partuuid/$env{ID_PART_ENTRY_UUID}"
|
||||
ENV{ID_PART_ENTRY_SCHEME}=="gpt", ENV{ID_PART_ENTRY_NAME}=="?*", SYMLINK+="disk/by-partlabel/$env{ID_PART_ENTRY_NAME}"
|
||||
ENV{ID_PART_ENTRY_SCHEME}=="gpt", ENV{ID_PART_GPT_AUTO_ROOT}=="1", SYMLINK+="gpt-auto-root"
|
||||
|
||||
# Add inotify watch to track changes on this device.
|
||||
# Using the watch rule is not optimal - it generates a lot of spurious
|
||||
# and useless events whenever the device opened for read-write is closed.
|
||||
# The best would be to generete the event directly in the tool changing
|
||||
# relevant information so only relevant events will be processed
|
||||
# (like creating a filesystem, changing filesystem label etc.).
|
||||
#
|
||||
# But let's use this until we have something better...
|
||||
LABEL="dm_watch"
|
||||
OPTIONS+="watch"
|
||||
|
||||
LABEL="dm_end"
|
||||
@@ -0,0 +1,53 @@
|
||||
#!/bin/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2022, longpanda <[email protected]>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
PATH=$PATH:/ventoy/busybox:/ventoy/tool
|
||||
|
||||
vlog() {
|
||||
echo "$@" >> /ventoy/autoinstall.log
|
||||
}
|
||||
|
||||
if grep -q '\$\$VT_' /ventoy/autoinstall; then
|
||||
vlog "======== auto install variables expansion ======="
|
||||
else
|
||||
vlog "======== auto install variables expansion no need ======="
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -f /ventoy/ventoy_os_param ]; then
|
||||
VTOYDISK=$(vtoydump -f /ventoy/ventoy_os_param | awk -F'#' '{print $1}')
|
||||
vlog VTOYDISK=$VTOYDISK
|
||||
|
||||
if [ -b "$VTOYDISK" ]; then
|
||||
vlog "$VTOYDISK exist OK"
|
||||
else
|
||||
vlog "$VTOYDISK does NOT exist"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -n "$1" -a -f "$1" ]; then
|
||||
vtoyexpand "$1" "$VTOYDISK"
|
||||
else
|
||||
vlog "File $1 not exist"
|
||||
fi
|
||||
else
|
||||
vlog "os param file not exist"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
preseed/file
|
||||
debian-installer/locale
|
||||
console-keymaps-at/keymap
|
||||
keyboard-configuration/xkb-keymap
|
||||
keyboard-configuration/layout
|
||||
simple-cdd/profiles
|
||||
vga
|
||||
@@ -0,0 +1,30 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <[email protected]>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
if is_ventoy_hook_finished || not_ventoy_disk "${1:0:-1}"; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ventoy_udev_disk_common_hook $*
|
||||
|
||||
# OK finish
|
||||
set_ventoy_hook_finish
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <[email protected]>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
ventoy_systemd_udevd_work_around
|
||||
|
||||
ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k"
|
||||
|
||||
if [ -f /init ]; then
|
||||
vtSize=$($BUSYBOX_PATH/stat -c '%s' /init)
|
||||
if ! [ -L /init ]; then
|
||||
if [ $vtSize -eq 0 ]; then
|
||||
rm -f /init
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
@@ -0,0 +1,31 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <[email protected]>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
vtHook=$($CAT $VTOY_PATH/inotifyd-hook-script.txt)
|
||||
|
||||
vtdisk=$(get_ventoy_disk_name)
|
||||
if [ "$vtdisk" = "unknown" ]; then
|
||||
vtlog "... start inotifyd listen $vtHook ..."
|
||||
$BUSYBOX_PATH/nohup $VTOY_PATH/tool/inotifyd $vtHook /dev:n 2>&- &
|
||||
else
|
||||
vtlog "... $vtdisk already exist ..."
|
||||
$BUSYBOX_PATH/sh $vtHook n /dev "${vtdisk#/dev/}2"
|
||||
fi
|
||||
Reference in New Issue
Block a user