-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Integrated P2V patch from Heinlein Support. We start with 1.9 now to
reflect the new feature in the version. * Migrate disk and network configuration if HW changed * Adjust drivers and initrd/initramfs * Adjust swap space with by-id mounting (only swap ATM) * Read mapping files in /etc/rear/mapping with answers instead of asking during recovery * Run PRE_RECOVERY_SCRIPT and POST_RECOVERY_SCRIPT scripts as a hook for user-supplied stuff * Changed the rescue system startup code to be a directory of shell snippets (/etc/scripts/system-setup.d) * recreate some FS attributes for ext* * recreate vfat - Added AddExitTask/RemoveExitTask functions to handle several exit tasks (e.g. umount NETFS share) - Added shell workflow to enter a ReaR shell where one can use all ReaR functions and source scriptlets
- Loading branch information
Showing
57 changed files
with
1,377 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
GSS Schlomo Schapiro | ||
GD Gratien D'haese | ||
GSS Schlomo Schapiro | ||
GD Gratien D'haese | ||
SSE Stefan Semmelroggen | ||
PHEI Peer Heinlein |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
* finalize/Fedora/i386/17_rebuild_initramfs.sh | ||
- needs to be written, seems like RH builds rich initramfs with all modules included | ||
|
||
* finalize/Gentoo/i386/17_rebuild_initramfs.sh | ||
- needs to be written, I have no idea what should be done here (since I don't have Gentoo) | ||
|
||
* write network migration code for all other distributions | ||
|
||
* support dhcp for network migration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
# | ||
# debian has to do everything different from all other Linux systems ... | ||
|
||
test -x "$(type -p lilo.real)" && { | ||
if test -x "$(type -p lilo.real)" ; then | ||
cp -af "$(type -p lilo.real)" $ROOTFS_DIR/bin/lilo | ||
cp -a /lib/libdevmapper* $ROOTFS_DIR/lib/ | ||
} | ||
fi | ||
|
||
test -x "$(type -p lvmiopversion)" && { | ||
if test -x "$(type -p lvmiopversion)" ; then | ||
cp -af /lib/lvm-* $ROOTFS_DIR/lib/ | ||
cp -af /sbin/lvm* $ROOTFS_DIR/bin/ | ||
} | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
usr/share/rear/build/GNU/Linux/60_verify_and_adjust_udev.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# verify that all required components for udev are present | ||
# | ||
|
||
# skip this script if udev is not part of the rescue system | ||
test -d $ROOTFS_DIR/etc/udev/rules.d || return 0 | ||
|
||
ProgressStart "Checking udev" | ||
# check that all external programs used by udev are available | ||
while read file location ; do | ||
# check for file in ROOTFS_DIR (if full path) or in lib/udev or in bin (if name without path) | ||
if test -x $ROOTFS_DIR/$file -o \ | ||
-x $ROOTFS_DIR/lib/udev/$file -o \ | ||
-x $ROOTFS_DIR/bin/$file ; then | ||
# everything is fine | ||
# Log "matched external call to $file in $location" | ||
echo "matched external call to $file in $location" 1>&8 | ||
else | ||
ProgressStep | ||
Log "WARNING: unmatched external call to '$file' in $location" | ||
fi | ||
done < <( | ||
# get list of external files called in PROGRAM= or RUN= statements. The result is filtered | ||
# for files (no $env{...} or socket: stuff) and looks like this: | ||
# /bin/sed etc/udev/rules.d/56-sane-backends-autoconfig.rules:289 | ||
# ata_id etc/udev/rules.d/60-persistent-storage.rules:39 | ||
# /sbin/kpartx etc/udev/rules.d/70-kpartx.rules:38 | ||
# /sbin/kpartx etc/udev/rules.d/70-kpartx.rules:40 | ||
# /sbin/kpartx etc/udev/rules.d/70-kpartx.rules:42 | ||
# write_cd_rules etc/udev/rules.d/75-cd-aliases-generator.rules:4 | ||
# write_cd_rules etc/udev/rules.d/75-cd-aliases-generator.rules:6 | ||
# ipw3945d.sh etc/udev/rules.d/77-network.rules:3 | ||
# /sbin/ifup etc/udev/rules.d/77-network.rules:12 | ||
# /sbin/ifdown etc/udev/rules.d/77-network.rules:13 | ||
# /sbin/modprobe etc/udev/rules.d/80-drivers.rules:8 | ||
# /sbin/modprobe etc/udev/rules.d/80-drivers.rules:9 | ||
# /sbin/modprobe etc/udev/rules.d/80-drivers.rules:10 | ||
# /sbin/modprobe etc/udev/rules.d/80-drivers.rules:11 | ||
# /sbin/modprobe etc/udev/rules.d/80-drivers.rules:12 | ||
# /sbin/modprobe etc/udev/rules.d/80-drivers.rules:13 | ||
# /sbin/modprobe etc/udev/rules.d/80-drivers.rules:14 | ||
# /usr/sbin/pcscd etc/udev/rules.d/99-pcsc_lite.rules:4 | ||
# /usr/bin/killall etc/udev/rules.d/kino.rules:11 | ||
# the files without a path name are supposed to be in /lib/udev | ||
cd $ROOTFS_DIR | ||
grep -nE '(PROGRAM|RUN)' etc/udev/rules.d/* lib/udev/rules.d/* | \ | ||
sed -ne 's#\(^.*:[0-9]\+\):.*\(PROGRAM\|RUN\)[+!]\?="\([^"%\$ ]\+\).*#\3 \1#p' | \ | ||
grep -v ^socket: | \ | ||
uniq | ||
) | ||
|
||
# insert our module auto-loading rule | ||
# the big and stupid problem is that some older udev versions, which we still want to support, use SYSFS{} instead of | ||
# ATTRS{} so we have to find out how to write the rule: | ||
|
||
# get some sysfs path with modalias in it (the printf prints it without the /sys ...) | ||
sysfs_modalias_paths=( $(find /sys -type f -name modalias -printf "/%P\n" | sed -e 's#/modalias$##') ) | ||
# the result looks like this: | ||
# /devices/pci0000:00/0000:00:00.0 | ||
# /devices/platform/i8042/serio1 | ||
# /devices/platform/i8042/serio0 | ||
|
||
# query the first sysfs path and choose ATTRS or SYSFS according to what *this* udev gives us | ||
# I check for ATTR and not ATTRS because it might be either one of the two, depends on the | ||
# sysfs path I query here and I don't predict that | ||
if my_udevinfo -a -p $sysfs_modalias_paths | grep '{modalias}' | grep -q ATTR ; then | ||
echo 'ACTION=="add", ATTRS{modalias}=="?*", RUN+="/bin/modprobe -v $attr{modalias}"' | ||
else | ||
echo 'ACTION=="add", SYSFS{modalias}=="?*", RUN+="/bin/modprobe -v $sysfs{modalias}"' | ||
fi >>$ROOTFS_DIR/etc/udev/rules.d/00-rear.rules | ||
ProgressStep | ||
|
||
# udev requires certain standard groups, add them to the rescue system | ||
# the groups and users are in rescue/default/15_users_and_groups.sh | ||
|
||
|
||
ProgressStop | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# some scripts need this | ||
COPY_AS_IS=( "${COPY_AS_IS[@]}" /etc/sysconfig/network/config /etc/sysconfig/network/scripts/functions ) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,37 @@ | ||
# describe all filesystems | ||
# describe all filesystems, including the extended attributes like max mount count, | ||
# check interval, etc. | ||
|
||
while read mountpoint device mountby filesystem junk ; do | ||
mkdir -p $VAR_DIR/recovery$device | ||
vol_id $device >$VAR_DIR/recovery$device/fs_vol_id || \ | ||
Error "Cannot determine filesystem info on '$device' | ||
Your udev implementation (vol_id or udev_volume_id) does not recognize it." | ||
echo "$device" >$VAR_DIR/recovery$device/depends | ||
case $filesystem in | ||
ext*) | ||
tmp_fs_parameters=$(mktemp $TMP_DIR/fs_parameters.XXXXXX) || \ | ||
Error "Failed creating a temporary file in $TMP_DIR." | ||
tune2fs -l $device > $tmp_fs_parameters || \ | ||
Error "Could not run tune2fs or failed to write to $tmp_fs_parameters." | ||
FS_RESERVED_BLOCKS=$(grep "Reserved block count" $tmp_fs_parameters | sed -e 's/^.*: \+\([0123456789]\+\).*$/\1/g') | ||
FS_MAX_MOUNTS=$(grep "Maximum mount count" $tmp_fs_parameters | sed -e 's/^.*: \+\([-0123456789]\+\).*$/\1/g') | ||
FS_CHECK_INTERVAL=$(grep "Check interval" $tmp_fs_parameters | sed -e 's/^.*: \+\([0123456789]\+\).*$/\1/g') | ||
|
||
# The check interval is displayed in seconds, but tune2fs only allows us to set | ||
# the interval in days, weeks or month. So we have to convert the seconds to days | ||
(( FS_CHECK_INTERVAL = FS_CHECK_INTERVAL / 86400 )) | ||
rm $tmp_fs_parameters | ||
fs_parameters=$VAR_DIR/recovery$device/fs_parameters | ||
> $fs_parameters || Error "Could not write to $fs_parameters" | ||
echo "FS_RESERVED_BLOCKS=$FS_RESERVED_BLOCKS" > $fs_parameters | ||
echo "FS_MAX_MOUNTS=$FS_MAX_MOUNTS" >> $fs_parameters | ||
echo "FS_CHECK_INTERVAL=$FS_CHECK_INTERVAL" >> $fs_parameters | ||
;; | ||
*) | ||
Log "The filesystem $filesystem on $device does not support extended filesystem" | ||
Log "parameters like max mount count, check imterval etc. or it" | ||
Log "is not implemented in ReaR yet" | ||
Log "Please file a bug if you think this is an error" | ||
;; | ||
esac | ||
done <$VAR_DIR/recovery/mountpoint_device |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
usr/share/rear/finalize/Debian/i386/17_rebuild_initramfs.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# rebuild the initramfs if the drivers changed | ||
# | ||
# probably not required, but I prefer to rely on this information when it | ||
# is backed by udev | ||
have_udev || return 0 | ||
|
||
# check if we need to do something | ||
if test -s $TMP_DIR/storage_drivers && ! diff $TMP_DIR/storage_drivers $VAR_DIR/recovery/storage_drivers >/dev/null ; then | ||
# remember, diff returns 0 if the files are the same | ||
|
||
# merge new drivers with previous initrd modules | ||
# BUG: we only add modules to the initrd, we don't take old ones out | ||
# could be done better, but might not be worth the risk | ||
INITRD_MODULES="$( sort -t " " -k 1 -u $TMP_DIR/storage_drivers /mnt/local/etc/initramfs-tools/module[s] )" | ||
# use [] to skip file if it does not exist | ||
# -t " " -k 1 tries to keep the comments unsorted | ||
|
||
echo "$INITRD_MODULES" >/mnt/local/etc/initramfs-tools/modules | ||
|
||
mount -t proc none /mnt/local/proc | ||
mount -t sysfs none /mnt/local/sys | ||
if chroot /mnt/local /bin/bash --login -c "update-initramfs -v -u -k all" 1>&2 ; then | ||
LogPrint "Updated initramfs with new drivers for this system." | ||
else | ||
LogPrint "WARNING !!! | ||
initramfs creation failed, please check '$LOGFILE' to see the error | ||
messages in detail and decide yourself, wether the system will boot or not. | ||
" | ||
fi | ||
umount /mnt/local/proc /mnt/local/sys | ||
|
||
fi |
52 changes: 52 additions & 0 deletions
52
usr/share/rear/finalize/GNU/Linux/15_migrate_disk_devices.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# migrate disk device mappings | ||
|
||
# skip if no mappings | ||
test -s $TMP_DIR/mappings/disk_devices || return 0 | ||
|
||
Log "TAG-15-migrate: $DISK_DEVICE_MAPPINGS_SED_SCRIPT" | ||
|
||
test "$DISK_DEVICE_MAPPINGS_SED_SCRIPT" || BugError "The sed script for the disk device mappings | ||
is missing, it should be defined in verify/GNU/Linux/21_migrate_recovery_configuration.sh." | ||
|
||
# now run sed | ||
pushd /mnt/local >/dev/null | ||
# the funny [] around the first letter make sure that shopt -s nullglob removes this file from the list if it does not exist | ||
# the files without a [] are mandatory, like fstab | ||
for file in [b]oot/{grub.conf,menu.lst,device.map} [e]tc/grub.* [b]oot/grub/{grub.conf,menu.lst,device.map} \ | ||
[e]tc/sysconfig/grub [e]tc/sysconfig/bootloader \ | ||
[e]tc/lilo.conf \ | ||
[e]tc/mtab etc/fstab \ | ||
[e]tc/mtools.conf \ | ||
[e]tc/smartd.conf [e]tc/sysconfig/smartmontools \ | ||
[e]tc/sysconfig/rawdevices \ | ||
[e]tc/security/pam_mount.conf.xml | ||
do | ||
|
||
# sed -i bails on symlinks, so we follow the symlink and patch the result | ||
# on dead links we warn and skip them | ||
# TODO: maybe we must put this into a chroot so that absolute symlinks will work correctly | ||
if test -L "$file" ; then | ||
if linkdest="$(readlink -f "$file")" ; then | ||
LogPrint "Patching '$linkdest' instead of '$file'" | ||
file="$linkdest" | ||
else | ||
LogPrint "Not patching dead link '$file'" | ||
continue | ||
fi | ||
fi | ||
|
||
sed -i "$DISK_DEVICE_MAPPINGS_SED_SCRIPT" "$file" ||\ | ||
Error "Patching '$file' with sed failed." | ||
done | ||
|
||
# we still need to modify the swap entries in /etc/fstab if byid mounting is used | ||
# TODO: keep swap priorities and other options | ||
if grep -q "^/dev/disk/by-id/.*swap" etc/fstab ; then | ||
sed -i -e '/^\/dev\/disk\/by-id\/.*swap/d' etc/fstab | ||
for swapfile in $(find $VAR_DIR/recovery -name swap_vol_id) ; do | ||
device_dir=$(dirname $swapfile) | ||
swap_device=${device_dir##$VAR_DIR/recovery} | ||
echo "$swap_device swap swap defaults 0 0" >> etc/fstab | ||
done | ||
fi | ||
popd >/dev/null |
Oops, something went wrong.