From 49b778dec05a142690bf88ead5649fefe0adc1a6 Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Sat, 19 Oct 2013 19:58:09 +0100 Subject: install/rescue: Adapt to a dracut based stage1. The main change here is not remounting a fresh /run. Dracut does this for us and we actually need to keep this one as the initial udev database (when udev is started by dracut) is stored here and thus mounting an empty fs could see us lose some metadata. We no longer touch the /bin, /sbin or /lib[64] symlinks as these are already relative symlinks into /usr and simply bind mounting /usr is enough. --- rescue/NEWS | 2 ++ rescue/tree/usr/share/symlinks | 5 ----- 2 files changed, 2 insertions(+), 5 deletions(-) (limited to 'rescue') diff --git a/rescue/NEWS b/rescue/NEWS index 57cf609ae..cf1c694d2 100644 --- a/rescue/NEWS +++ b/rescue/NEWS @@ -1,3 +1,5 @@ +- adapt to a dracut based stage1 + Version 1.45.1 - 14 October 2013 by Colin Guthrie - many btrfs tools no longer exist diff --git a/rescue/tree/usr/share/symlinks b/rescue/tree/usr/share/symlinks index 659a42c8c..091153872 100644 --- a/rescue/tree/usr/share/symlinks +++ b/rescue/tree/usr/share/symlinks @@ -1,9 +1,4 @@ -/bin /boot /etc/fstab /etc/inittab /etc/rc.sysinit -/lib -/lib64 -/sbin -/usr -- cgit v1.2.1 From fb0e725b23878e5c4b7dccd5b679831f78ad536d Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Sun, 3 Nov 2013 16:12:51 +0000 Subject: rescue: 1.46 --- rescue/Makefile | 2 +- rescue/NEWS | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'rescue') diff --git a/rescue/Makefile b/rescue/Makefile index 9e6b80637..064670531 100644 --- a/rescue/Makefile +++ b/rescue/Makefile @@ -1,6 +1,6 @@ include ../Makefile.config -VERSION=1.45.1 +VERSION=1.46 PRODUCT=drakx-installer-rescue RESCUE = rescue.sqfs diff --git a/rescue/NEWS b/rescue/NEWS index cf1c694d2..bb85b4dbd 100644 --- a/rescue/NEWS +++ b/rescue/NEWS @@ -1,3 +1,4 @@ +Version 1.46 - 20 October 2013 by Colin Guthrie - adapt to a dracut based stage1 Version 1.45.1 - 14 October 2013 by Colin Guthrie -- cgit v1.2.1 From 38a37508919ec7ee04bb740ee1b6a72011ab32cc Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Sun, 1 Dec 2013 13:00:29 +0000 Subject: Ignore the built rescue.sqfs --- rescue/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 rescue/.gitignore (limited to 'rescue') diff --git a/rescue/.gitignore b/rescue/.gitignore new file mode 100644 index 000000000..7b75a3e33 --- /dev/null +++ b/rescue/.gitignore @@ -0,0 +1 @@ +rescue.sqfs -- cgit v1.2.1 From 645e6932216fddd154865a9bebb0fd0e3beed301 Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Sun, 1 Dec 2013 20:57:39 +0000 Subject: rescue: Avoid having to run dracut convertfs script by setting up the tree. We can easily avoid post processing the tree simply by moving the tree around and ensuring we set it up correctly (with the compat symlinks) early in the process. --- rescue/make_rescue_img | 15 +++++++++------ rescue/tree/bin/login | 2 -- rescue/tree/sbin/fakeshutdown | 39 --------------------------------------- rescue/tree/usr/bin/login | 2 ++ rescue/tree/usr/sbin/fakeshutdown | 39 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 50 insertions(+), 47 deletions(-) delete mode 100755 rescue/tree/bin/login delete mode 100755 rescue/tree/sbin/fakeshutdown create mode 100755 rescue/tree/usr/bin/login create mode 100755 rescue/tree/usr/sbin/fakeshutdown (limited to 'rescue') diff --git a/rescue/make_rescue_img b/rescue/make_rescue_img index 18c045acb..432a6cf94 100755 --- a/rescue/make_rescue_img +++ b/rescue/make_rescue_img @@ -15,20 +15,23 @@ BEGIN { undef *_ } sub __ { print @_, "\n"; system(@_) } sub _ { __ @_; $? and die } +my $arch = arch() =~ /i.86/ ? $MDK::Common::System::compat_arch{arch()} : arch(); _ "rm -rf $tmp" if -e $tmp; -_ "mkdir $tmp"; +_ "mkdir -p $tmp/usr/{bin,sbin,lib}"; +_ "ln -s usr/bin $tmp/bin"; +_ "ln -s usr/sbin $tmp/sbin"; +_ "ln -s usr/lib $tmp/lib"; +if ($arch eq "x86_64") { + _ "mkdir $tmp/usr/lib64"; + _ "ln -s usr/lib64 $tmp/lib64"; +} _ 'find . -name "*~" | xargs rm -f'; mkdir_p($tmp . chomp_($_)) foreach cat_("dirs"); _ "cp -a tree/* $tmp"; -_ "find $tmp -name .svn | xargs rm -rf"; substInFile { s/DISTRIB_DESCR/$ENV{DISTRIB_DESCR}/ } "$tmp/etc/issue"; _ "../tools/install-xml-file-list list.xml $tmp"; -# / -> /usr move -_ "mkdir -p $tmp/usr/{,s}bin"; -_ "/usr/lib/dracut/modules.d/30convertfs/convertfs.sh $tmp"; - my %keytable_conflicts; my @less_important_keytables = qw(am_old am_phonetic no-dvorak de-latin1); foreach (keyboard::loadkeys_files(sub { warn @_ })) { diff --git a/rescue/tree/bin/login b/rescue/tree/bin/login deleted file mode 100755 index 4b2816926..000000000 --- a/rescue/tree/bin/login +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exec /bin/bash --login diff --git a/rescue/tree/sbin/fakeshutdown b/rescue/tree/sbin/fakeshutdown deleted file mode 100755 index 309f26c6c..000000000 --- a/rescue/tree/sbin/fakeshutdown +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/perl - -# -# Guillaume Cottenceau (gc) -# -# Copyright 2001 Mandrakesoft -# -# This software may be freely redistributed under the terms of the GNU -# public license. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# - -# From MDK::Common: -sub cat_ { open(my $F, '<', $_[0]) or die "cat of file $_[0] failed: $!\n"; my @l = <$F>; wantarray() ? @l : join '', @l } -print "\n"; - - -#- try to umount as much as possible; uses Pixel's ultra optimized algo (let you guess how it works..) -print "Umounting:\n"; -my @mounts = cat_('/proc/mounts'); -my $something_moved; -do { - $something_moved = 0; - foreach (@mounts) { - my $where = (split)[1]; - next if $where eq '/'; #- ouch! umounting the ramdisk on / always succeeds, and makes it becoming ro :-( - if (!system("umount $where 2>/dev/null")) { - print "\t$where\n"; - $something_moved++; - } - } -} while $something_moved; - - -#- shutdown with init -exec '/sbin/init', 6; diff --git a/rescue/tree/usr/bin/login b/rescue/tree/usr/bin/login new file mode 100755 index 000000000..4b2816926 --- /dev/null +++ b/rescue/tree/usr/bin/login @@ -0,0 +1,2 @@ +#!/bin/sh +exec /bin/bash --login diff --git a/rescue/tree/usr/sbin/fakeshutdown b/rescue/tree/usr/sbin/fakeshutdown new file mode 100755 index 000000000..309f26c6c --- /dev/null +++ b/rescue/tree/usr/sbin/fakeshutdown @@ -0,0 +1,39 @@ +#!/usr/bin/perl + +# +# Guillaume Cottenceau (gc) +# +# Copyright 2001 Mandrakesoft +# +# This software may be freely redistributed under the terms of the GNU +# public license. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# + +# From MDK::Common: +sub cat_ { open(my $F, '<', $_[0]) or die "cat of file $_[0] failed: $!\n"; my @l = <$F>; wantarray() ? @l : join '', @l } +print "\n"; + + +#- try to umount as much as possible; uses Pixel's ultra optimized algo (let you guess how it works..) +print "Umounting:\n"; +my @mounts = cat_('/proc/mounts'); +my $something_moved; +do { + $something_moved = 0; + foreach (@mounts) { + my $where = (split)[1]; + next if $where eq '/'; #- ouch! umounting the ramdisk on / always succeeds, and makes it becoming ro :-( + if (!system("umount $where 2>/dev/null")) { + print "\t$where\n"; + $something_moved++; + } + } +} while $something_moved; + + +#- shutdown with init +exec '/sbin/init', 6; -- cgit v1.2.1 From c4634f60b5c6d67eedfedc02166499884e4d6625 Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Sun, 1 Dec 2013 22:29:20 +0000 Subject: rescue: Use systemd as initsystem. This commit converts the rescue system to systemd rather than the legacy sysvinit. Besides being faster, one primary advantage of running systemd here is that we can "boot" the system we're inspecting via systemd-nspawn to properly test it. Note: Bits that don't work: * nspawn * old dracut initqueue udev rules in /etc/ are not cleaned out (drop in support error?) * the gui may loop differently now --- rescue/NEWS | 2 + rescue/aliases | 2 + rescue/dirs | 9 ++- rescue/list.xml | 92 ++++++++++++++++++++-- rescue/make_rescue_img | 13 +-- rescue/tree/etc/hostname | 1 + rescue/tree/etc/inittab | 16 ---- rescue/tree/etc/passwd | 2 - rescue/tree/etc/rc.reboot | 8 -- rescue/tree/etc/rc.sysinit | 87 -------------------- rescue/tree/usr/bin/mageia-rescue | 35 ++++++++ rescue/tree/usr/lib/CVS. | 0 .../tree/usr/lib/modules-load.d/mageia-rescue.conf | 17 ++++ rescue/tree/usr/lib/systemd/system/rescue.service | 20 +++++ .../systemd-udevd.service.d/dracut-rules.conf | 1 + rescue/tree/usr/sbin/fakeshutdown | 39 --------- rescue/tree/usr/share/symlinks | 4 - 17 files changed, 178 insertions(+), 170 deletions(-) create mode 100644 rescue/tree/etc/hostname delete mode 100644 rescue/tree/etc/inittab delete mode 100755 rescue/tree/etc/rc.reboot delete mode 100755 rescue/tree/etc/rc.sysinit create mode 100755 rescue/tree/usr/bin/mageia-rescue delete mode 100644 rescue/tree/usr/lib/CVS. create mode 100644 rescue/tree/usr/lib/modules-load.d/mageia-rescue.conf create mode 100644 rescue/tree/usr/lib/systemd/system/rescue.service create mode 100644 rescue/tree/usr/lib/systemd/system/systemd-udevd.service.d/dracut-rules.conf delete mode 100755 rescue/tree/usr/sbin/fakeshutdown delete mode 100644 rescue/tree/usr/share/symlinks (limited to 'rescue') diff --git a/rescue/NEWS b/rescue/NEWS index bb85b4dbd..7f84b4b3e 100644 --- a/rescue/NEWS +++ b/rescue/NEWS @@ -1,3 +1,5 @@ +- use systemd as init in the rescue system + Version 1.46 - 20 October 2013 by Colin Guthrie - adapt to a dracut based stage1 diff --git a/rescue/aliases b/rescue/aliases index 59c96a124..ebb5a462e 100644 --- a/rescue/aliases +++ b/rescue/aliases @@ -1,2 +1,4 @@ /bin/vi vim-minimal /lib/modules /modules +/usr/sbin/init /usr/lib/systemd/systemd +/usr/lib/systemd/system/default.target rescue.target diff --git a/rescue/dirs b/rescue/dirs index 6b6d88a6f..256a7f0f7 100644 --- a/rescue/dirs +++ b/rescue/dirs @@ -1,4 +1,9 @@ -/lib +/dev +/proc +/run +/sys +/usr/bin +/usr/sbin +/usr/lib /tmp /modules -/proc diff --git a/rescue/list.xml b/rescue/list.xml index fb73f4df4..fd5a829a2 100644 --- a/rescue/list.xml +++ b/rescue/list.xml @@ -150,12 +150,6 @@ - - - init - - - /usr/lib/kbd/keymaps/include @@ -272,10 +266,94 @@ + systemd + systemd-cgroups-agent + systemd-shutdown + systemd-reply-password + systemd-fsck systemd-udevd + systemd-journald + systemd-sysctl + systemd-modules-load + systemd-vconsole-setup + system-generators/systemd-fstab-generator + + + + cryptsetup.target + emergency.target + sysinit.target + basic.target + halt.target + kexec.target + local-fs.target + local-fs-pre.target + remote-fs.target + remote-fs-pre.target + network.target + nss-lookup.target + nss-user-lookup.target + poweroff.target + reboot.target + rescue.target + rpcbind.target + shutdown.target + final.target + sigpwr.target + sockets.target + swap.target + timers.target + paths.target + umount.target + kmod-static-nodes.service + systemd-tmpfiles-setup-dev.service + systemd-ask-password-console.path + systemd-udevd-control.socket + systemd-udevd-kernel.socket + systemd-ask-password-plymouth.path + systemd-journald.socket + systemd-ask-password-console.service + systemd-modules-load.service + systemd-halt.service + systemd-poweroff.service + systemd-reboot.service + systemd-kexec.service + systemd-fsck@.service + systemd-udevd.service + systemd-udev-trigger.service + systemd-udev-settle.service + systemd-ask-password-plymouth.service + systemd-journald.service + systemd-vconsole-setup.service + + sysinit.target.wants/systemd-modules-load.service + sysinit.target.wants/systemd-ask-password-console.path + sysinit.target.wants/systemd-journald.service + sockets.target.wants/systemd-udevd-control.socket + sockets.target.wants/systemd-udevd-kernel.socket + sockets.target.wants/systemd-journald.socket + sysinit.target.wants/systemd-udevd.service + sysinit.target.wants/systemd-udev-trigger.service + sysinit.target.wants/kmod-static-nodes.service + sysinit.target.wants/systemd-tmpfiles-setup-dev.service + + ctrl-alt-del.target + syslog.socket + + slices.target + system.slice + + + + journalctl systemctl echo swapoff systemd-cgls systemd-tmpfiles systemd-nspawn + + + + ata_id + scsi_id - + 10-dm.rules 11-dm-lvm.rules 13-dm-disk.rules diff --git a/rescue/make_rescue_img b/rescue/make_rescue_img index 432a6cf94..50083d0b0 100755 --- a/rescue/make_rescue_img +++ b/rescue/make_rescue_img @@ -17,7 +17,7 @@ sub _ { __ @_; $? and die } my $arch = arch() =~ /i.86/ ? $MDK::Common::System::compat_arch{arch()} : arch(); _ "rm -rf $tmp" if -e $tmp; -_ "mkdir -p $tmp/usr/{bin,sbin,lib}"; +_ "mkdir -p $tmp"; _ "ln -s usr/bin $tmp/bin"; _ "ln -s usr/sbin $tmp/sbin"; _ "ln -s usr/lib $tmp/lib"; @@ -25,13 +25,16 @@ if ($arch eq "x86_64") { _ "mkdir $tmp/usr/lib64"; _ "ln -s usr/lib64 $tmp/lib64"; } -_ 'find . -name "*~" | xargs rm -f'; -mkdir_p($tmp . chomp_($_)) foreach cat_("dirs"); _ "cp -a tree/* $tmp"; +_ "find $tmp -name '*~' -delete"; +mkdir_p($tmp . chomp_($_)) foreach cat_("dirs"); substInFile { s/DISTRIB_DESCR/$ENV{DISTRIB_DESCR}/ } "$tmp/etc/issue"; _ "../tools/install-xml-file-list list.xml $tmp"; +_ "sed 's/Mageia \\([0-9]*\\)/Mageia Rescue \\1/' /etc/os-release >$tmp/etc/os-release"; +_ "ls -1 $tmp/etc | sed 's,\\(.*\\),/etc/\\1,' >>$tmp/usr/share/symlinks"; + my %keytable_conflicts; my @less_important_keytables = qw(am_old am_phonetic no-dvorak de-latin1); foreach (keyboard::loadkeys_files(sub { warn @_ })) { @@ -56,11 +59,11 @@ foreach (cat_("aliases")) { if (my ($LANGUAGE) = map { if_(/LANGUAGE_(.*)/, $1) } keys %ENV) { substInFile { $_ = "export LANGUAGE=$LANGUAGE\n" . "export LC_ALL=$LANGUAGE\n" if /^#LANGUAGE/; - } "$tmp/etc/rc.sysinit"; + } "$tmp/usr/bin/mageia-rescue"; } exit 0 if $ARGV[0]; _ "mksquashfs $tmp $rescue -all-root -noappend >/dev/null"; _ "chmod 755 $rescue"; -_ "rm -rf $tmp"; +#_ "rm -rf $tmp"; diff --git a/rescue/tree/etc/hostname b/rescue/tree/etc/hostname new file mode 100644 index 000000000..344f71bc8 --- /dev/null +++ b/rescue/tree/etc/hostname @@ -0,0 +1 @@ +rescue diff --git a/rescue/tree/etc/inittab b/rescue/tree/etc/inittab deleted file mode 100644 index 6a30c0360..000000000 --- a/rescue/tree/etc/inittab +++ /dev/null @@ -1,16 +0,0 @@ -#Inittab for Mageia Rescue Disk -#Author: Daouda Lo -id:3:initdefault: - -si::sysinit:/etc/rc.sysinit -re:6:wait:/etc/rc.reboot -ca:12345:ctrlaltdel:/sbin/fakeshutdown - -1:12345:respawn:/sbin/mingetty --autologin root tty1 -2:23:respawn:/sbin/mingetty --autologin root tty2 -3:23:respawn:/sbin/mingetty --autologin root tty3 -4:23:respawn:/sbin/mingetty --autologin root tty4 -5:23:respawn:/sbin/mingetty --autologin root tty5 -6:23:respawn:/sbin/mingetty --autologin root tty6 -s0:2345:respawn:/sbin/agetty -h -t 60 ttyS0 9600 ansi -#s1:2345:respawn:/sbin/agetty -h -t 60 ttyS1 115200,9600 linux diff --git a/rescue/tree/etc/passwd b/rescue/tree/etc/passwd index 3a1254f77..06677c9bf 100644 --- a/rescue/tree/etc/passwd +++ b/rescue/tree/etc/passwd @@ -1,3 +1 @@ root::0:0::/root:/bin/bash -shutdown:*:6:0:shutdown:/sbin:/sbin/shutdown -halt:*:7:0:halt:/sbin:/sbin/halt diff --git a/rescue/tree/etc/rc.reboot b/rescue/tree/etc/rc.reboot deleted file mode 100755 index 0b67416f1..000000000 --- a/rescue/tree/etc/rc.reboot +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -sleep 1 -/sbin/killall5 -9 - -umount -a -f -t noproc - -reboot -i -d diff --git a/rescue/tree/etc/rc.sysinit b/rescue/tree/etc/rc.sysinit deleted file mode 100755 index 551a4bc76..000000000 --- a/rescue/tree/etc/rc.sysinit +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/sh - -action() { echo $1; shift; $*; } -DATE=`date +%Y%m%d-%Hh%M` - -export PATH=/bin:/sbin:/usr/bin:/usr/sbin - -echo -e "\t\t\tWelcome to \\033[1;36mMageia\\033[0;39m Linux" - -action "Remounting root filesystem in read-write mode" mount -n -o remount,rw / - -echo "Starting udev" -mkdir /run -mount -t tmpfs -o mode=0755,nosuid,nodev tmpfs /run -mkdir -p /run/udev/rules.d -export UDEVRULESD=/run/udev/rules.d - -/usr/lib/systemd/systemd-udevd --daemon --resolve-names=never -udevadm trigger --type=subsystems --action=add -udevadm trigger --type=devices --action=add - -ln -s /tmp/stage2/etc/* /etc 2>/dev/null -# make passwd changable -rm -f /etc/passwd -cp /tmp/stage2/etc/passwd /etc/ - -mkdir -p /mnt /var/log - ->/etc/mtab -mount -f / -mount -f /proc - -# Set the hostname. -action "Setting hostname rescue" hostname rescue -echo rescue > /etc/HOSTNAME - -# Loads common modules ( no kerneld :( ) -echo "Loading additional modules..." -load() { modprobe $* 2>/dev/null; } -load ide-gd_mod -load ide-cd_mod -load floppy -load af_packet -load isofs -load vfat -load ext3 -load ext4 -load reiserfs -load nilfs2 -load btrfs -load xfs -load jfs -load loop -load fuse -load sd_mod -load sr_mod - -action "Bringing up local loop interface" ifconfig lo up - -# disable the weird echoprt in cooked mode for user interaction: -stty sane - -#LANGUAGE (filled by make_rescue_img) - -grep -q noauto /proc/cmdline || drvinst SERIAL_USB - -partimage_default_dir=/data/box -partimage_dir=`perl -lne 'print $1 if /BOX=(\S+)/' /proc/cmdline` -[ -z "$partimage_dir" ] && partimage_dir=$partimage_default_dir -partimage_server=`perl -lne 'print $1 if /\bpserver=(\S+)/' /proc/cmdline` - -if grep -q save_all /proc/cmdline; then - partimage_whole_disk -s $partimage_server save_all $partimage_default_dir -elif grep -q rest_all /proc/cmdline; then - if [ -d /tmp/image$partimage_dir ]; then - partimage_whole_disk rest_all /tmp/image$partimage_dir - else - partimage_whole_disk -s $partimage_server rest_all $partimage_dir - fi -elif grep -q oem /proc/cmdline; then - /tmp/image/oem-rescue.sh -elif grep -q restore /proc/cmdline; then - /usr/sbin/restore-image.sh -elif ! grep -q expert /proc/cmdline; then - echo "starting GUI" - rescue-gui -fi diff --git a/rescue/tree/usr/bin/mageia-rescue b/rescue/tree/usr/bin/mageia-rescue new file mode 100755 index 000000000..c9dd35661 --- /dev/null +++ b/rescue/tree/usr/bin/mageia-rescue @@ -0,0 +1,35 @@ +#!/bin/sh + +# disable the weird echoprt in cooked mode for user interaction: +stty sane + +#LANGUAGE (filled by make_rescue_img) + +grep -q noauto /proc/cmdline || drvinst SERIAL_USB + +partimage_default_dir=/data/box +partimage_dir=`perl -lne 'print $1 if /BOX=(\S+)/' /proc/cmdline` +[ -z "$partimage_dir" ] && partimage_dir=$partimage_default_dir +partimage_server=`perl -lne 'print $1 if /\bpserver=(\S+)/' /proc/cmdline` + +LOOP="" +if grep -q save_all /proc/cmdline; then + partimage_whole_disk -s $partimage_server save_all $partimage_default_dir +elif grep -q rest_all /proc/cmdline; then + if [ -d /tmp/image$partimage_dir ]; then + partimage_whole_disk rest_all /tmp/image$partimage_dir + else + partimage_whole_disk -s $partimage_server rest_all $partimage_dir + fi +elif grep -q oem /proc/cmdline; then + /tmp/image/oem-rescue.sh +elif grep -q restore /proc/cmdline; then + /usr/sbin/restore-image.sh +elif ! grep -q expert /proc/cmdline; then + rescue-gui && LOOP=y +fi + +while [ "$LOOP" ]; do + bash --login + rescue-gui +done diff --git a/rescue/tree/usr/lib/CVS. b/rescue/tree/usr/lib/CVS. deleted file mode 100644 index e69de29bb..000000000 diff --git a/rescue/tree/usr/lib/modules-load.d/mageia-rescue.conf b/rescue/tree/usr/lib/modules-load.d/mageia-rescue.conf new file mode 100644 index 000000000..4111c0484 --- /dev/null +++ b/rescue/tree/usr/lib/modules-load.d/mageia-rescue.conf @@ -0,0 +1,17 @@ +ide-gd_mod +ide-cd_mod +floppy +af_packet +isofs +vfat +ext3 +ext4 +reiserfs +nilfs2 +btrfs +xfs +jfs +loop +fuse +sd_mod +sr_mod diff --git a/rescue/tree/usr/lib/systemd/system/rescue.service b/rescue/tree/usr/lib/systemd/system/rescue.service new file mode 100644 index 000000000..336e06c22 --- /dev/null +++ b/rescue/tree/usr/lib/systemd/system/rescue.service @@ -0,0 +1,20 @@ +[Unit] +Description=Mageia Rescue +DefaultDependencies=no +Conflicts=shutdown.target +After=sysinit.target plymouth-start.service +Before=shutdown.target + +[Service] +Environment=HOME=/ +WorkingDirectory=/ +ExecStartPre=-/bin/plymouth quit +ExecStart=/usr/bin/mageia-rescue +ExecStopPost=-/usr/bin/systemctl --fail --no-block reboot +Type=idle +StandardInput=tty-force +StandardOutput=inherit +StandardError=inherit +KillMode=process +IgnoreSIGPIPE=no +SendSIGHUP=yes diff --git a/rescue/tree/usr/lib/systemd/system/systemd-udevd.service.d/dracut-rules.conf b/rescue/tree/usr/lib/systemd/system/systemd-udevd.service.d/dracut-rules.conf new file mode 100644 index 000000000..b75df2e4e --- /dev/null +++ b/rescue/tree/usr/lib/systemd/system/systemd-udevd.service.d/dracut-rules.conf @@ -0,0 +1 @@ +ExecStartPre=-/usr/bin/rm -f /etc/udev/rules.d/10-console.rules diff --git a/rescue/tree/usr/sbin/fakeshutdown b/rescue/tree/usr/sbin/fakeshutdown deleted file mode 100755 index 309f26c6c..000000000 --- a/rescue/tree/usr/sbin/fakeshutdown +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/perl - -# -# Guillaume Cottenceau (gc) -# -# Copyright 2001 Mandrakesoft -# -# This software may be freely redistributed under the terms of the GNU -# public license. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# - -# From MDK::Common: -sub cat_ { open(my $F, '<', $_[0]) or die "cat of file $_[0] failed: $!\n"; my @l = <$F>; wantarray() ? @l : join '', @l } -print "\n"; - - -#- try to umount as much as possible; uses Pixel's ultra optimized algo (let you guess how it works..) -print "Umounting:\n"; -my @mounts = cat_('/proc/mounts'); -my $something_moved; -do { - $something_moved = 0; - foreach (@mounts) { - my $where = (split)[1]; - next if $where eq '/'; #- ouch! umounting the ramdisk on / always succeeds, and makes it becoming ro :-( - if (!system("umount $where 2>/dev/null")) { - print "\t$where\n"; - $something_moved++; - } - } -} while $something_moved; - - -#- shutdown with init -exec '/sbin/init', 6; diff --git a/rescue/tree/usr/share/symlinks b/rescue/tree/usr/share/symlinks deleted file mode 100644 index 091153872..000000000 --- a/rescue/tree/usr/share/symlinks +++ /dev/null @@ -1,4 +0,0 @@ -/boot -/etc/fstab -/etc/inittab -/etc/rc.sysinit -- cgit v1.2.1 From 8faa57a8737a0e1a163fbd91d86065784ea5d44d Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Mon, 2 Dec 2013 22:28:45 +0000 Subject: rescue: add machined (and dbus as a dep) to the rescue. This allows us to actually mount and run the system inside a container for more advanced debugging. I've successfully booted my systemd, logged in, had a fiddle and then powered it off again. There are some delays and it's requried to umount the /mnt/proc which seems to get automatically mounted before running nspawn. Also audit support has to be turned off in the kernel too to allow a full boot to work properly (otherwise the authentication in the container doesn't work. This is a known problem in the kernel and will be fixed eventually. --- rescue/NEWS | 1 + rescue/aliases | 2 ++ rescue/list.xml | 15 ++++++++++++++- rescue/make_rescue_img | 1 + rescue/tree/etc/passwd | 1 + 5 files changed, 19 insertions(+), 1 deletion(-) (limited to 'rescue') diff --git a/rescue/NEWS b/rescue/NEWS index 7f84b4b3e..cf8d6e3cf 100644 --- a/rescue/NEWS +++ b/rescue/NEWS @@ -1,4 +1,5 @@ - use systemd as init in the rescue system +- allowing systemd-nspawn "booting" of a mounted /mnt (after umount /mnt/proc) Version 1.46 - 20 October 2013 by Colin Guthrie - adapt to a dracut based stage1 diff --git a/rescue/aliases b/rescue/aliases index ebb5a462e..d92ea8ccf 100644 --- a/rescue/aliases +++ b/rescue/aliases @@ -2,3 +2,5 @@ /lib/modules /modules /usr/sbin/init /usr/lib/systemd/systemd /usr/lib/systemd/system/default.target rescue.target +/usr/lib/systemd/system/rescue.target.wants/sockets.target ../sockets.target +/usr/lib/systemd/system/dbus-org.freedesktop.machine1.service systemd-machined.service diff --git a/rescue/list.xml b/rescue/list.xml index fd5a829a2..29139f46d 100644 --- a/rescue/list.xml +++ b/rescue/list.xml @@ -273,6 +273,7 @@ systemd-fsck systemd-udevd systemd-journald + systemd-machined systemd-sysctl systemd-modules-load systemd-vconsole-setup @@ -281,6 +282,8 @@ cryptsetup.target + dbus.service + dbus.socket emergency.target sysinit.target basic.target @@ -324,11 +327,13 @@ systemd-udev-settle.service systemd-ask-password-plymouth.service systemd-journald.service + systemd-machined.service systemd-vconsole-setup.service sysinit.target.wants/systemd-modules-load.service sysinit.target.wants/systemd-ask-password-console.path sysinit.target.wants/systemd-journald.service + sockets.target.wants/dbus.socket sockets.target.wants/systemd-udevd-control.socket sockets.target.wants/systemd-udevd-kernel.socket sockets.target.wants/systemd-journald.socket @@ -345,7 +350,15 @@ - journalctl systemctl echo swapoff systemd-cgls systemd-tmpfiles systemd-nspawn + journalctl systemctl echo swapoff systemd-cgls systemd-tmpfiles systemd-nspawn dbus-daemon machinectl + + + + /etc/dbus-1/system.conf + /etc/dbus-1/system.d/org.freedesktop.systemd1.conf + /etc/dbus-1/system.d/org.freedesktop.machine1.conf + /usr/share/dbus-1/system-services/org.freedesktop.systemd1.service + /usr/share/dbus-1/system-services/org.freedesktop.machine1.service diff --git a/rescue/make_rescue_img b/rescue/make_rescue_img index 50083d0b0..4b4301c55 100755 --- a/rescue/make_rescue_img +++ b/rescue/make_rescue_img @@ -34,6 +34,7 @@ _ "../tools/install-xml-file-list list.xml $tmp"; _ "sed 's/Mageia \\([0-9]*\\)/Mageia Rescue \\1/' /etc/os-release >$tmp/etc/os-release"; _ "ls -1 $tmp/etc | sed 's,\\(.*\\),/etc/\\1,' >>$tmp/usr/share/symlinks"; +_ "mkdir -p $tmp/usr/lib/systemd/system/rescue.target.wants"; my %keytable_conflicts; my @less_important_keytables = qw(am_old am_phonetic no-dvorak de-latin1); diff --git a/rescue/tree/etc/passwd b/rescue/tree/etc/passwd index 06677c9bf..c0274a116 100644 --- a/rescue/tree/etc/passwd +++ b/rescue/tree/etc/passwd @@ -1 +1,2 @@ root::0:0::/root:/bin/bash +messagebus:x:1:1::/:/sbin/nologin -- cgit v1.2.1 From 2ad4c4fc0b990dd0db23cdee815ac2a13c60929d Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Mon, 2 Dec 2013 23:02:52 +0000 Subject: rescue: Rebuild the image when anything in the tree folder is changed. --- rescue/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'rescue') diff --git a/rescue/Makefile b/rescue/Makefile index 064670531..473bdd14a 100644 --- a/rescue/Makefile +++ b/rescue/Makefile @@ -10,7 +10,7 @@ all: $(RESCUE) install: $(RESCUE) cp -f $< $(STAGE2_DEST) -$(RESCUE): list.xml drvinst guessmounts lsparts rescue-doc make_rescue_img +$(RESCUE): $(wildcard tree/**/*) list.xml drvinst guessmounts lsparts rescue-doc make_rescue_img DISTRIB_DESCR=$(DISTRIB_DESCR) ./make_rescue_img dist: tar -- cgit v1.2.1 From e7aedc3aa7e08f3337c86085c6da10ca83445024 Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Mon, 2 Dec 2013 23:40:22 +0000 Subject: rescue: Move files around and introduce proper dep tracking. This moves any perl files into bin and sbin folders which will be directly installed in /usr/bin and /usr/sbin. This is done such that the extract modes in list.xml still work and the files end up in the right places. All other files have been moved into the tree folder in their final destination. --- rescue/Makefile | 2 +- rescue/bin/drvinst | 38 +++ rescue/bin/guessmounts | 145 +++++++++++ rescue/bin/install_bootloader | 72 ++++++ rescue/bin/lsparts | 45 ++++ rescue/bin/rescue-doc | 57 +++++ rescue/bin/restore_ms_boot | 74 ++++++ rescue/diskdrake-resize | 29 --- rescue/drvinst | 38 --- rescue/genpasswd | 13 - rescue/grabjournallogs | 51 ---- rescue/guessmounts | 145 ----------- rescue/install_bootloader | 72 ------ rescue/list.xml | 29 +-- rescue/lsparts | 45 ---- rescue/partimage_whole_disk | 264 -------------------- rescue/rescue-doc | 57 ----- rescue/restore-image-lib.sh | 80 ------ rescue/restore-image.sh | 412 ------------------------------- rescue/restore_ms_boot | 74 ------ rescue/sbin/partimage_whole_disk | 264 ++++++++++++++++++++ rescue/startssh | 27 -- rescue/tree/usr/lib/restore-image-lib.sh | 80 ++++++ rescue/tree/usr/sbin/diskdrake-resize | 29 +++ rescue/tree/usr/sbin/genpasswd | 13 + rescue/tree/usr/sbin/grabjournallogs | 51 ++++ rescue/tree/usr/sbin/restore-image.sh | 412 +++++++++++++++++++++++++++++++ rescue/tree/usr/sbin/startssh | 27 ++ 28 files changed, 1317 insertions(+), 1328 deletions(-) create mode 100755 rescue/bin/drvinst create mode 100755 rescue/bin/guessmounts create mode 100755 rescue/bin/install_bootloader create mode 100755 rescue/bin/lsparts create mode 100755 rescue/bin/rescue-doc create mode 100755 rescue/bin/restore_ms_boot delete mode 100755 rescue/diskdrake-resize delete mode 100755 rescue/drvinst delete mode 100755 rescue/genpasswd delete mode 100755 rescue/grabjournallogs delete mode 100755 rescue/guessmounts delete mode 100755 rescue/install_bootloader delete mode 100755 rescue/lsparts delete mode 100755 rescue/partimage_whole_disk delete mode 100755 rescue/rescue-doc delete mode 100755 rescue/restore-image-lib.sh delete mode 100755 rescue/restore-image.sh delete mode 100755 rescue/restore_ms_boot create mode 100755 rescue/sbin/partimage_whole_disk delete mode 100755 rescue/startssh create mode 100755 rescue/tree/usr/lib/restore-image-lib.sh create mode 100755 rescue/tree/usr/sbin/diskdrake-resize create mode 100755 rescue/tree/usr/sbin/genpasswd create mode 100755 rescue/tree/usr/sbin/grabjournallogs create mode 100755 rescue/tree/usr/sbin/restore-image.sh create mode 100755 rescue/tree/usr/sbin/startssh (limited to 'rescue') diff --git a/rescue/Makefile b/rescue/Makefile index 473bdd14a..64e9119e3 100644 --- a/rescue/Makefile +++ b/rescue/Makefile @@ -10,7 +10,7 @@ all: $(RESCUE) install: $(RESCUE) cp -f $< $(STAGE2_DEST) -$(RESCUE): $(wildcard tree/**/*) list.xml drvinst guessmounts lsparts rescue-doc make_rescue_img +$(RESCUE): $(wildcard tree/**/*) $(wildcard bin/*) $(wildcard sbin/*) make_rescue_img list.xml aliases DISTRIB_DESCR=$(DISTRIB_DESCR) ./make_rescue_img dist: tar diff --git a/rescue/bin/drvinst b/rescue/bin/drvinst new file mode 100755 index 000000000..4868b42e0 --- /dev/null +++ b/rescue/bin/drvinst @@ -0,0 +1,38 @@ +#!/usr/bin/perl +# +# Guillaume Cottenceau +# +# Copyright 2000-2005 Mandriva +# +# This software may be freely redistributed under the terms of the GNU +# public license. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# + +use lib qw(/usr/lib/libDrakX); +use common; +use detect_devices; + +$ARGV[0] =~ /^--?h/ and die "usage: drivers_install [drivertype1 [drivertype2 ...]]\n"; +my @types = @ARGV; + +sub install_module { + my ($driver, $descr) = @_; + print STDERR qq(Installing driver $driver (for "$descr")\n); + system("/sbin/modprobe", $driver) and print "\tfailed\n"; +} + +#- start +foreach my $card (detect_devices::pci_probe()) { + # ignoring "unknown", "Card:foobar" and the like as well as video cards: + $card->{driver} eq 'unknown' || $card->{driver} =~ /:/ and next; + $card->{media_type} eq "DISPLAY_VGA" and next; + + # load drivers for selected categories or for everything if no args: + if (!@ARGV || find { $card->{media_type} =~ /$_/i } @types) { + install_module($card->{driver}, $card->{description}); + } +} diff --git a/rescue/bin/guessmounts b/rescue/bin/guessmounts new file mode 100755 index 000000000..27b920c9d --- /dev/null +++ b/rescue/bin/guessmounts @@ -0,0 +1,145 @@ +#!/usr/bin/perl +# +# Guillaume Cottenceau +# +# Copyright 2001-2005 Mandriva +# +# This software may be freely redistributed under the terms of the GNU +# public license. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# + +use lib qw(/usr/lib/libDrakX); +use common; +use devices; +use fs; +use fs::dmcrypt; +use fs::proc_partitions; +use fs::type; +use lvm; +use run_program; + +my @proc_mounts = fs::read_fstab('', '/proc/mounts'); + +my $target = '/mnt'; + +if (fs::get::mntpoint2part($target, \@proc_mounts)) { + print STDERR "$target is already mounted (according to /proc/mounts)\n"; + exit 0; +} + +system('drvinst', 'STORAGE'); + +print STDERR "\nPlease wait, trying to find your root device...\n"; + +mkdir_p($target); + +{ + local $::isInstall = 1; # so that detect_during_install() got called by init: + lvm::init(); +} +fs::dmcrypt::init; + +my @parts = map { + $_->{device} = delete $_->{dev}; + put_in_hash($_, fs::type::type_subpart_from_magic($_)); +} fs::proc_partitions::read_raw(); +my ($raid_parts, $normal_parts) = partition { isRawRAID($_) } @parts; + +if (@$raid_parts) { + require raid; + raid::detect_during_install(@$raid_parts); + my $raids = raid::get_existing(@$raid_parts); + push @$normal_parts, @$raids; +} + +my @roots; + +my $arch = arch() =~ /i.86/ ? $MDK::Common::System::compat_arch{arch()} : arch(); +foreach (@$normal_parts) { + my $dev = devices::make($_->{device}); + + my $fs = find { + system("mount -t $_ $dev $target 2>/dev/null") == 0; + } fs::type::true_local_fs_types() or next; + + if (my $release_file = common::release_file($target)) { + my $release = chomp_(cat_("$target$release_file")); + print STDERR "=> found a $release root partition on $dev\n=> type $fs, version `\n"; + my @fstab = fs::read_fstab($target, '/etc/fstab'); + my $h = common::parse_release_file($target, $release_file, $_); + add2hash($h, { dev => $dev, fs => $fs, fstab => \@fstab, + pretty_name => "$h->{release} $h->{version} $h->{arch} on $dev" }); + # Offer to rescue only same arch: + $h->{pretty_name} .= " (cannot be rescued: $h->{arch} ne $arch;)" if $h->{arch} ne $arch; + push @roots, $h; + } + system('umount', $target) == 0 or die "error unmounting $target\n"; +} + +my ($root, $fs, @fstab); + +# Try Mageia first: +if (@roots) { + # Order by release number: + @roots = sort { $b->{version} cmp $a->{version} } @roots; + # Then pick mga over mdv: + @roots = map { @$_ } partition { $_->{release} =~ /Mageia/ } @roots; + + my $selected; + if (@roots == 1) { + $selected = first(@roots); + } else { + print "\n\nWhich system do you want to rescue?\n0: Abort\n"; + each_index { print $::i + 1, ": $_->{pretty_name}\n" } @roots; + my $res; + while ($res < 1 || $res > @roots) { + print "what is your choice (type the number of your selection or C^c to abort)?\n"; + $res = <>; + chomp($res); + if ($res eq "0") { + print "Aborting\n"; + exit(1); + } + } + $selected = $roots[$res-1]; + } + + $root = $selected->{dev}; + $fs = $selected->{fs}; + @fstab = @{$selected->{fstab}}; + print STDERR "=> Selecting $root as root fs\n"; +} + +if ($root) { + system("mount -t $fs $root $target 2>/dev/null"); + + print STDERR "\nMounting other partitions from fstab on $target...\n"; + foreach (@fstab) { + my ($valued_options, $options) = fs::mount_options::unpack($_); + + next if + !$_->{fs_type} || $_->{device} eq 'none' + || $valued_options->{noauto} + || $_->{mntpoint} eq '/' + || member($_->{fs_type}, 'swap', 'nfs', 'ntfs', 'ntfs-3g'); + + delete $valued_options->{'iocharset='}; + delete $valued_options->{'codepage='}; + fs::mount_options::pack($_, $valued_options, $options); #- vfat opts, we don't have the modules in rescue + + my $where = "$target$_->{mntpoint}"; + my $dev = fs::wild_device::from_part('', $_); + mkdir_p($where); + print STDERR "\t$dev on $where type $_->{fs_type} options $_->{options}\n"; + system("mount -t $_->{fs_type} $dev $where -o $_->{options}"); + } + system("mount -t proc proc $target/proc"); + print STDERR "\nYour system is ready on $target.\n\n"; +} else { + die "Could not find your root device :-(.\n"; +} + diff --git a/rescue/bin/install_bootloader b/rescue/bin/install_bootloader new file mode 100755 index 000000000..7328de1d2 --- /dev/null +++ b/rescue/bin/install_bootloader @@ -0,0 +1,72 @@ +#!/usr/bin/perl +# +# Guillaume Cottenceau +# +# Copyright 2001-2005 Mandriva +# +# This software may be freely redistributed under the terms of the GNU +# public license. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# + +use lib qw(/usr/lib/libDrakX); +use common; +use bootloader; +use fs; + +my $auto; +if ($ARGV[0] eq '--auto') { + $auto = shift @ARGV; +} + +$::prefix = '/mnt'; + +my $release = common::mageia_release($::prefix) || + do { + system('guessmounts') == 0 or die 'guessmounts failed'; + common::mageia_release($::prefix); + }; + +if ($release) { + $release =~ /Mageia|Mandriva/ or die "release file doesn't contain '%s', exiting.\n"; +} elsif (fs::get::mntpoint2part($::prefix, [ fs::read_fstab('', '/proc/mounts') ])) { + die "unknown distribution mounted in $::prefix\n"; +} else { + die "Your root device isn't mounted on $::prefix\n"; +} + +my @main_methods = bootloader::configured_main_methods(); + +my $main_method; +if (@main_methods == 0) { + die "Cannot find a configured boot loader\n"; +} elsif (@main_methods == 1) { + ($main_method) = @main_methods; +} else { + while (1) { + print "Configuration files for Boot Loaders ", join(' and ', @main_methods), " were found.\n"; + print "Which one one should be installed? "; + chomp($main_method = ); + if (member($main_method, @main_methods)) { + last; + } else { + print "bad choice\n"; + } + } +} + +my $install = $bootloader::{'install_raw_' . $main_method} or die "unknown bootloader method install_raw_$main_method\n"; + +print "About to re-install Boot Loader $main_method of following %s distribution:\n\t", + $release, "\n"; +if (!$auto) { + print "=> ok? "; + =~ /^n/i and exit 0; +} + +run_program::run('mount', '--bind', '/dev', "$::prefix/dev"); +$install->(); +run_program::run('umount', "$::prefix/dev"); diff --git a/rescue/bin/lsparts b/rescue/bin/lsparts new file mode 100755 index 000000000..8d36a02f4 --- /dev/null +++ b/rescue/bin/lsparts @@ -0,0 +1,45 @@ +#!/usr/bin/perl +# +# Main author Pascal Rigaux (pixel) +# Put together by Guillaume Cottenceau +# +# Copyright 1999-2005 Mandriva +# +# This software may be freely redistributed under the terms of the GNU +# public license. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# +# Detects partition types using signatures +# + +use lib qw(/usr/lib/libDrakX); +use common; +use fs::type; +use fs::proc_partitions; + +my $params = join '', @ARGV; +my $verbose = $params =~ /-v/; + +$params =~ /-h/ and die "usage: lsparts [-v]\n"; + + +foreach (fs::proc_partitions::read_raw()) { + if (my $err = $_->{size} <= 1 ? + "Skipping <$_->{dev}> because too little blocks ($_->{size})" : + $_->{dev} !~ /\d$/ ? + "Skipping <$_->{dev}> because doesn't end with a number (e.g. seems to not be a partition)" : + $_->{dev} =~ /^loop\d+$/ ? + "Skipping <$_->{dev}>" : + '') { + print STDERR "$err\n" if $verbose; + } else { + $_->{device} = $_->{dev}; + if (my $type = fs::type::type_subpart_from_magic($_)) { + printf "$_->{dev}: %6s, fs %s (%s)\n", formatXiB($_->{size} * 512), $type->{fs_type}, fs::type::part2type_name($type); + } + } +} diff --git a/rescue/bin/rescue-doc b/rescue/bin/rescue-doc new file mode 100755 index 000000000..e6514b462 --- /dev/null +++ b/rescue/bin/rescue-doc @@ -0,0 +1,57 @@ +#!/usr/bin/perl + +# From MDK::Common: +sub output { my $f = shift; open(my $F, ">$f") or die "output in file $f failed: $!\n"; print $F $_ foreach @_ } + +output('/tmp/rescue-doc-contents', q( + Information regarding problems not directly addressed + by this rescue. + + +Are you certain "rescue mode" is the best tool for your specific +problem? + +The rescue system on this CD is a very basic text-based +environment for rescuing systems that no longer boot. You will +not find an easy-to-use graphical environment in this rescue +system, nor the detection/configuration libraries. + + +The vast majority of problems that can affect a Linux system are +much easier to repair on a running system than by booting into +"rescue mode". In fact, there are very few problems which aren't +easier to resolve in the comfortable environment of a fully +installed system than in this spartan "rescue system" shell. +Some of the most common problems include: + +- bad or missing X (video display) configuration +- adding/removing/reconfiguring hardware +- repairing problems caused by installing third-party software + with the "--force" and "--nodeps" options + +The general rule of thumb is: "If you can boot into the Linux +system without using rescue mode or this CD, there is no real +reason to use the rescue CD". + + +However, if you can no longer boot into the system, the rescue +system is the right tool. Some common examples include: + +- If you previously changed some parameters in the /etc/fstab and + the system will no longer boot, fix the offending line while in + rescue mode, then try to boot normally into your system. + +- If the problem cannot be completely resolved in rescue mode + (for example, if you need to reconfigure the video display), + just modify what's necessary to boot into a running system, + then complete the fix from there. + +For more information on troubleshooting your system, +please consult the official manuals, the documentation on +wiki.mageia.org or support forum at forum.mageia.org. + + +)); + +exec 'less /tmp/rescue-doc-contents'; + diff --git a/rescue/bin/restore_ms_boot b/rescue/bin/restore_ms_boot new file mode 100755 index 000000000..1f8cc2907 --- /dev/null +++ b/rescue/bin/restore_ms_boot @@ -0,0 +1,74 @@ +#!/usr/bin/perl +# +# Guillaume Cottenceau, Pixel +# +# Copyright 2002-2005 Mandriva +# +# This software may be freely redistributed under the terms of the GNU +# public license. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# + +use lib qw(/usr/lib/libDrakX); +use common; +use bootloader; +use fs; +use fs::proc_partitions; +use partition_table::raw; + + +my @choices = map { + my $type = partition_table::raw::typeOfMBR($_->{dev}); + if_($type && member($type, bootloader::main_method_choices()) , [ $_->{dev}, $type ]); +} fs::proc_partitions::read_raw(); + +my $choice; + +if (!@choices) { + print "No known Linux bootloader has been found, nothing to do.\n"; +} elsif (@choices == 1) { + print "I've found a Linux bootloader only on <$choices[0][0]>.\n\n"; + $choice = $choices[0]; +} else { + print "I've found the following Linux bootloaders:\n", + (map_index { "\t" . $::i . ": <$_->[1]> \ton <$_->[0]>\n" } @choices), + "\n", + "Which disk/partition do you want to overwrite with the Windows bootloader?\n", + "\t "; + if ( =~ /^(\d+)$/i && $1 >= 1) { + $choice = $choices[$1 - 1]; + } +} + +if ($choice) { + print "I'm going to overwrite bootloader on <$choice->[0]> with +Windows bootloader. + +Ok? "; + =~ /^n/i and exit 0; + + system('dd', 'if=/usr/lib/extipl/aldebaran.bin', "of=/dev/$choice->[0]") == 0 + or print "\tFailed!\n"; +} + +#------------------------------------------------- +#- $Log$ +#- Revision 1.5 2005/06/13 04:33:50 prigaux +#- move functions using /proc/partitions out of fsedit to fs::proc_partitions +#- +#- Revision 1.4 2005/05/19 08:59:54 prigaux +#- rewrite using DrakX modules +#- +#- Revision 1.3 2005/04/19 12:49:39 prigaux +#- update copyright +#- +#- Revision 1.2 2004/07/20 02:42:12 prigaux +#- MandrakeSoft -> Mandrakesoft +#- +#- Revision 1.1 2002/02/27 13:31:30 gc +#- add "restore Windows Boot Loader" to rescue +#- +#- diff --git a/rescue/diskdrake-resize b/rescue/diskdrake-resize deleted file mode 100755 index 88372aac7..000000000 --- a/rescue/diskdrake-resize +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/perl - -use lib qw(/usr/lib/libDrakX); - -use devices; -use log; -use resize_fat::main; -use diskdrake::resize_ntfs; -use diskdrake::resize_ext2; - -my ($device, $fs_type, $size) = @ARGV - or die "usage: $0 \n"; - -my %fs_pkgs = ( - vfat => 'resize_fat::main', - ntfs => 'diskdrake::resize_ntfs', - ext2 => 'diskdrake::resize_ext2', - ext3 => 'diskdrake::resize_ext2', - ext4 => 'diskdrake::resize_ext2', -); - -my $resize_pkg = $fs_pkgs{$fs_type} - or die "no support for $fs_type type\n"; - -log::l("resizing $device to $size"); - -my $resize = $resize_pkg->new($device, devices::make($device)) - or die "unable to initialize resize\n"; -$resize->resize($size); diff --git a/rescue/drvinst b/rescue/drvinst deleted file mode 100755 index 4868b42e0..000000000 --- a/rescue/drvinst +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/perl -# -# Guillaume Cottenceau -# -# Copyright 2000-2005 Mandriva -# -# This software may be freely redistributed under the terms of the GNU -# public license. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# - -use lib qw(/usr/lib/libDrakX); -use common; -use detect_devices; - -$ARGV[0] =~ /^--?h/ and die "usage: drivers_install [drivertype1 [drivertype2 ...]]\n"; -my @types = @ARGV; - -sub install_module { - my ($driver, $descr) = @_; - print STDERR qq(Installing driver $driver (for "$descr")\n); - system("/sbin/modprobe", $driver) and print "\tfailed\n"; -} - -#- start -foreach my $card (detect_devices::pci_probe()) { - # ignoring "unknown", "Card:foobar" and the like as well as video cards: - $card->{driver} eq 'unknown' || $card->{driver} =~ /:/ and next; - $card->{media_type} eq "DISPLAY_VGA" and next; - - # load drivers for selected categories or for everything if no args: - if (!@ARGV || find { $card->{media_type} =~ /$_/i } @types) { - install_module($card->{driver}, $card->{description}); - } -} diff --git a/rescue/genpasswd b/rescue/genpasswd deleted file mode 100755 index 2f129673d..000000000 --- a/rescue/genpasswd +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/perl - -use strict; - -system "stty -echo"; -print STDERR "Give a password for ssh access: "; -chomp(my $word = ); -print STDERR "\n"; -system "stty echo"; - -my @salt = ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[rand 64, rand 64]; -print crypt($word, join('', @salt)); -print "\n"; diff --git a/rescue/grabjournallogs b/rescue/grabjournallogs deleted file mode 100755 index ef2ea4a1d..000000000 --- a/rescue/grabjournallogs +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash - -if ! mountpoint -q /mnt ; then - echo "I do not seem to see a Mageia install mounted on /mnt. You need to mount it first!" >&2 - exit 1 -fi - -if [ ! -f /mnt/etc/machine-id ]; then - echo "Cannot find machine-id file (/mnt/etc/machine-id)" >&2 - exit 1 -fi - -MID=$(cat /mnt/etc/machine-id) -echo -echo "Found machine-id: $MID" -if [ ! -d /mnt/var/log/journal/$MID ]; then - echo "Cannot find journal log directory (/mnt/var/log/journal/)" >&2 - exit 1 -fi - -TIMEFRAME=24 -if [ -n "$1" ]; then - NEWTIMEFRAME=$(( 0 + $1 )) - if [ $NEWTIMEFRAME -gt 0 ]; then - TIMEFRAME=$NEWTIMEFRAME - fi -fi -SINCE="$(LC_ALL=c date --date=$TIMEFRAME' hours ago' +'%F %T')" -echo "Will collect logs from the last $TIMEFRAME hour(s)" -echo " NB give numeric argument to override capture period" - -TEMPFILE=$(mktemp /tmp/grabjournallogs.XXXXXX) -echo -n "Extracting logs... " -journalctl -D /mnt/var/log/journal/$MID --since "$SINCE" -o short >$TEMPFILE -echo "done" - -if [ $(cat $TEMPFILE | wc -l) -lt 2 ]; then - rm -f $TEMPFILE - echo >&2 - echo "Cannot find any logs. Consider increasing the capture period by passing a" >&2 - echo "numeric argument larger than $TIMEFRAME." >&2 - exit 1 -fi - -echo -n "Compressing logs... " -cat $TEMPFILE | xz >/journallogs.xz -rm -f $TEMPFILE -echo "done" - -echo -echo "Your logs have been extracted to the file 'journallogs.xz'" diff --git a/rescue/guessmounts b/rescue/guessmounts deleted file mode 100755 index 27b920c9d..000000000 --- a/rescue/guessmounts +++ /dev/null @@ -1,145 +0,0 @@ -#!/usr/bin/perl -# -# Guillaume Cottenceau -# -# Copyright 2001-2005 Mandriva -# -# This software may be freely redistributed under the terms of the GNU -# public license. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# - -use lib qw(/usr/lib/libDrakX); -use common; -use devices; -use fs; -use fs::dmcrypt; -use fs::proc_partitions; -use fs::type; -use lvm; -use run_program; - -my @proc_mounts = fs::read_fstab('', '/proc/mounts'); - -my $target = '/mnt'; - -if (fs::get::mntpoint2part($target, \@proc_mounts)) { - print STDERR "$target is already mounted (according to /proc/mounts)\n"; - exit 0; -} - -system('drvinst', 'STORAGE'); - -print STDERR "\nPlease wait, trying to find your root device...\n"; - -mkdir_p($target); - -{ - local $::isInstall = 1; # so that detect_during_install() got called by init: - lvm::init(); -} -fs::dmcrypt::init; - -my @parts = map { - $_->{device} = delete $_->{dev}; - put_in_hash($_, fs::type::type_subpart_from_magic($_)); -} fs::proc_partitions::read_raw(); -my ($raid_parts, $normal_parts) = partition { isRawRAID($_) } @parts; - -if (@$raid_parts) { - require raid; - raid::detect_during_install(@$raid_parts); - my $raids = raid::get_existing(@$raid_parts); - push @$normal_parts, @$raids; -} - -my @roots; - -my $arch = arch() =~ /i.86/ ? $MDK::Common::System::compat_arch{arch()} : arch(); -foreach (@$normal_parts) { - my $dev = devices::make($_->{device}); - - my $fs = find { - system("mount -t $_ $dev $target 2>/dev/null") == 0; - } fs::type::true_local_fs_types() or next; - - if (my $release_file = common::release_file($target)) { - my $release = chomp_(cat_("$target$release_file")); - print STDERR "=> found a $release root partition on $dev\n=> type $fs, version `\n"; - my @fstab = fs::read_fstab($target, '/etc/fstab'); - my $h = common::parse_release_file($target, $release_file, $_); - add2hash($h, { dev => $dev, fs => $fs, fstab => \@fstab, - pretty_name => "$h->{release} $h->{version} $h->{arch} on $dev" }); - # Offer to rescue only same arch: - $h->{pretty_name} .= " (cannot be rescued: $h->{arch} ne $arch;)" if $h->{arch} ne $arch; - push @roots, $h; - } - system('umount', $target) == 0 or die "error unmounting $target\n"; -} - -my ($root, $fs, @fstab); - -# Try Mageia first: -if (@roots) { - # Order by release number: - @roots = sort { $b->{version} cmp $a->{version} } @roots; - # Then pick mga over mdv: - @roots = map { @$_ } partition { $_->{release} =~ /Mageia/ } @roots; - - my $selected; - if (@roots == 1) { - $selected = first(@roots); - } else { - print "\n\nWhich system do you want to rescue?\n0: Abort\n"; - each_index { print $::i + 1, ": $_->{pretty_name}\n" } @roots; - my $res; - while ($res < 1 || $res > @roots) { - print "what is your choice (type the number of your selection or C^c to abort)?\n"; - $res = <>; - chomp($res); - if ($res eq "0") { - print "Aborting\n"; - exit(1); - } - } - $selected = $roots[$res-1]; - } - - $root = $selected->{dev}; - $fs = $selected->{fs}; - @fstab = @{$selected->{fstab}}; - print STDERR "=> Selecting $root as root fs\n"; -} - -if ($root) { - system("mount -t $fs $root $target 2>/dev/null"); - - print STDERR "\nMounting other partitions from fstab on $target...\n"; - foreach (@fstab) { - my ($valued_options, $options) = fs::mount_options::unpack($_); - - next if - !$_->{fs_type} || $_->{device} eq 'none' - || $valued_options->{noauto} - || $_->{mntpoint} eq '/' - || member($_->{fs_type}, 'swap', 'nfs', 'ntfs', 'ntfs-3g'); - - delete $valued_options->{'iocharset='}; - delete $valued_options->{'codepage='}; - fs::mount_options::pack($_, $valued_options, $options); #- vfat opts, we don't have the modules in rescue - - my $where = "$target$_->{mntpoint}"; - my $dev = fs::wild_device::from_part('', $_); - mkdir_p($where); - print STDERR "\t$dev on $where type $_->{fs_type} options $_->{options}\n"; - system("mount -t $_->{fs_type} $dev $where -o $_->{options}"); - } - system("mount -t proc proc $target/proc"); - print STDERR "\nYour system is ready on $target.\n\n"; -} else { - die "Could not find your root device :-(.\n"; -} - diff --git a/rescue/install_bootloader b/rescue/install_bootloader deleted file mode 100755 index 7328de1d2..000000000 --- a/rescue/install_bootloader +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/perl -# -# Guillaume Cottenceau -# -# Copyright 2001-2005 Mandriva -# -# This software may be freely redistributed under the terms of the GNU -# public license. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# - -use lib qw(/usr/lib/libDrakX); -use common; -use bootloader; -use fs; - -my $auto; -if ($ARGV[0] eq '--auto') { - $auto = shift @ARGV; -} - -$::prefix = '/mnt'; - -my $release = common::mageia_release($::prefix) || - do { - system('guessmounts') == 0 or die 'guessmounts failed'; - common::mageia_release($::prefix); - }; - -if ($release) { - $release =~ /Mageia|Mandriva/ or die "release file doesn't contain '%s', exiting.\n"; -} elsif (fs::get::mntpoint2part($::prefix, [ fs::read_fstab('', '/proc/mounts') ])) { - die "unknown distribution mounted in $::prefix\n"; -} else { - die "Your root device isn't mounted on $::prefix\n"; -} - -my @main_methods = bootloader::configured_main_methods(); - -my $main_method; -if (@main_methods == 0) { - die "Cannot find a configured boot loader\n"; -} elsif (@main_methods == 1) { - ($main_method) = @main_methods; -} else { - while (1) { - print "Configuration files for Boot Loaders ", join(' and ', @main_methods), " were found.\n"; - print "Which one one should be installed? "; - chomp($main_method = ); - if (member($main_method, @main_methods)) { - last; - } else { - print "bad choice\n"; - } - } -} - -my $install = $bootloader::{'install_raw_' . $main_method} or die "unknown bootloader method install_raw_$main_method\n"; - -print "About to re-install Boot Loader $main_method of following %s distribution:\n\t", - $release, "\n"; -if (!$auto) { - print "=> ok? "; - =~ /^n/i and exit 0; -} - -run_program::run('mount', '--bind', '/dev', "$::prefix/dev"); -$install->(); -run_program::run('umount', "$::prefix/dev"); diff --git a/rescue/list.xml b/rescue/list.xml index 29139f46d..d4c0adcb4 100644 --- a/rescue/list.xml +++ b/rescue/list.xml @@ -410,15 +410,18 @@ - - rescue-doc drvinst lsparts - guessmounts install_bootloader + + bin/rescue-doc + bin/drvinst + bin/lsparts + bin/guessmounts + bin/install_bootloader - restore_ms_boot + bin/restore_ms_boot - - partimage_whole_disk + + sbin/partimage_whole_disk @@ -439,20 +442,6 @@ dhcp-client - - - diskdrake-resize - genpasswd - startssh - grabjournallogs - - - restore-image.sh - - - restore-image-lib.sh - - dirname diff --git a/rescue/lsparts b/rescue/lsparts deleted file mode 100755 index 8d36a02f4..000000000 --- a/rescue/lsparts +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/perl -# -# Main author Pascal Rigaux (pixel) -# Put together by Guillaume Cottenceau -# -# Copyright 1999-2005 Mandriva -# -# This software may be freely redistributed under the terms of the GNU -# public license. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# -# Detects partition types using signatures -# - -use lib qw(/usr/lib/libDrakX); -use common; -use fs::type; -use fs::proc_partitions; - -my $params = join '', @ARGV; -my $verbose = $params =~ /-v/; - -$params =~ /-h/ and die "usage: lsparts [-v]\n"; - - -foreach (fs::proc_partitions::read_raw()) { - if (my $err = $_->{size} <= 1 ? - "Skipping <$_->{dev}> because too little blocks ($_->{size})" : - $_->{dev} !~ /\d$/ ? - "Skipping <$_->{dev}> because doesn't end with a number (e.g. seems to not be a partition)" : - $_->{dev} =~ /^loop\d+$/ ? - "Skipping <$_->{dev}>" : - '') { - print STDERR "$err\n" if $verbose; - } else { - $_->{device} = $_->{dev}; - if (my $type = fs::type::type_subpart_from_magic($_)) { - printf "$_->{dev}: %6s, fs %s (%s)\n", formatXiB($_->{size} * 512), $type->{fs_type}, fs::type::part2type_name($type); - } - } -} diff --git a/rescue/partimage_whole_disk b/rescue/partimage_whole_disk deleted file mode 100755 index ed0653a95..000000000 --- a/rescue/partimage_whole_disk +++ /dev/null @@ -1,264 +0,0 @@ -#!/usr/bin/perl - -use lib qw(/usr/lib/libDrakX); -use standalone; -use fsedit; -use fs::format; -use fs::type; -use resize_fat::main; -use diskdrake::resize_ntfs; -use diskdrake::resize_ext2; -use common; -use partition_table::empty; -use Carp::Heavy; - -my %options = ( - save_home_directory => 1, - empty_space_at_end_of_disk => 0, # 300 * 1024 * 2, # 300MB - ask_before_modifying_home => 1, - bzip2 => 1, -); - -my ($server); -if ($ARGV[0] eq '-s') { - (undef, $server, @ARGV) = @ARGV; -} -my $action = shift @ARGV; - -sub usage() { die "partimage_whole_disk [-s ] (save_all | rest_all )\n" } - -$ENV{PATH} = "/sbin:/usr/sbin:$ENV{PATH}"; -$ENV{HOME} = '/'; -log::openLog("/var/log/partimage_whole_disk.log"); -my @partimage_cmd = ('partimage', if_($server, '-s', $server, '-n', '-L')); - -@ARGV == 1 or usage(); - -if ($server && !is_network_configured()) { - run_program::run('drvinst', 'NETWORK'); - run_program::run('dhcp-client'); -} - -run_program::run('drvinst', 'STORAGE_SCSI', 'STORAGE_IDE'); - -my $all_hds = fsedit::get_hds({}); - -if ($action eq 'save_all') { - save_all($ARGV[0]); -} elsif ($action eq 'rest_all') { - rest_all($ARGV[0]); -} - -sub save_all { - my ($dir) = @_; - - my $base_dir = $dir; - for (my $i = 0; read_part_list($dir); $i++) { - #- find a free dir - $dir = sprintf("$base_dir.%03d", $i); - } - - my $hd = $all_hds->{hds}[0] or die "no main hard drive\n"; - log::l("save_all on $hd->{device}"); - my $part_list = [ partition_table::get_normal_parts($hd) ]; - - foreach (@$part_list) { - $_->{saved} = !member($_->{fs_type}, 'ntfs', 'ntfs-3g', 'vfat', 'swap'); - } - - if (!$options{save_home_directory}) { - #- shrink and don't save the last ext3 partition (which is the /home partition) - if (my $part = find { isTrueLocalFS($_) } reverse @$part_list) { - $part->{size} = min($part->{size}, 1024 * 1024 * 2); # not greater than 1GB - $part->{saved} = 0; - } - } - - foreach (grep { $_->{saved} } @$part_list) { - run_or_die(@partimage_cmd, - if_($options{bzip2}, '-z', 2), - '-V', 0, '--nombr', '--nodesc', '--nocheck', '-b', '-o', - 'save', devices::make($_->{device}), "$dir/$_->{device}"); - } - save_part_list($dir, $hd->{geom}, $part_list); -} -sub rest_all { - my ($dir) = @_; - - my ($forced_geom, $part_list) = read_part_list($dir) or error("read_part_list $dir failed"); - - (my $hd) = my @used_hds = uniq(map { - my $part = $_; - find { $part->{device} =~ /^\Q$_->{device}\E./ } fs::get::hds($all_hds) - or error("can't find hard drive for partition $part->{device}"); - } @$part_list); - - @used_hds >= 1 or error("no matching hd"); - @used_hds <= 1 or error("multiple hds: " . join(' ', map { $_->{device} } @used_hds)); - - fs::type::set_fs_type($_, $_->{fs_type}) foreach @$part_list; - put_in_hash($_, partition_table::hd2minimal_part($hd)) foreach @$part_list; - - my ($from_partimage, $other) = partition { $_->{saved} } @$part_list; - my ($from_resize, $created) = partition { member($_->{fs_type}, 'vfat', 'ntfs', 'ntfs-3g') } @$other; - - my $total = sum(map { $_->{size} } @$part_list); - if ($total > $hd->{totalsectors}) { - error("$dir doesn't fit: $total > $hd->{totalsectors}"); - } - - - foreach (@$from_resize) { - #- resize first - my $part = fs::get::device2part($_->{device}, [ fs::get::fstab($all_hds) ]); - if (!$part) { - log::l("partition to resize is missing ($_->{device})"); - $_->{missing} = 1; - next; - } - if ($part->{fs_type} ne $_->{fs_type}) { - log::l("partition $_->{device} doesn't have the right filesystem ($part->{fs_type} != $_->{fs_type})"); - $_->{missing} = 1; - next; - } - - if (@$from_resize == 1) { - my $half_size = int($hd->{totalsectors} / 2) - 2 * $hd->cylinder_size; - my $suggested_total = $total - $_->{size} + $half_size; - log::l("resizing bigger? (size $_->{size}, half_size $half_size, total $total, suggested_total $suggested_total)"); - if ($half_size > $_->{size} && $suggested_total < $hd->{totalsectors}) { - log::l("prefering to resize $_->{device} to size $half_size instead of $_->{size}"); - $_->{size} = $half_size; - } - } - - $_->{start} = $part->{start}; - if ($_->{size} < $part->{size}) { - log::l("resizing $_->{device} to $_->{size} (it is $part->{size})"); - my $resize_pkg = $_->{fs_type} eq 'vfat' ? 'resize_fat::main' : 'diskdrake::resize_ntfs'; - my $resize = $resize_pkg->new($_->{device}, devices::make($_->{device})); - $resize->resize($_->{size}); - } else { - log::l("no need to resize, instead setting $_->{device}'s size to $part->{size} instead of $_->{size}"); - $_->{size} = $part->{size}; - } - } - - put_in_hash($hd->{geom}, $forced_geom); - log::l("totalsectors $hd->{totalsectors} heads $hd->{geom}{heads} sectors $hd->{geom}{sectors}"); - partition_table::raw::compute_nb_cylinders($hd->{geom}, $hd->{totalsectors}); - - #- grow the last ext3 partition - if (my $part = find { isTrueLocalFS($_) } reverse @$part_list) { - $part->{ratio} = 1; - - if ($options{ask_before_modifying_home}) { - print "\nkeep existing /home? (Y/n) "; - if ( !~ /n/i) { - my $l = @$from_partimage > 1 ? $from_partimage : $created; - #- it was meant to be restored or formatted - my $p = pop @$l; - log::l("keeping existing /home: removing $p->{device}"); - } - } - } - - #- write the partition table - partition_table::raw::zero_MBR($hd); - foreach my $part (grep { $_->{rootDevice} eq $hd->{device} } @$part_list) { - next if $part->{missing}; - - my $hole = find { isEmpty($_) && $_->{size} >= $part->{size} } partition_table::get_normal_parts_and_holes($hd) or die "not enough room for $part->{device}"; - $part->{start} = $hole->{start}; - - log::l("handling $part->{device}"); - my $extended = $part->{device} =~ /(\d+)$/ && $1 > 4 && $hd->hasExtended; - - my %wanted_part = %$part; - if ($part->{ratio}) { - $part->{size} = $hole->{size} - ($options{empty_space_at_end_of_disk} || 0); - } else { - $part->{size} += $hd->{geom}{sectors} if $extended; - $part->{size} += $hd->cylinder_size if $part->{start} == 1; - } - log::l("adding $part->{device} with size $part->{size}"); - partition_table::add($hd, $part, $extended ? 'Extended' : 'Primary'); - foreach ('device', if_(!$part->{ratio}, 'size')) { - $part->{$_} eq $wanted_part{$_} or log::l("bad $_ for $part->{device}: $part->{$_} != $wanted_part{$_}"); - } - } - partition_table::write($hd); - - #- restore from partimage - foreach (@$from_partimage) { - run_or_die(@partimage_cmd, 'restore', '-b', devices::make($_->{device}), "$dir/$_->{device}"); - - if ($_->{ratio}) { - my $resize = diskdrake::resize_ext2->new($_->{device}, devices::make($_->{device})); - $resize->resize($_->{size}); - } - } - - foreach (@$created) { - fs::format::part_raw($_, undef); - } - - run_program::run('guessmounts'); - - if (my @missing = grep { $_->{missing} } @$part_list) { - my $missing = join('|', map { quotemeta($_->{device}) } @missing); - log::l("drop missing devices from fstab and lilo.conf: $missing"); - $::prefix = '/mnt'; - substInFile { $_ = '' if m!^/dev/($missing)\s! } "$::prefix/etc/fstab"; - - my $match; - substInFile { - /^\S/ and $match = m!^other=/dev/($missing)$!; - $_ = '' if $match; - } "$::prefix/etc/lilo.conf"; - } - - run_or_die('install_bootloader', '--auto'); - - print "\n", "Your system is ready, press enter to reboot (Y/n) "; - if ( !~ /n/i) { - run_program::run('reboot'); - } -} - -sub lst_fields() { qw(device size fs_type saved) } -sub save_part_list { - my ($dir, $geom, $part_list) = @_; - my @l = map { join(' ', @$_{lst_fields()}) } @$part_list; - log::l("save_part_list $dir: $_") foreach @l; - my $partimage = join(' ', @partimage_cmd); - open(my $F, "| $partimage -z0 -Bfoo=bar -o save_file $dir/lst"); - print $F join("/", $geom->{heads}, $geom->{sectors}), "\n"; - print $F "$_\n" foreach @l; -} -sub read_part_list { - my ($dir) = @_; - my $partimage = join(' ', @partimage_cmd); - open(my $F, "$partimage -z0 -Bfoo=bar rest_file $dir/lst |"); - my $geom_string = <$F> or return; - my %geom; @geom{'heads', 'sectors'} = split('/', chomp_($geom_string)); - my @l = chomp_(cat__($F)); - log::l("read_part_list $dir: $_") foreach @l; - \%geom, [ map { my %l; @l{lst_fields()} = split; \%l } @l ]; -} - -sub run_or_die { - my (@l) = @_; - run_program::raw({ timeout => 4 * 60 * 60 }, @l) or die join(' ', @l) . " failed\n"; -} - -sub error { - my ($msg) = @_; - log::l($msg); - die "$msg\n"; -} - -sub is_network_configured() { - my (undef, @l) = cat_('/proc/net/route'); - find { /^(\S+)/ && $1 ne 'lo' } @l; -} diff --git a/rescue/rescue-doc b/rescue/rescue-doc deleted file mode 100755 index e6514b462..000000000 --- a/rescue/rescue-doc +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/perl - -# From MDK::Common: -sub output { my $f = shift; open(my $F, ">$f") or die "output in file $f failed: $!\n"; print $F $_ foreach @_ } - -output('/tmp/rescue-doc-contents', q( - Information regarding problems not directly addressed - by this rescue. - - -Are you certain "rescue mode" is the best tool for your specific -problem? - -The rescue system on this CD is a very basic text-based -environment for rescuing systems that no longer boot. You will -not find an easy-to-use graphical environment in this rescue -system, nor the detection/configuration libraries. - - -The vast majority of problems that can affect a Linux system are -much easier to repair on a running system than by booting into -"rescue mode". In fact, there are very few problems which aren't -easier to resolve in the comfortable environment of a fully -installed system than in this spartan "rescue system" shell. -Some of the most common problems include: - -- bad or missing X (video display) configuration -- adding/removing/reconfiguring hardware -- repairing problems caused by installing third-party software - with the "--force" and "--nodeps" options - -The general rule of thumb is: "If you can boot into the Linux -system without using rescue mode or this CD, there is no real -reason to use the rescue CD". - - -However, if you can no longer boot into the system, the rescue -system is the right tool. Some common examples include: - -- If you previously changed some parameters in the /etc/fstab and - the system will no longer boot, fix the offending line while in - rescue mode, then try to boot normally into your system. - -- If the problem cannot be completely resolved in rescue mode - (for example, if you need to reconfigure the video display), - just modify what's necessary to boot into a running system, - then complete the fix from there. - -For more information on troubleshooting your system, -please consult the official manuals, the documentation on -wiki.mageia.org or support forum at forum.mageia.org. - - -)); - -exec 'less /tmp/rescue-doc-contents'; - diff --git a/rescue/restore-image-lib.sh b/rescue/restore-image-lib.sh deleted file mode 100755 index 3451f7be5..000000000 --- a/rescue/restore-image-lib.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/bash - -TITLE="%s Installer" -BACKTITLE="%s" -MIN_DISKSIZE=5000000 - -debug="/dev/null" - -function _msgbox() -{ - dialog --timeout 60 --backtitle "$BACKTITLE" --title "$TITLE" --msgbox \ - "$1" 0 0 - - return $? -} - -function _infobox() -{ - dialog --backtitle "$BACKTITLE" --title "$TITLE" --sleep 2 \ - --infobox "$1" 0 0 - - return $? -} - -function _yesno() -{ - dialog --backtitle "$BACKTITLE" --title "$TITLE" \ - --yes-label "Yes" --no-label "No" --yesno "$1" 0 0 - - return $? -} - -function _mount() -{ - mount $1 $2 > $debug 2>&1 - - return $? -} - -function _umount() -{ - umount $1 > $debug 2>&1 - - return $? -} - -function _bind() -{ - mount --bind $1 $2 > $debug 2>&1 - - return $? -} - -function _eject() -{ - eject $1 > $debug 2>&1 - - return $? -} - -function _shutdown() -{ - [ -e /tmp/no-shutdown ] && exit - clear - sync - echo s > /proc/sysrq-trigger - echo o > /proc/sysrq-trigger - exit -} - -function _reboot() -{ - [ -e /tmp/no-shutdown ] && exit - clear - sync - echo s > /proc/sysrq-trigger - echo b > /proc/sysrq-trigger - exit -} - diff --git a/rescue/restore-image.sh b/rescue/restore-image.sh deleted file mode 100755 index f4f904f3f..000000000 --- a/rescue/restore-image.sh +++ /dev/null @@ -1,412 +0,0 @@ -#!/bin/bash - -setterm -powersave off -setterm -blank 0 - -if [ -r ./restore-image-lib.sh ]; then - . ./restore-image-lib.sh -elif [ -r /usr/lib/restore-image-lib.sh ]; then - . /usr/lib/restore-image-lib.sh -fi - -export PATH="/sbin:/bin:/usr/sbin:/usr/bin" - -mnt_dir="/tmp/mnt" -restore_media="/tmp/media" -images_dir="$restore_media/images" -images="$images_dir/list" -images_config="$images_dir/config" -image="" -win32_part_dev= -win32_part_type= -win32_part_new_size= - -function read_config() -{ - if [ -r "$images_config" ]; then - . $images_config - fi -} - -function image_list() -{ - list=$(cat $images | awk -F',' \ - '{ print $1 " " $2 " " $4 }') - - echo $list -} - -function image_file() -{ - country="$1" - - file=$(grep ^$country $images | awk -F',' '{ print $3 }') - - echo $file -} - -function welcome() -{ - while true; do - clear - msg="\n Welcome to $TITLE\n\ -\nThe following images were found, select one:\n " - opcao=$(dialog --backtitle "$BACKTITLE" --title "$TITLE" \ - --stdout --radiolist "$msg" 0 0 0 \ - $(image_list)) - - if [ "$?" != "0" ]; then - _yesno "\nInterrupt installation?\n " - if [ "$?" = "0" ]; then - _shutdown - fi - else - if [ -z "$opcao" ]; then - continue - else - image=$(image_file $opcao) - break - fi - fi - done - - # disable kernel messages in the console - echo "1 4 1 7" > /proc/sys/kernel/printk -} - -function install_warning() -{ - if [ -n "${win32_part_dev}" ]; then - warn_msg="Windows installation detected.\nWe will set it up as dual boot. \ -You may lose some data.\nPlease backup before proceeding." - else - warn_msg="WARNING: This process will erase all data in this machine, \ -do you want to continue?" - fi - - clear - _yesno "\n$warn_msg\n" - if [ "$?" != "0" ]; then - _shutdown - fi -} - -function detect_root() -{ - inst_source_dev=$(awk "\$2 == \"$restore_media\" { print \$1 }" /proc/mounts | sed -e 's/[0-9]$//') - inst_source_dev=${inst_source_dev#/dev/} - devices=$(grep "^ .*[^0-9]$" < /proc/partitions | grep -v ${inst_source_dev} | awk '$3 > '$MIN_DISKSIZE' { print $4,$3 }') - - if [ -z "${devices}" ]; then - exit 1 - fi - - devs_found=$(($(echo $devices | wc -w)/2)) - - root_data=$(detect_win32 ${inst_source_dev}) - - if [ -z "${root_data}" ]; then - if [ "$devs_found" -gt "1" ]; then - if [ -n "${inst_source_dev}" ]; then - opcao=$(dialog --backtitle "$BACKTITLE" --title "$TITLE" --stdout --menu 'Choose one of the detected devices to restore to (check the blocks size column first):' 8 50 0 $devices ) - if [ "$?" != "0" ]; then - _yesno "\nInterrupt installation?\n " - if [ "$?" = "0" ]; then - _shutdown - fi - else - root_data=${opcao} - fi - fi - else - root_data=$(echo ${devices} | cut -d ' ' -f 1) - fi - fi - - echo ${root_data} -} - -function detect_win32() -{ - # from detect_root() - skip_dev=${1} - - # win32 detection won't handle complex layouts - if [ $(fdisk -l | grep "^/dev/" | grep -v ${skip_dev} | wc -l) -gt 1 ]; then - exit - fi - - # get the last created windows partition information - set -f - device=$(fdisk -l | grep "^/dev/" | grep -v ${skip_dev} | grep -e "FAT\|NTFS\|HPFS" | tail -1 | sed 's/ .*$//') - set +f - - if [ -z "${device}" ]; then - exit - fi - - # it might be needed, for safety - device_type=$(blkid -o value -s TYPE ${device}) - modprobe ${device_type} - - # df for that partition - mount ${device} /mnt - size=$(df ${device} | tail -1) - umount /mnt - - # its diskspace - used=$(echo ${size} | awk '{ print $3 }') - left=$(echo ${size} | awk '{ print $4 }') - avail=$((${left}/2)) - - if [ ! ${avail} -lt ${MIN_DISKSIZE} ]; then - win32_part_dev=${device} - win32_part_type=${device_type} - # our install takes half of 'left' - win32_part_new_size=$((${used}+${avail})) - - dev=${win32_part_dev#/dev/} - disk=${dev%[0-9]} - number=${dev#[a-w][a-w][a-w]} - let number++ - echo ${disk}${number} ${win32_part_dev} ${win32_part_type} ${win32_part_new_size} - fi -} - -function resize_win32() -{ - device=${1} - device_type=${2} - new_win32_size=${3} - - dialog --backtitle "$BACKTITLE" --title "$TITLE" --infobox "\nResizing Windows partition...\n" 4 55 - - dev=${device#/dev/} - disk=${dev%[0-9]} - win32_number=${dev#[a-w][a-w][a-w]} - - case ${device_type} in - vfat) device_id=b ;; - ntfs) device_id=7 ;; - hpfs) device_id=87 ;; - esac - - # wrapper around libdrakx by blino - diskdrake-resize ${device} ${device_type} $((${new_win32_size}*2)) &>/dev/null - - # we need some free sector here, rebuilding layout - fdisk /dev/${disk} &>/dev/null </dev/null </dev/null; dd bs=4M of=/dev/${root} >/tmp/backup.out 2>&1>>/tmp/log) & - - sleep 3 - pid=$(ps ax | grep 'dd bs=4M of' | grep -v grep | awk '{ print $1 }') - - while [ true ]; do - ps | grep -q $pid - if [ $? -eq 0 ]; then - /bin/kill -SIGUSR1 $pid - complete=$(tail -n 1 /tmp/backup.out | awk '{ print $1 }') - echo $((complete*100/total)) - sleep 1 - else - break - fi - done | dialog --backtitle "$BACKTITLE" --title "$TITLE" --gauge "\nWriting image..." 8 45 - - in=$(tail -n 3 /tmp/backup.out | grep 'in$' | cut -d' ' -f1) - out=$(tail -n 3 /tmp/backup.out | grep 'out$' | cut -d' ' -f1) - - if [ x"$in" != x"$out" ]; then - _msgbox "\nError writing image!\n" - sleep 24h - fi - - # Now re-read the partition table because 'dd' might have changed it - sfdisk -R /dev/${root} -} - -function grub_setup() -{ - root=${1} - grub_dir=${2} - - # install the bootloader - grub <> ${grub_dir}/menu.lst </dev/null| grep "Filesystem OS type" | awk '{ print $4 }') - if [ "${filesystem_type}" = "Linux" ]; then - dialog --backtitle "$BACKTITLE" --title "$TITLE" --infobox "Finishing Install... Expanding ${root}" 3 40 - disk=/dev/${root%[0-9]} - main_part=/dev/${root} - - # FIXME: absurdly dirty hack - main_part_num=${root:3} - swap_part_num=$((main_part_num+1)) - swap_part=${disk}${swap_part_num} - - main_part_sectors= - if [ -n "$SWAP_BLOCKS" ]; then - if [ -n "$EXPAND_FS" ]; then - total_blocks=$(sfdisk -s $disk) - main_part_blocks=$((total_blocks-SWAP_BLOCKS)) - main_part_sectors=$((main_part_blocks*2)) - else - main_part_sectors=$(sfdisk -d $disk | perl -lne 'm|^'$main_part'\b.*,\s*size\s*=\s*(\d+)\b| and print($1), exit') - fi - fi - if [ -n "$SWAP_BLOCKS" ]; then - parted $disk -- mkpartfs primary linux-swap ${main_part_sectors}s -1s yes - mkswap -L swap $swap_part - fi - if [ -n "$EXPAND_FS" ]; then - e2fsck -fy $main_part - fdisk $disk << EOF -d -$main_part_num -n -p -$main_part_num - - -a -$main_part_num -w -EOF - sfdisk -R $disk - e2fsck -fy $main_part - resize2fs $main_part - fi - mkdir -p $mnt_dir - mount $main_part $mnt_dir - grub_dir="$mnt_dir/boot/grub" - if [ -d "$grub_dir" ]; then - echo "(hd0) $disk" > "$grub_dir/device.map" - if [ -n "$win32_part_dev" ]; then - grub_setup ${root} ${grub_dir} - fi - fi - if [ -n "$MKINITRD" ]; then - mount -t sysfs none "$mnt_dir/sys" - mount -t proc none "$mnt_dir/proc" - chroot $mnt_dir bootloader-config --action rebuild-initrds - umount "$mnt_dir/sys" - umount "$mnt_dir/proc" - fi - umount $mnt_dir - fi -} - -# installation steps -welcome -read_config -detect_device -install_warning -write_image -expand_fs - -# all done! -_msgbox "\nInstallation process finished.\nPress ENTER to shutdown.\n " - -_shutdown - diff --git a/rescue/restore_ms_boot b/rescue/restore_ms_boot deleted file mode 100755 index 1f8cc2907..000000000 --- a/rescue/restore_ms_boot +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/perl -# -# Guillaume Cottenceau, Pixel -# -# Copyright 2002-2005 Mandriva -# -# This software may be freely redistributed under the terms of the GNU -# public license. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# - -use lib qw(/usr/lib/libDrakX); -use common; -use bootloader; -use fs; -use fs::proc_partitions; -use partition_table::raw; - - -my @choices = map { - my $type = partition_table::raw::typeOfMBR($_->{dev}); - if_($type && member($type, bootloader::main_method_choices()) , [ $_->{dev}, $type ]); -} fs::proc_partitions::read_raw(); - -my $choice; - -if (!@choices) { - print "No known Linux bootloader has been found, nothing to do.\n"; -} elsif (@choices == 1) { - print "I've found a Linux bootloader only on <$choices[0][0]>.\n\n"; - $choice = $choices[0]; -} else { - print "I've found the following Linux bootloaders:\n", - (map_index { "\t" . $::i . ": <$_->[1]> \ton <$_->[0]>\n" } @choices), - "\n", - "Which disk/partition do you want to overwrite with the Windows bootloader?\n", - "\t "; - if ( =~ /^(\d+)$/i && $1 >= 1) { - $choice = $choices[$1 - 1]; - } -} - -if ($choice) { - print "I'm going to overwrite bootloader on <$choice->[0]> with -Windows bootloader. - -Ok? "; - =~ /^n/i and exit 0; - - system('dd', 'if=/usr/lib/extipl/aldebaran.bin', "of=/dev/$choice->[0]") == 0 - or print "\tFailed!\n"; -} - -#------------------------------------------------- -#- $Log$ -#- Revision 1.5 2005/06/13 04:33:50 prigaux -#- move functions using /proc/partitions out of fsedit to fs::proc_partitions -#- -#- Revision 1.4 2005/05/19 08:59:54 prigaux -#- rewrite using DrakX modules -#- -#- Revision 1.3 2005/04/19 12:49:39 prigaux -#- update copyright -#- -#- Revision 1.2 2004/07/20 02:42:12 prigaux -#- MandrakeSoft -> Mandrakesoft -#- -#- Revision 1.1 2002/02/27 13:31:30 gc -#- add "restore Windows Boot Loader" to rescue -#- -#- diff --git a/rescue/sbin/partimage_whole_disk b/rescue/sbin/partimage_whole_disk new file mode 100755 index 000000000..ed0653a95 --- /dev/null +++ b/rescue/sbin/partimage_whole_disk @@ -0,0 +1,264 @@ +#!/usr/bin/perl + +use lib qw(/usr/lib/libDrakX); +use standalone; +use fsedit; +use fs::format; +use fs::type; +use resize_fat::main; +use diskdrake::resize_ntfs; +use diskdrake::resize_ext2; +use common; +use partition_table::empty; +use Carp::Heavy; + +my %options = ( + save_home_directory => 1, + empty_space_at_end_of_disk => 0, # 300 * 1024 * 2, # 300MB + ask_before_modifying_home => 1, + bzip2 => 1, +); + +my ($server); +if ($ARGV[0] eq '-s') { + (undef, $server, @ARGV) = @ARGV; +} +my $action = shift @ARGV; + +sub usage() { die "partimage_whole_disk [-s ] (save_all | rest_all )\n" } + +$ENV{PATH} = "/sbin:/usr/sbin:$ENV{PATH}"; +$ENV{HOME} = '/'; +log::openLog("/var/log/partimage_whole_disk.log"); +my @partimage_cmd = ('partimage', if_($server, '-s', $server, '-n', '-L')); + +@ARGV == 1 or usage(); + +if ($server && !is_network_configured()) { + run_program::run('drvinst', 'NETWORK'); + run_program::run('dhcp-client'); +} + +run_program::run('drvinst', 'STORAGE_SCSI', 'STORAGE_IDE'); + +my $all_hds = fsedit::get_hds({}); + +if ($action eq 'save_all') { + save_all($ARGV[0]); +} elsif ($action eq 'rest_all') { + rest_all($ARGV[0]); +} + +sub save_all { + my ($dir) = @_; + + my $base_dir = $dir; + for (my $i = 0; read_part_list($dir); $i++) { + #- find a free dir + $dir = sprintf("$base_dir.%03d", $i); + } + + my $hd = $all_hds->{hds}[0] or die "no main hard drive\n"; + log::l("save_all on $hd->{device}"); + my $part_list = [ partition_table::get_normal_parts($hd) ]; + + foreach (@$part_list) { + $_->{saved} = !member($_->{fs_type}, 'ntfs', 'ntfs-3g', 'vfat', 'swap'); + } + + if (!$options{save_home_directory}) { + #- shrink and don't save the last ext3 partition (which is the /home partition) + if (my $part = find { isTrueLocalFS($_) } reverse @$part_list) { + $part->{size} = min($part->{size}, 1024 * 1024 * 2); # not greater than 1GB + $part->{saved} = 0; + } + } + + foreach (grep { $_->{saved} } @$part_list) { + run_or_die(@partimage_cmd, + if_($options{bzip2}, '-z', 2), + '-V', 0, '--nombr', '--nodesc', '--nocheck', '-b', '-o', + 'save', devices::make($_->{device}), "$dir/$_->{device}"); + } + save_part_list($dir, $hd->{geom}, $part_list); +} +sub rest_all { + my ($dir) = @_; + + my ($forced_geom, $part_list) = read_part_list($dir) or error("read_part_list $dir failed"); + + (my $hd) = my @used_hds = uniq(map { + my $part = $_; + find { $part->{device} =~ /^\Q$_->{device}\E./ } fs::get::hds($all_hds) + or error("can't find hard drive for partition $part->{device}"); + } @$part_list); + + @used_hds >= 1 or error("no matching hd"); + @used_hds <= 1 or error("multiple hds: " . join(' ', map { $_->{device} } @used_hds)); + + fs::type::set_fs_type($_, $_->{fs_type}) foreach @$part_list; + put_in_hash($_, partition_table::hd2minimal_part($hd)) foreach @$part_list; + + my ($from_partimage, $other) = partition { $_->{saved} } @$part_list; + my ($from_resize, $created) = partition { member($_->{fs_type}, 'vfat', 'ntfs', 'ntfs-3g') } @$other; + + my $total = sum(map { $_->{size} } @$part_list); + if ($total > $hd->{totalsectors}) { + error("$dir doesn't fit: $total > $hd->{totalsectors}"); + } + + + foreach (@$from_resize) { + #- resize first + my $part = fs::get::device2part($_->{device}, [ fs::get::fstab($all_hds) ]); + if (!$part) { + log::l("partition to resize is missing ($_->{device})"); + $_->{missing} = 1; + next; + } + if ($part->{fs_type} ne $_->{fs_type}) { + log::l("partition $_->{device} doesn't have the right filesystem ($part->{fs_type} != $_->{fs_type})"); + $_->{missing} = 1; + next; + } + + if (@$from_resize == 1) { + my $half_size = int($hd->{totalsectors} / 2) - 2 * $hd->cylinder_size; + my $suggested_total = $total - $_->{size} + $half_size; + log::l("resizing bigger? (size $_->{size}, half_size $half_size, total $total, suggested_total $suggested_total)"); + if ($half_size > $_->{size} && $suggested_total < $hd->{totalsectors}) { + log::l("prefering to resize $_->{device} to size $half_size instead of $_->{size}"); + $_->{size} = $half_size; + } + } + + $_->{start} = $part->{start}; + if ($_->{size} < $part->{size}) { + log::l("resizing $_->{device} to $_->{size} (it is $part->{size})"); + my $resize_pkg = $_->{fs_type} eq 'vfat' ? 'resize_fat::main' : 'diskdrake::resize_ntfs'; + my $resize = $resize_pkg->new($_->{device}, devices::make($_->{device})); + $resize->resize($_->{size}); + } else { + log::l("no need to resize, instead setting $_->{device}'s size to $part->{size} instead of $_->{size}"); + $_->{size} = $part->{size}; + } + } + + put_in_hash($hd->{geom}, $forced_geom); + log::l("totalsectors $hd->{totalsectors} heads $hd->{geom}{heads} sectors $hd->{geom}{sectors}"); + partition_table::raw::compute_nb_cylinders($hd->{geom}, $hd->{totalsectors}); + + #- grow the last ext3 partition + if (my $part = find { isTrueLocalFS($_) } reverse @$part_list) { + $part->{ratio} = 1; + + if ($options{ask_before_modifying_home}) { + print "\nkeep existing /home? (Y/n) "; + if ( !~ /n/i) { + my $l = @$from_partimage > 1 ? $from_partimage : $created; + #- it was meant to be restored or formatted + my $p = pop @$l; + log::l("keeping existing /home: removing $p->{device}"); + } + } + } + + #- write the partition table + partition_table::raw::zero_MBR($hd); + foreach my $part (grep { $_->{rootDevice} eq $hd->{device} } @$part_list) { + next if $part->{missing}; + + my $hole = find { isEmpty($_) && $_->{size} >= $part->{size} } partition_table::get_normal_parts_and_holes($hd) or die "not enough room for $part->{device}"; + $part->{start} = $hole->{start}; + + log::l("handling $part->{device}"); + my $extended = $part->{device} =~ /(\d+)$/ && $1 > 4 && $hd->hasExtended; + + my %wanted_part = %$part; + if ($part->{ratio}) { + $part->{size} = $hole->{size} - ($options{empty_space_at_end_of_disk} || 0); + } else { + $part->{size} += $hd->{geom}{sectors} if $extended; + $part->{size} += $hd->cylinder_size if $part->{start} == 1; + } + log::l("adding $part->{device} with size $part->{size}"); + partition_table::add($hd, $part, $extended ? 'Extended' : 'Primary'); + foreach ('device', if_(!$part->{ratio}, 'size')) { + $part->{$_} eq $wanted_part{$_} or log::l("bad $_ for $part->{device}: $part->{$_} != $wanted_part{$_}"); + } + } + partition_table::write($hd); + + #- restore from partimage + foreach (@$from_partimage) { + run_or_die(@partimage_cmd, 'restore', '-b', devices::make($_->{device}), "$dir/$_->{device}"); + + if ($_->{ratio}) { + my $resize = diskdrake::resize_ext2->new($_->{device}, devices::make($_->{device})); + $resize->resize($_->{size}); + } + } + + foreach (@$created) { + fs::format::part_raw($_, undef); + } + + run_program::run('guessmounts'); + + if (my @missing = grep { $_->{missing} } @$part_list) { + my $missing = join('|', map { quotemeta($_->{device}) } @missing); + log::l("drop missing devices from fstab and lilo.conf: $missing"); + $::prefix = '/mnt'; + substInFile { $_ = '' if m!^/dev/($missing)\s! } "$::prefix/etc/fstab"; + + my $match; + substInFile { + /^\S/ and $match = m!^other=/dev/($missing)$!; + $_ = '' if $match; + } "$::prefix/etc/lilo.conf"; + } + + run_or_die('install_bootloader', '--auto'); + + print "\n", "Your system is ready, press enter to reboot (Y/n) "; + if ( !~ /n/i) { + run_program::run('reboot'); + } +} + +sub lst_fields() { qw(device size fs_type saved) } +sub save_part_list { + my ($dir, $geom, $part_list) = @_; + my @l = map { join(' ', @$_{lst_fields()}) } @$part_list; + log::l("save_part_list $dir: $_") foreach @l; + my $partimage = join(' ', @partimage_cmd); + open(my $F, "| $partimage -z0 -Bfoo=bar -o save_file $dir/lst"); + print $F join("/", $geom->{heads}, $geom->{sectors}), "\n"; + print $F "$_\n" foreach @l; +} +sub read_part_list { + my ($dir) = @_; + my $partimage = join(' ', @partimage_cmd); + open(my $F, "$partimage -z0 -Bfoo=bar rest_file $dir/lst |"); + my $geom_string = <$F> or return; + my %geom; @geom{'heads', 'sectors'} = split('/', chomp_($geom_string)); + my @l = chomp_(cat__($F)); + log::l("read_part_list $dir: $_") foreach @l; + \%geom, [ map { my %l; @l{lst_fields()} = split; \%l } @l ]; +} + +sub run_or_die { + my (@l) = @_; + run_program::raw({ timeout => 4 * 60 * 60 }, @l) or die join(' ', @l) . " failed\n"; +} + +sub error { + my ($msg) = @_; + log::l($msg); + die "$msg\n"; +} + +sub is_network_configured() { + my (undef, @l) = cat_('/proc/net/route'); + find { /^(\S+)/ && $1 ne 'lo' } @l; +} diff --git a/rescue/startssh b/rescue/startssh deleted file mode 100755 index e14bb10e8..000000000 --- a/rescue/startssh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -# test for an up interface != lo -if test "x"`ifconfig | cut -d ' ' -f 1 | grep -v '^$' | grep -v lo` = "x"; then - echo "There is no up interface, you can try to execute 'drvinst' to find drivers and 'dhcp-client' to configure your interface for DHCP." >&2 - exit 5 -fi - -# generate host keys -mkdir -p /etc/dropbear -[[ -f /etc/dropbear/dropbear_dss_host_key ]] || dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key >/dev/null || { echo "Can't generate dsa host key" >&2 ; exit 4; } -[[ -f /etc/dropbear/dropbear_rsa_host_key ]] || dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key >/dev/null || { echo "Can't generate rsa host key" >&2 ; exit 3; } - -# set a password -passwd=`genpasswd` -if (( $? != 0 )); then - reset - exit $? -fi -sed -E -i -e 's/^root:[^:]*:/root:'"${passwd//\//\\/}"':/' /etc/passwd || { echo "Can't set password" >&2 ; exit 2; } - -# test for /dev/pts -grep '^devpts /dev/pts devpts ' /proc/mounts >/dev/null 2>/dev/null || mount -t devpts devpts /dev/pts - -echo "" -echo -n "Starting ssh daemon... " -dropbear -E 2>/var/log/dropbear.log && echo "OK" || { echo "Failed" ; exit 1; } diff --git a/rescue/tree/usr/lib/restore-image-lib.sh b/rescue/tree/usr/lib/restore-image-lib.sh new file mode 100755 index 000000000..3451f7be5 --- /dev/null +++ b/rescue/tree/usr/lib/restore-image-lib.sh @@ -0,0 +1,80 @@ +#!/bin/bash + +TITLE="%s Installer" +BACKTITLE="%s" +MIN_DISKSIZE=5000000 + +debug="/dev/null" + +function _msgbox() +{ + dialog --timeout 60 --backtitle "$BACKTITLE" --title "$TITLE" --msgbox \ + "$1" 0 0 + + return $? +} + +function _infobox() +{ + dialog --backtitle "$BACKTITLE" --title "$TITLE" --sleep 2 \ + --infobox "$1" 0 0 + + return $? +} + +function _yesno() +{ + dialog --backtitle "$BACKTITLE" --title "$TITLE" \ + --yes-label "Yes" --no-label "No" --yesno "$1" 0 0 + + return $? +} + +function _mount() +{ + mount $1 $2 > $debug 2>&1 + + return $? +} + +function _umount() +{ + umount $1 > $debug 2>&1 + + return $? +} + +function _bind() +{ + mount --bind $1 $2 > $debug 2>&1 + + return $? +} + +function _eject() +{ + eject $1 > $debug 2>&1 + + return $? +} + +function _shutdown() +{ + [ -e /tmp/no-shutdown ] && exit + clear + sync + echo s > /proc/sysrq-trigger + echo o > /proc/sysrq-trigger + exit +} + +function _reboot() +{ + [ -e /tmp/no-shutdown ] && exit + clear + sync + echo s > /proc/sysrq-trigger + echo b > /proc/sysrq-trigger + exit +} + diff --git a/rescue/tree/usr/sbin/diskdrake-resize b/rescue/tree/usr/sbin/diskdrake-resize new file mode 100755 index 000000000..88372aac7 --- /dev/null +++ b/rescue/tree/usr/sbin/diskdrake-resize @@ -0,0 +1,29 @@ +#!/usr/bin/perl + +use lib qw(/usr/lib/libDrakX); + +use devices; +use log; +use resize_fat::main; +use diskdrake::resize_ntfs; +use diskdrake::resize_ext2; + +my ($device, $fs_type, $size) = @ARGV + or die "usage: $0 \n"; + +my %fs_pkgs = ( + vfat => 'resize_fat::main', + ntfs => 'diskdrake::resize_ntfs', + ext2 => 'diskdrake::resize_ext2', + ext3 => 'diskdrake::resize_ext2', + ext4 => 'diskdrake::resize_ext2', +); + +my $resize_pkg = $fs_pkgs{$fs_type} + or die "no support for $fs_type type\n"; + +log::l("resizing $device to $size"); + +my $resize = $resize_pkg->new($device, devices::make($device)) + or die "unable to initialize resize\n"; +$resize->resize($size); diff --git a/rescue/tree/usr/sbin/genpasswd b/rescue/tree/usr/sbin/genpasswd new file mode 100755 index 000000000..2f129673d --- /dev/null +++ b/rescue/tree/usr/sbin/genpasswd @@ -0,0 +1,13 @@ +#!/usr/bin/perl + +use strict; + +system "stty -echo"; +print STDERR "Give a password for ssh access: "; +chomp(my $word = ); +print STDERR "\n"; +system "stty echo"; + +my @salt = ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[rand 64, rand 64]; +print crypt($word, join('', @salt)); +print "\n"; diff --git a/rescue/tree/usr/sbin/grabjournallogs b/rescue/tree/usr/sbin/grabjournallogs new file mode 100755 index 000000000..ef2ea4a1d --- /dev/null +++ b/rescue/tree/usr/sbin/grabjournallogs @@ -0,0 +1,51 @@ +#!/bin/bash + +if ! mountpoint -q /mnt ; then + echo "I do not seem to see a Mageia install mounted on /mnt. You need to mount it first!" >&2 + exit 1 +fi + +if [ ! -f /mnt/etc/machine-id ]; then + echo "Cannot find machine-id file (/mnt/etc/machine-id)" >&2 + exit 1 +fi + +MID=$(cat /mnt/etc/machine-id) +echo +echo "Found machine-id: $MID" +if [ ! -d /mnt/var/log/journal/$MID ]; then + echo "Cannot find journal log directory (/mnt/var/log/journal/)" >&2 + exit 1 +fi + +TIMEFRAME=24 +if [ -n "$1" ]; then + NEWTIMEFRAME=$(( 0 + $1 )) + if [ $NEWTIMEFRAME -gt 0 ]; then + TIMEFRAME=$NEWTIMEFRAME + fi +fi +SINCE="$(LC_ALL=c date --date=$TIMEFRAME' hours ago' +'%F %T')" +echo "Will collect logs from the last $TIMEFRAME hour(s)" +echo " NB give numeric argument to override capture period" + +TEMPFILE=$(mktemp /tmp/grabjournallogs.XXXXXX) +echo -n "Extracting logs... " +journalctl -D /mnt/var/log/journal/$MID --since "$SINCE" -o short >$TEMPFILE +echo "done" + +if [ $(cat $TEMPFILE | wc -l) -lt 2 ]; then + rm -f $TEMPFILE + echo >&2 + echo "Cannot find any logs. Consider increasing the capture period by passing a" >&2 + echo "numeric argument larger than $TIMEFRAME." >&2 + exit 1 +fi + +echo -n "Compressing logs... " +cat $TEMPFILE | xz >/journallogs.xz +rm -f $TEMPFILE +echo "done" + +echo +echo "Your logs have been extracted to the file 'journallogs.xz'" diff --git a/rescue/tree/usr/sbin/restore-image.sh b/rescue/tree/usr/sbin/restore-image.sh new file mode 100755 index 000000000..f4f904f3f --- /dev/null +++ b/rescue/tree/usr/sbin/restore-image.sh @@ -0,0 +1,412 @@ +#!/bin/bash + +setterm -powersave off +setterm -blank 0 + +if [ -r ./restore-image-lib.sh ]; then + . ./restore-image-lib.sh +elif [ -r /usr/lib/restore-image-lib.sh ]; then + . /usr/lib/restore-image-lib.sh +fi + +export PATH="/sbin:/bin:/usr/sbin:/usr/bin" + +mnt_dir="/tmp/mnt" +restore_media="/tmp/media" +images_dir="$restore_media/images" +images="$images_dir/list" +images_config="$images_dir/config" +image="" +win32_part_dev= +win32_part_type= +win32_part_new_size= + +function read_config() +{ + if [ -r "$images_config" ]; then + . $images_config + fi +} + +function image_list() +{ + list=$(cat $images | awk -F',' \ + '{ print $1 " " $2 " " $4 }') + + echo $list +} + +function image_file() +{ + country="$1" + + file=$(grep ^$country $images | awk -F',' '{ print $3 }') + + echo $file +} + +function welcome() +{ + while true; do + clear + msg="\n Welcome to $TITLE\n\ +\nThe following images were found, select one:\n " + opcao=$(dialog --backtitle "$BACKTITLE" --title "$TITLE" \ + --stdout --radiolist "$msg" 0 0 0 \ + $(image_list)) + + if [ "$?" != "0" ]; then + _yesno "\nInterrupt installation?\n " + if [ "$?" = "0" ]; then + _shutdown + fi + else + if [ -z "$opcao" ]; then + continue + else + image=$(image_file $opcao) + break + fi + fi + done + + # disable kernel messages in the console + echo "1 4 1 7" > /proc/sys/kernel/printk +} + +function install_warning() +{ + if [ -n "${win32_part_dev}" ]; then + warn_msg="Windows installation detected.\nWe will set it up as dual boot. \ +You may lose some data.\nPlease backup before proceeding." + else + warn_msg="WARNING: This process will erase all data in this machine, \ +do you want to continue?" + fi + + clear + _yesno "\n$warn_msg\n" + if [ "$?" != "0" ]; then + _shutdown + fi +} + +function detect_root() +{ + inst_source_dev=$(awk "\$2 == \"$restore_media\" { print \$1 }" /proc/mounts | sed -e 's/[0-9]$//') + inst_source_dev=${inst_source_dev#/dev/} + devices=$(grep "^ .*[^0-9]$" < /proc/partitions | grep -v ${inst_source_dev} | awk '$3 > '$MIN_DISKSIZE' { print $4,$3 }') + + if [ -z "${devices}" ]; then + exit 1 + fi + + devs_found=$(($(echo $devices | wc -w)/2)) + + root_data=$(detect_win32 ${inst_source_dev}) + + if [ -z "${root_data}" ]; then + if [ "$devs_found" -gt "1" ]; then + if [ -n "${inst_source_dev}" ]; then + opcao=$(dialog --backtitle "$BACKTITLE" --title "$TITLE" --stdout --menu 'Choose one of the detected devices to restore to (check the blocks size column first):' 8 50 0 $devices ) + if [ "$?" != "0" ]; then + _yesno "\nInterrupt installation?\n " + if [ "$?" = "0" ]; then + _shutdown + fi + else + root_data=${opcao} + fi + fi + else + root_data=$(echo ${devices} | cut -d ' ' -f 1) + fi + fi + + echo ${root_data} +} + +function detect_win32() +{ + # from detect_root() + skip_dev=${1} + + # win32 detection won't handle complex layouts + if [ $(fdisk -l | grep "^/dev/" | grep -v ${skip_dev} | wc -l) -gt 1 ]; then + exit + fi + + # get the last created windows partition information + set -f + device=$(fdisk -l | grep "^/dev/" | grep -v ${skip_dev} | grep -e "FAT\|NTFS\|HPFS" | tail -1 | sed 's/ .*$//') + set +f + + if [ -z "${device}" ]; then + exit + fi + + # it might be needed, for safety + device_type=$(blkid -o value -s TYPE ${device}) + modprobe ${device_type} + + # df for that partition + mount ${device} /mnt + size=$(df ${device} | tail -1) + umount /mnt + + # its diskspace + used=$(echo ${size} | awk '{ print $3 }') + left=$(echo ${size} | awk '{ print $4 }') + avail=$((${left}/2)) + + if [ ! ${avail} -lt ${MIN_DISKSIZE} ]; then + win32_part_dev=${device} + win32_part_type=${device_type} + # our install takes half of 'left' + win32_part_new_size=$((${used}+${avail})) + + dev=${win32_part_dev#/dev/} + disk=${dev%[0-9]} + number=${dev#[a-w][a-w][a-w]} + let number++ + echo ${disk}${number} ${win32_part_dev} ${win32_part_type} ${win32_part_new_size} + fi +} + +function resize_win32() +{ + device=${1} + device_type=${2} + new_win32_size=${3} + + dialog --backtitle "$BACKTITLE" --title "$TITLE" --infobox "\nResizing Windows partition...\n" 4 55 + + dev=${device#/dev/} + disk=${dev%[0-9]} + win32_number=${dev#[a-w][a-w][a-w]} + + case ${device_type} in + vfat) device_id=b ;; + ntfs) device_id=7 ;; + hpfs) device_id=87 ;; + esac + + # wrapper around libdrakx by blino + diskdrake-resize ${device} ${device_type} $((${new_win32_size}*2)) &>/dev/null + + # we need some free sector here, rebuilding layout + fdisk /dev/${disk} &>/dev/null </dev/null </dev/null; dd bs=4M of=/dev/${root} >/tmp/backup.out 2>&1>>/tmp/log) & + + sleep 3 + pid=$(ps ax | grep 'dd bs=4M of' | grep -v grep | awk '{ print $1 }') + + while [ true ]; do + ps | grep -q $pid + if [ $? -eq 0 ]; then + /bin/kill -SIGUSR1 $pid + complete=$(tail -n 1 /tmp/backup.out | awk '{ print $1 }') + echo $((complete*100/total)) + sleep 1 + else + break + fi + done | dialog --backtitle "$BACKTITLE" --title "$TITLE" --gauge "\nWriting image..." 8 45 + + in=$(tail -n 3 /tmp/backup.out | grep 'in$' | cut -d' ' -f1) + out=$(tail -n 3 /tmp/backup.out | grep 'out$' | cut -d' ' -f1) + + if [ x"$in" != x"$out" ]; then + _msgbox "\nError writing image!\n" + sleep 24h + fi + + # Now re-read the partition table because 'dd' might have changed it + sfdisk -R /dev/${root} +} + +function grub_setup() +{ + root=${1} + grub_dir=${2} + + # install the bootloader + grub <> ${grub_dir}/menu.lst </dev/null| grep "Filesystem OS type" | awk '{ print $4 }') + if [ "${filesystem_type}" = "Linux" ]; then + dialog --backtitle "$BACKTITLE" --title "$TITLE" --infobox "Finishing Install... Expanding ${root}" 3 40 + disk=/dev/${root%[0-9]} + main_part=/dev/${root} + + # FIXME: absurdly dirty hack + main_part_num=${root:3} + swap_part_num=$((main_part_num+1)) + swap_part=${disk}${swap_part_num} + + main_part_sectors= + if [ -n "$SWAP_BLOCKS" ]; then + if [ -n "$EXPAND_FS" ]; then + total_blocks=$(sfdisk -s $disk) + main_part_blocks=$((total_blocks-SWAP_BLOCKS)) + main_part_sectors=$((main_part_blocks*2)) + else + main_part_sectors=$(sfdisk -d $disk | perl -lne 'm|^'$main_part'\b.*,\s*size\s*=\s*(\d+)\b| and print($1), exit') + fi + fi + if [ -n "$SWAP_BLOCKS" ]; then + parted $disk -- mkpartfs primary linux-swap ${main_part_sectors}s -1s yes + mkswap -L swap $swap_part + fi + if [ -n "$EXPAND_FS" ]; then + e2fsck -fy $main_part + fdisk $disk << EOF +d +$main_part_num +n +p +$main_part_num + + +a +$main_part_num +w +EOF + sfdisk -R $disk + e2fsck -fy $main_part + resize2fs $main_part + fi + mkdir -p $mnt_dir + mount $main_part $mnt_dir + grub_dir="$mnt_dir/boot/grub" + if [ -d "$grub_dir" ]; then + echo "(hd0) $disk" > "$grub_dir/device.map" + if [ -n "$win32_part_dev" ]; then + grub_setup ${root} ${grub_dir} + fi + fi + if [ -n "$MKINITRD" ]; then + mount -t sysfs none "$mnt_dir/sys" + mount -t proc none "$mnt_dir/proc" + chroot $mnt_dir bootloader-config --action rebuild-initrds + umount "$mnt_dir/sys" + umount "$mnt_dir/proc" + fi + umount $mnt_dir + fi +} + +# installation steps +welcome +read_config +detect_device +install_warning +write_image +expand_fs + +# all done! +_msgbox "\nInstallation process finished.\nPress ENTER to shutdown.\n " + +_shutdown + diff --git a/rescue/tree/usr/sbin/startssh b/rescue/tree/usr/sbin/startssh new file mode 100755 index 000000000..e14bb10e8 --- /dev/null +++ b/rescue/tree/usr/sbin/startssh @@ -0,0 +1,27 @@ +#!/bin/bash + +# test for an up interface != lo +if test "x"`ifconfig | cut -d ' ' -f 1 | grep -v '^$' | grep -v lo` = "x"; then + echo "There is no up interface, you can try to execute 'drvinst' to find drivers and 'dhcp-client' to configure your interface for DHCP." >&2 + exit 5 +fi + +# generate host keys +mkdir -p /etc/dropbear +[[ -f /etc/dropbear/dropbear_dss_host_key ]] || dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key >/dev/null || { echo "Can't generate dsa host key" >&2 ; exit 4; } +[[ -f /etc/dropbear/dropbear_rsa_host_key ]] || dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key >/dev/null || { echo "Can't generate rsa host key" >&2 ; exit 3; } + +# set a password +passwd=`genpasswd` +if (( $? != 0 )); then + reset + exit $? +fi +sed -E -i -e 's/^root:[^:]*:/root:'"${passwd//\//\\/}"':/' /etc/passwd || { echo "Can't set password" >&2 ; exit 2; } + +# test for /dev/pts +grep '^devpts /dev/pts devpts ' /proc/mounts >/dev/null 2>/dev/null || mount -t devpts devpts /dev/pts + +echo "" +echo -n "Starting ssh daemon... " +dropbear -E 2>/var/log/dropbear.log && echo "OK" || { echo "Failed" ; exit 1; } -- cgit v1.2.1 From 2137cf19edadc5e039ab9af523b1d5bc6e4ee136 Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Tue, 3 Dec 2013 00:01:09 +0000 Subject: rescue: Tidy up dirs and aliases Technically, because we don't actually switchroot into this filesystem we don't need some of the directories and symlinks (as they are already present in the initrd). But with a long term view to making this a "real" filesystem that we DO switchroot into, it makes sense to try and keep things vaguely valid. --- rescue/aliases | 9 ++++++--- rescue/dirs | 4 ++-- rescue/make_rescue_img | 20 +++++++------------- 3 files changed, 15 insertions(+), 18 deletions(-) (limited to 'rescue') diff --git a/rescue/aliases b/rescue/aliases index d92ea8ccf..ae924a86e 100644 --- a/rescue/aliases +++ b/rescue/aliases @@ -1,6 +1,9 @@ -/bin/vi vim-minimal -/lib/modules /modules -/usr/sbin/init /usr/lib/systemd/systemd +/bin usr/bin +/sbin usr/sbin +/lib usr/lib +/usr/bin/vi vim-minimal +/usr/sbin/init ../lib/systemd/systemd +/usr/lib/modules ../../modules /usr/lib/systemd/system/default.target rescue.target /usr/lib/systemd/system/rescue.target.wants/sockets.target ../sockets.target /usr/lib/systemd/system/dbus-org.freedesktop.machine1.service systemd-machined.service diff --git a/rescue/dirs b/rescue/dirs index 256a7f0f7..1b1153926 100644 --- a/rescue/dirs +++ b/rescue/dirs @@ -2,8 +2,8 @@ /proc /run /sys +/tmp /usr/bin /usr/sbin -/usr/lib -/tmp +/usr/lib/systemd/system/rescue.target.wants /modules diff --git a/rescue/make_rescue_img b/rescue/make_rescue_img index 4b4301c55..49dc1a8d1 100755 --- a/rescue/make_rescue_img +++ b/rescue/make_rescue_img @@ -18,23 +18,23 @@ sub _ { __ @_; $? and die } my $arch = arch() =~ /i.86/ ? $MDK::Common::System::compat_arch{arch()} : arch(); _ "rm -rf $tmp" if -e $tmp; _ "mkdir -p $tmp"; -_ "ln -s usr/bin $tmp/bin"; -_ "ln -s usr/sbin $tmp/sbin"; -_ "ln -s usr/lib $tmp/lib"; +_ "cp -a tree/* $tmp"; +_ "find $tmp -name '*~' -delete"; +mkdir_p($tmp . chomp_($_)) foreach cat_("dirs"); +foreach (cat_("aliases")) { + chomp; my ($f, $dest) = split; + symlink $dest, "$tmp$f"; +} if ($arch eq "x86_64") { _ "mkdir $tmp/usr/lib64"; _ "ln -s usr/lib64 $tmp/lib64"; } -_ "cp -a tree/* $tmp"; -_ "find $tmp -name '*~' -delete"; -mkdir_p($tmp . chomp_($_)) foreach cat_("dirs"); substInFile { s/DISTRIB_DESCR/$ENV{DISTRIB_DESCR}/ } "$tmp/etc/issue"; _ "../tools/install-xml-file-list list.xml $tmp"; _ "sed 's/Mageia \\([0-9]*\\)/Mageia Rescue \\1/' /etc/os-release >$tmp/etc/os-release"; _ "ls -1 $tmp/etc | sed 's,\\(.*\\),/etc/\\1,' >>$tmp/usr/share/symlinks"; -_ "mkdir -p $tmp/usr/lib/systemd/system/rescue.target.wants"; my %keytable_conflicts; my @less_important_keytables = qw(am_old am_phonetic no-dvorak de-latin1); @@ -51,12 +51,6 @@ foreach (keyboard::loadkeys_files(sub { warn @_ })) { } } -foreach (cat_("aliases")) { - chomp; my ($f, $dest) = split; - symlink $dest, "$tmp$f"; -} - - if (my ($LANGUAGE) = map { if_(/LANGUAGE_(.*)/, $1) } keys %ENV) { substInFile { $_ = "export LANGUAGE=$LANGUAGE\n" . "export LC_ALL=$LANGUAGE\n" if /^#LANGUAGE/; -- cgit v1.2.1 From cad4721a454d9fcda1a505fdd9825113ac034893 Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Sat, 7 Dec 2013 17:56:33 +0000 Subject: rescue: Mask an unimportant error when loading kernel modules. Particularly the floppy module fails quite regularly. That said, do we even need floppy support these days? --- rescue/make_rescue_img | 3 +++ 1 file changed, 3 insertions(+) (limited to 'rescue') diff --git a/rescue/make_rescue_img b/rescue/make_rescue_img index 49dc1a8d1..8e3f64334 100755 --- a/rescue/make_rescue_img +++ b/rescue/make_rescue_img @@ -35,6 +35,9 @@ _ "../tools/install-xml-file-list list.xml $tmp"; _ "sed 's/Mageia \\([0-9]*\\)/Mageia Rescue \\1/' /etc/os-release >$tmp/etc/os-release"; _ "ls -1 $tmp/etc | sed 's,\\(.*\\),/etc/\\1,' >>$tmp/usr/share/symlinks"; +# Loading the floppy module causes this service to fail so lets mask this to +# prevent a red "FAILED" briefly showing on the screen +_ "sed -i s/ExecStart=/ExecStart=-/ $tmp/usr/lib/systemd/system/systemd-modules-load.service"; my %keytable_conflicts; my @less_important_keytables = qw(am_old am_phonetic no-dvorak de-latin1); -- cgit v1.2.1 From 218b7daece5df6dd17c3edef963132507eb9c819 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Sun, 8 Dec 2013 22:31:39 +0100 Subject: fix spacing --- rescue/NEWS | 1 + 1 file changed, 1 insertion(+) (limited to 'rescue') diff --git a/rescue/NEWS b/rescue/NEWS index cf8d6e3cf..80a09a316 100644 --- a/rescue/NEWS +++ b/rescue/NEWS @@ -2,6 +2,7 @@ - allowing systemd-nspawn "booting" of a mounted /mnt (after umount /mnt/proc) Version 1.46 - 20 October 2013 by Colin Guthrie + - adapt to a dracut based stage1 Version 1.45.1 - 14 October 2013 by Colin Guthrie -- cgit v1.2.1 From 034d58457f287d312a06b10a3496a25befbf15d5 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Sun, 8 Dec 2013 22:32:21 +0100 Subject: 1.47 --- rescue/Makefile | 2 +- rescue/NEWS | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'rescue') diff --git a/rescue/Makefile b/rescue/Makefile index 64e9119e3..a53703d0f 100644 --- a/rescue/Makefile +++ b/rescue/Makefile @@ -1,6 +1,6 @@ include ../Makefile.config -VERSION=1.46 +VERSION=1.47 PRODUCT=drakx-installer-rescue RESCUE = rescue.sqfs diff --git a/rescue/NEWS b/rescue/NEWS index 80a09a316..c2a820493 100644 --- a/rescue/NEWS +++ b/rescue/NEWS @@ -1,3 +1,5 @@ +Version 1.47 - 8 December 2013 by Colin Guthrie + - use systemd as init in the rescue system - allowing systemd-nspawn "booting" of a mounted /mnt (after umount /mnt/proc) -- cgit v1.2.1