Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[solved] mounting usb sticks after restoring from stage4
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
Elleni
l33t
l33t


Joined: 23 May 2006
Posts: 858

PostPosted: Sat Feb 04, 2017 3:14 pm    Post subject: [solved] mounting usb sticks after restoring from stage4 Reply with quote

As my college has a quite similar box, I thought, I could backup my box with stage4.sh and restore it on his machine. The client boots and works only it does not mount usb sticks. I run kde plasma on it with sddm as login manager.

I imagine, when doing a full emerge -e world it would mount usb disks, but is there an other possible reason, and a smarter aproach ?

Code:
emerge --info
Portage 2.3.3 (python 2.7.12-final-0, default/linux/amd64/13.0/desktop/plasma, gcc-4.9.4, glibc-2.23-r3, 4.9.6-gentoo-r1 x86_64)
=================================================================
System uname: Linux-4.9.6-gentoo-r1-x86_64-Intel-R-_Core-TM-2_Duo_CPU_E8500_@_3.16GHz-with-gentoo-2.3
KiB Swap:    9767516 total,   9767516 free
Timestamp of repository gentoo: Sat, 04 Feb 2017 11:00:01 +0000
sh bash 4.3_p48-r1
ld GNU ld (Gentoo 2.25.1 p1.1) 2.25.1
app-shells/bash:          4.3_p48-r1::gentoo
dev-lang/perl:            5.22.3_rc4::gentoo
dev-lang/python:          2.7.12::gentoo, 3.4.5::gentoo
dev-util/cmake:           3.7.2::gentoo
dev-util/pkgconfig:       0.28-r2::gentoo
sys-apps/baselayout:      2.3::gentoo
sys-apps/openrc:          0.22.4::gentoo
sys-apps/sandbox:         2.10-r1::gentoo
sys-devel/autoconf:       2.13::gentoo, 2.69::gentoo
sys-devel/automake:       1.11.6-r1::gentoo, 1.12.6::gentoo, 1.14.1::gentoo, 1.15::gentoo
sys-devel/binutils:       2.25.1-r1::gentoo
sys-devel/gcc:            4.9.4::gentoo
sys-devel/gcc-config:     1.7.3::gentoo
sys-devel/libtool:        2.4.6-r2::gentoo
sys-devel/make:           4.2.1::gentoo
sys-kernel/linux-headers: 4.4::gentoo (virtual/os-headers)
sys-libs/glibc:           2.23-r3::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000

x-portage
    location: /usr/local/portage
    masters: gentoo
    priority: 0

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"                                                                                                   
CBUILD="x86_64-pc-linux-gnu"                                                                                                 
CFLAGS="-march=native -O2 -pipe"                                                                                             
CHOST="x86_64-pc-linux-gnu"                                                                                                 
CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc /usr/share/config /usr/share/gnupg/qualified.txt"             
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"                                                                               
CXXFLAGS="-march=native -O2 -pipe"                                                                                           
DISTDIR="/usr/portage/distfiles"                                                                                             
EMERGE_DEFAULT_OPTS="--with-bdeps=y --jobs=3 --load-average=2"                                                               
FCFLAGS="-O2 -pipe"                                                                                                         
FEATURES="assume-digests binpkg-logs candy clean-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="de_CH.UTF-8"
LC_ALL="de_CH.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j5"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/tmp"
USE="X a52 aac acl acpi alsa amd64 berkdb bluetooth branding bzip2 cairo cdda cdr cli consolekit cracklib crypt cups cxx d3d9 dbus declarative dri dri3 dts dvd dvdr emboss encode exif fam ffmpeg firefox flac fortran frei0r gdbm gif glamor gnutls gpm gtk hpcups iconv icu ipv6 jpeg kde kipi lcms ldap libnotify llvm lm_sensors mad mmx mmxext mng modules mp3 mp4 mpeg multilib ncurses nls nptl ocr ogg openal opencl opengl openmax openmp osmesa pam pango pcre pdf phonon plasma png policykit ppds pulseaudio qml qt3support qt4 qt5 readline realtime s3tc scanner sdl seccomp semantic-desktop session spell spice sse sse2 sse3 ssh ssl ssse3 staging startup-notification svg tcpd theora tiff truetype udev udisks unicode upower usb uxa vaapi vdpau vhost-net vorbis vpx webrtc-aec widgets wxwidgets x264 xattr xcb xcomposite xinerama xml xscreensaver xv xvid zlib" ABI_X86="64 32" ALSA_CARDS="hda-intel" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext smp sse sse2 sse3 sse4_1 ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="evdev" KERNEL="linux" L10N="de el en fr it tr" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="de de_DE el en fr fr_FR it tr" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_4" RUBY_TARGETS="ruby21" SANE_BACKENDS="pixma" USERLAND="GNU" VIDEO_CARDS="amdgpu radeon radeonsi intel i965" XFCE_PLUGINS="clock power multiload-nandhp trash" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, INSTALL_MASK, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON


Last edited by Elleni on Sun Feb 05, 2017 1:21 pm; edited 3 times in total
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7071

PostPosted: Sat Feb 04, 2017 4:56 pm    Post subject: Reply with quote

his user is in the right group?
i'm not sure if he should be plugdev or usb, or both.
Back to top
View user's profile Send private message
Elleni
l33t
l33t


Joined: 23 May 2006
Posts: 858

PostPosted: Sat Feb 04, 2017 5:29 pm    Post subject: Reply with quote

Yes, its in both
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6228
Location: Room 101

PostPosted: Sat Feb 04, 2017 6:22 pm    Post subject: Reply with quote

Elleni ...

you say a 'stage4.sh' was used, I'm not sure what this is, but when using tar you should use '--xattrs' (when compressing/decompressing) to 'enable extended attributes support', and you should also be using '-p, --preserve-permissions'. The symptom suggests its caused by some permission, ownership, or attribute, having changed.

best ... khay
Back to top
View user's profile Send private message
Elleni
l33t
l33t


Joined: 23 May 2006
Posts: 858

PostPosted: Sun Feb 05, 2017 12:23 am    Post subject: Reply with quote

Hello krinn and khayyam, and thank you for taking care of my problem! :)

Well it is a script, that I found for making a full system backup of a gentoo box. and restored it with tar xvjpf archive.bz2 after chrooting from a livecd and creating partitions. Then a emerge sync followed by an grub install, user creation and the system booted fine. Hm, and if it indeed is a permission problem? Which would be the packages to re-emerge in order to get permissions right for beeing able to mount usb drives? Or is it bether to do an emerge -e system or even an emerge -e world anyways?

The used script is:

Code:
#!/bin/bash
 
# Backup script for Gentoo Linux
#
# mkstage4.sh is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# mkstage4.sh is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# Copyright: Reto Glauser aka blinkeye
# Mailto: stage4 at blinkeye dot ch
# Homepage: http://blinkeye.ch
# Forum post: http://forums.gentoo.org/viewtopic-t-312817.html
# Date: 2009-04-02
 
version=v3.7
basename=`basename $0`
 
find=/usr/bin/find
tar=/bin/tar
 
# these are the commands we actually need for the backup
command_list=(cut date echo $find grep hostname mount sh split $tar umount uname which)
 
# verify that each command we use exists. if one can't be found use $PATH and make a suggestion if possible.
for command in ${command_list[@]}; do
        if [ ! -x "`which $command 2>&1`" ]; then
                echo -e "\nERROR: $command not found! "
                base=`basename $command`
                if [ "`which $base 2>&1 | grep "no \`basename $command\` in"`" != "" ]; then
                        echo -e "ERROR: $base is not in your \$PATH."
                fi
                exit -1
        fi
done
 
help="\nUsage:\n\nsh `basename $0` [[-v]|[--verbose]] [[-s]|[--split]] \n\nTo run the script NOT in verbose mode comes in handy if you want to see only the errors that occur during the backup.\n"
 
# Defaults to creating one tarball
tar_output="--file"
 
# split command
split_options="--suffix-length=1 --bytes=685m"
 
# options for the tar command
tarOptions=" --preserve-permissions --create --absolute-names --totals --ignore-failed-read"
 
# where to put the stage4
stage4Location=/mnt/backups/stage4
 
# name prefix
stage4prefix=`hostname`-stage4-`date +\%Y.\%m.\%d`
 
# patterns which should not be backed up (like iso files).
# example: default_exclude_pattern="*.iso *.divx"
# These pattern count only for files NOT listed in the $custom_include_list.
default_exclude_pattern=""
 
# these files/directories are always excluded. don't add trailing slashes.
# don't touch it unless you know what you are doing!
# /var/db and /var/cache/edb are intentionally added here. they are listed
# in $default_include_folders
default_exclude_list="
/dev
/lost+found
/mnt
/proc
/sys
/tmp
/usr/portage
/usr/src
/var/log
/var/tmp
/var/db
/var/cache/edb
$stage4Location
`echo $CCACHE_DIR`"
 
# files/devices/folders, which need to be backed up (preserve folder structure).
# don't touch it unless you know what you are doing! no recursive backup of folders.
# use $default_include_folders instead.
default_include_files="
/dev/null
/dev/console
/home
/mnt
`find /mnt -name .keep`
/proc
/sys
/tmp
/usr/portage
/usr/src
/var/log/emerge.log
/usr/src/linux-`uname -r`/.config"
 
# folders, which need to be backed up recursively on every backup.
# don't touch it unless you know what you are doing! the reason for this
# variable is that some users add /var to the $default_exclude_list. here
# we ensure that portage's memory is backed up in any case.
default_include_folders="
/var/db"
 
# IMPORTANT: A minimal backup will EXCLUDE files/folders listed here. A custom backup will
# include/exclude these files/folders depening on your answer.
custom_include_list="
/home/*
/usr/src/linux-`uname -r`"
 
# add files/folders here which are subfolders of a folder listed in $custom_include_list which should NOT
# be backed up. eg.
#custom_exclude_list="/home/foo/mp3 /home/foo/downloads /home/foo/.*"
custom_exclude_list=""
 
# Only files/folders within the $custom_include_list are checked against these patterns
# custom_exclude_pattern="*.mp3 *.iso"
custom_exclude_pattern=""
 
# the find_command
find_command="$find /*"
 
# don't backup anything which matches pattern listed in $default_exclude_pattern
for pattern in $default_exclude_pattern; do
        find_command="$find_command -not -name $pattern"
done
 
# assemble the find_command
function find_files()
{
        for folder in $default_exclude_list; do
                find_command="$find_command -path $folder -prune -o"
        done
 
        find_command="$find_command -print"
 
        for i in $default_include_files; do
                find_command="echo $i; $find_command"
        done
 
        for i in $default_include_folders; do
                if [ -d $i ]; then
                        find_command="$find $i; $find_command"
                else
                        find_command="echo $i; $find_command"
                fi
        done
}
 
# check the exclude/include variables for non-existing entries
function verify()
{
        for i in $1; do
                if [ ! -e "`echo "$i" | cut -d'=' -f2 | cut -d'*' -f1`" -a "$i" != "/lost+found" -a "$i" != "$stage4Location" ]; then
                        echo "ERROR: `echo "$i" | cut -d'=' -f2` not found! Check your "$2
                        exit 0
                fi
        done
}
 
# check input parameters
while [ $1 ]; do
        case  $1 in
        "-h" | "--help")
                echo -e $help
                exit 0;;
        "-v" | "--verbose")
                verbose=$1;;
        "-s" | "--split")
                tar_output="--split";;
        "");;
        *)
                echo -e $help
                exit 0;;
        esac
        shift
done
 
echo ""
 
# check folder/files listed in $default_exclude_list exist
verify "$default_exclude_list" "\$default_exclude_list"
 
# check files listed in $default_include_files exist
verify "$default_include_files" "\$default_include_files"
 
# check folder listed in $default_include_folders exist
verify "$default_include_folders" "\$default_include_folders"
 
#check folder listed in $custom_include_list exist
verify "$custom_include_list" "\$custom_include_list"
 
#check folder listed in $custom_exclude_list exist
verify "$custom_exclude_list" "\$custom_exclude_list"
 
# print out the version
 echo -e "\nBackup script $version"
 echo -e "=================="
 
# how do you want to backup?
echo -e "\nWhat do you want to do? (Use CONTROL-C to abort)\n
Fast (tar.gz):
 (1) Minimal backup
 (2) Interactive backup
 
 
Best (tar.bz2):
 (3) Minimal backup
 (4) Interactive backup\n"
 
while [ "$option" != '1' -a "$option" != '2' -a "$option" != '3' -a "$option" != '4' ]; do
        echo -en "Please enter your option: "
        read option
done
 
case $option in
[1,3])
        stage4Name=$stage4Location/$stage4prefix-minimal.tar;;
 
[2,4])
        stage4Name=$stage4Location/$stage4prefix-custom.tar
 
        for folder in $custom_include_list; do
                echo -en "\nDo you want to backup" `echo "$folder" | cut -d'=' -f2`"? (y/n) "
                read answer
                while [ "$answer" != 'y' -a "$answer" != 'n' ]; do
                        echo -en "Do you want to backup" `echo "$folder" | cut -d'=' -f2`"? (y/n) "
                        read answer
                done
                if [ "$answer" == 'n' ]; then
                        find_command="$find_command -path $folder -prune -o"
                else
                        custom_find="$find $folder"
                        for i in $custom_exclude_pattern; do
                                custom_find="$custom_find -name $i -o"
                        done
                        for i in $custom_exclude_list; do
                                custom_find="$custom_find -path $i -prune -o"
                        done
                        find_command="$custom_find -print; $find_command"
                fi
        done ;;
esac
 
# add $custom_include_list to the $default_exclude_list as we assembled
# $custom_find with $custom_include_list already.
default_exclude_list="$default_exclude_list $custom_include_list"
 
case $option in
[1,2])
        stage4postfix="gz"
        zip="--gzip";;
 
[3,4])
        stage4postfix="bz2"
        zip="--bzip2";;
esac
 
# mount boot
echo -e "\n* mounting boot"
mount /boot >/dev/null 2>&1
 
# find the files/folder to backup
find_files
find_command="($find_command)"
 
# create the final command
if [ "$tar_output" == "--file" ]; then
        tar_command="$find_command | $tar $zip $tarOptions $verbose --file $stage4Name.$stage4postfix --no-recursion -T -"
else
        tar_command="$find_command | $tar $zip $tarOptions $verbose --no-recursion -T - | split $split_options - "$stage4Name.$stage4postfix"_"
fi
 
if [ "$verbose" ]; then
        echo -e "\n* creating the stage4 in $stage4Location with the following command:\n\n"$tar_command
fi
 
# everything is set, are you sure to continue?
echo -ne "\nDo you want to continue? (y/n) "
read answer
while [ "$answer" != 'y' ] && [ "$answer" != 'n' ]; do
        echo -ne "Do you want to continue? (y/n) "
        read answer
done
 
if [ "$answer" == 'y' ]; then
        # check whether the file already exists.
        if [ "$tar_output" == "--split" ]; then
                overwrite="`ls "$stage4Name.$stage4postfix"_* 2>&1 | grep -v 'No such file'`"
        else
                overwrite="$stage4Name.$stage4postfix"
        fi
 
        if [ -a "`echo "$overwrite" | grep "$overwrite" -m1`" ]; then
                echo -en "\nDo you want to overwrite $overwrite? (y/n) "
                read answer
                while [ "$answer" != 'y' ] && [ "$answer" != 'n' ]; do
                        echo -en "Do you want to overwrite $overwrite? (y/n) "
                        read answer
                done
                if [ "$answer" == 'n' ]; then
                        echo -e "\n* There's nothing to do ... Exiting"
                        exit 0;
                fi
        fi
 
        # if necessary, create the stage4Location
        if [ ! -d "$stage4Location" ] ; then
                echo "* creating directory $stage4Location"
                mkdir -p $stage4Location
        fi
 
        echo -e "\n* Please wait while the stage4 is being created.\n"
 
        # do the backup.
        sh -c "$tar_command"
 
        # finished, clean up
        echo -e "\n* stage4 is done"
        echo "* umounting boot"
        umount /boot >/dev/null 2>&1
 
        # Integrity check
        echo -e "* Checking integrity"
        if [ "$zip" == "--gzip" ]; then
                zip="gzip"
        else
                zip="bzip2"
        fi
 
        if [ "$tar_output" == "--split" ]; then
                if [ "`cat "$stage4Name.$stage4postfix"_*"" | $zip --test 2>&1`" != "" ]; then
                        echo -e "* Integrity check failed. Re-run the script and check your hardware."
                        exit -1
                fi
        else
                if [ "`$zip --test  $stage4Name.$stage4postfix 2>&1`" != "" ]; then
                        echo -e "* Integrity check failed. Re-run the script and check your hardware."
                        exit -1
                fi
        fi
 
        # everything went smoothly
        echo -e "* Everything went smoothly. You successfully created a stage4."
 
else
        echo -e "\n* There's nothing to do ... Exiting"
fi


https://paste.pound-python.org/show/W0qyaxD7orjm049BLBRg/
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6228
Location: Room 101

PostPosted: Sun Feb 05, 2017 6:48 am    Post subject: Reply with quote

Elleni wrote:
Code:
# Date: 2009-04-02

Elleni ... that would pre-date the use of xattr, and while I don't know for sure if this is the cause, the --xattr switch should be used (as per the instructions in unpacking the stage tarball). So, those attributes are lost for the entire install.

Elleni wrote:
Hm, and if it indeed is a permission problem? Which would be the packages to re-emerge in order to get permissions right for beeing able to mount usb drives? Or is it bether to do an emerge -e system or even an emerge -e world anyways?

It's very difficult to say, '--empty-tree @world' should fix the attributes but there may be other issues caused by the script as things have changed since 2009 (/var/run becoming a symlink for instance). It might actually be easier to make your archive again (this time providing --xattr) or do something like tar over ssh (again, providing -p and --xattr) while both target and destination are booted from a USB/CD.

best ... khay
Back to top
View user's profile Send private message
Elleni
l33t
l33t


Joined: 23 May 2006
Posts: 858

PostPosted: Sun Feb 05, 2017 10:03 am    Post subject: Reply with quote

I understand. Unfortunatelly i dont know how to modify the script myself, so I will look for a newer one, and alternatively I will perform an emerge -e world to see if this fixes it. If anyone is able to modify Blinkeyes's script, I could do a new backup. I will also search for a newer scriptversion myself.

Thank you for your comments.

By the way, would it be a bether aproach to do a new minimal install and then make binary packages on the source system and install them on the box to be cloned? I will read and try to find out how to do that..
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6228
Location: Room 101

PostPosted: Sun Feb 05, 2017 12:43 pm    Post subject: Reply with quote

Elleni wrote:
I understand. Unfortunatelly i cannot modify the script myself, so I will look for a newer one, and alternatively I will perform an emerge -e world to see if this fixes it. If anyone is able to modify Blinkeyes's script, I could do a new backup. I will also search for a newer scriptversion myself.

Elleni ... this simplest way to achieve the desire outcome is to rsync one install to the other: boot both machines via a USB or CD, mount the filesystem(s) to /mnt/gentoo (and /mnt/gentoo/<filesystem> if you have separate filesystems, ie for /boot), start ssh on the target machine, and then do the following (from the machine with the install to be copied):

Code:
# rsync -av --xattrs -e ssh --progress --delete /mnt/gentoo/ root@192.168.x.x:/mnt/gentoo

I'm using --delete there with the assumption that this will correct xattrs, but to be safe you could mkfs.ext4 on the target machine so /mnt/gentoo is empty. You could also add --exclude 'home' so as not to copy user data.

Otherwise, you can build a 'stage4' without a script, all you need to is boot from a USB/CD and do the following:

Code:
# mount /dev/sda2 /mnt/gentoo
# mount /dev/sda1 /mnt/gentoo/boot
# mount /dev/sdb1 /mnt/my_external_usb_drive
# tar -jcvfp --xattrs /mnt/my_external_usb_drive/stage4-$(hostname)-$(date +%F).tar.bz2 /mnt/gentoo/

and you could similarly --exclude="/home". Then on the target machine:

Code:
# mount /dev/sda2 /mnt/gentoo
# mount /dev/sda1 /mnt/gentoo/boot
# mount /dev/sdb1 /mnt/my_external_usb_drive
# tar -jxvfp --xattrs /mnt/my_external_usb_drive/stage4-hostname-2017-02-05.tar.bz2 -C /mnt/gentoo

One last example 'tar over ssh' (booted from a USB/CD):

Code:
# tar -jcvfp --xattrs - /mnt/gentoo/ | ssh root@192.168.x.x "cat > /path/to/disk/stage4-$(hostname)-$(date +%F).tar.bz2"

Elleni wrote:
By the way, would it be a bether aproach to do a new minimal install and then make binary packages on the source system and install them on the box to be cloned? I will read and try to find out how to do that..

You could do that, but it adds additional complexity, you might as well start a new install on the target.

best ... khay
Back to top
View user's profile Send private message
Elleni
l33t
l33t


Joined: 23 May 2006
Posts: 858

PostPosted: Sun Feb 05, 2017 1:21 pm    Post subject: Reply with quote

thank you very much, you gave me the instruments to do what I want. I have to see which version I will do. I'll mark thread as solved.
Back to top
View user's profile Send private message
Elleni
l33t
l33t


Joined: 23 May 2006
Posts: 858

PostPosted: Wed Feb 08, 2017 7:24 pm    Post subject: Reply with quote

Just for the record. I built binaries of my whole system -> 2.5 GB and a stage4 image created manually -> 3GB

I used as suggested the following commands, but I had to remove --xattrs as it threw an error telling me that this operation is not supported. and another error suggested that after the f option the filename has to be right after it.

Code:

tar --exclude=home/* --exclude=dev/* --exclude=proc/* --exclude=sys/* --exclude=mnt/* --exclude=tmp/* --exclude=var/tmp/* --exclude=var/lock/* --exclude=var/log/* --exclude=var/run/* --exclude=mnt/root/.bash_history  --exclude=usr/portage/* --exclude=var/lib/libvirt/* --exclude=lost+found -jcvpPf stage4-gentoo1-2017-02-08.tar.bz2 / 2> /tmp/backup_errors.log


I did this from within my linux box. The only errors I have got are:
Code:

tar: /run/user/1002/pulse/native: Socket ignoriert
tar: /run/user/1002/klauncherTJ3656.1.slave-socket: Socket ignoriert
tar: /run/user/1002/kdeinit5__0: Socket ignoriert
tar: /run/dhcpcd.unpriv.sock: Socket ignoriert
tar: /run/dhcpcd.sock: Socket ignoriert
tar: /run/cups/cups.sock: Socket ignoriert
tar: /run/syslog-ng.ctl: Socket ignoriert
tar: /run/dbus/system_bus_socket: Socket ignoriert
tar: /run/udev/control: Socket ignoriert


I hope, exclusions are ok, and there is not something I have missed. I also added the P option to make message disapear warning me that leading / has been removed.

So I am prepared, and looking forward to access the box with a livesystem (knoppix) remotely to try to extract this stage4 file and see, how it works.
Back to top
View user's profile Send private message
szatox
Veteran
Veteran


Joined: 27 Aug 2013
Posts: 1747

PostPosted: Wed Feb 08, 2017 10:32 pm    Post subject: Reply with quote

I think you could replace quite a few exclusions with this single parameter: --one-file-system.
If nothing else, it's gonna rid you of /dev, /proc/ /sys /mnt /media.
It's not uncommon to keep /home and /tmp separate as well, so they are others potentially left out by this. Perhaps /usr/portage too.
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6228
Location: Room 101

PostPosted: Thu Feb 09, 2017 4:06 pm    Post subject: Reply with quote

Elleni wrote:
I used as suggested the following commands, but I had to remove --xattrs as it threw an error telling me that this operation is not supported. and another error suggested that after the f option the filename has to be right after it.

Elleni ... do you have the USE="xattrs" set? ... and yes, my bad, 'f' does need to be prior to filename.

Elleni wrote:
I did this from within my linux box. The only errors I have got are:
Code:
tar: /run/user/1002/pulse/native: Socket ignoriert
tar: /run/user/1002/klauncherTJ3656.1.slave-socket: Socket ignoriert
tar: /run/user/1002/kdeinit5__0: Socket ignoriert
tar: /run/dhcpcd.unpriv.sock: Socket ignoriert
tar: /run/dhcpcd.sock: Socket ignoriert
tar: /run/cups/cups.sock: Socket ignoriert
tar: /run/syslog-ng.ctl: Socket ignoriert
tar: /run/dbus/system_bus_socket: Socket ignoriert
tar: /run/udev/control: Socket ignoriert

/run is tmpfs, and so that should also be excluded (that is why I prefer doing this sort of thing on a non-live system, everything you rsync, or tar, is as it should be).

Elleni wrote:
I also added the P option to make message disapear warning me that leading / has been removed.

That is why I provided the '-C /mnt/gentoo/' above, anyhow, the warning shouldn't matter.

best ... khay
Back to top
View user's profile Send private message
Elleni
l33t
l33t


Joined: 23 May 2006
Posts: 858

PostPosted: Thu Feb 09, 2017 8:29 pm    Post subject: Reply with quote

Thank you szatox for your tip, I will look at it :)

Khayyam, xattr is not set in make.conf explicitely but it is aparently part of the profile as it shows up in emerge --info. Thanks for your explanation on /run. So I will exclude it when restoring to the new box. And I will do the stage from a livemedium next time. If there are some more things to exclude when not beeing on a livemedium, I would apreciate a hint. :)

I will report back how it works with the cloned box when I am done.
Back to top
View user's profile Send private message
Elleni
l33t
l33t


Joined: 23 May 2006
Posts: 858

PostPosted: Sun Feb 12, 2017 5:50 pm    Post subject: Reply with quote

Just for the record. After having had troubles with my cloned box again - I had not included /usr/portage, and thus the profile was not symlinked in /etc/portage - I went back and did a new tarball - this time from a livecd and with no exlusions at all. This did the trick. After some adjustements like changing fstab and hostname, creating a user with the right groups and so on, system booted like a charm and the initial problem (not mounting usbsticks) was gone. Thanks again khayyam :)

Now I just have to figure out how I will confiure the two clients so that my collegues box gets binpkgs from my box via ssh. This wil probably not work anyway as both boxes get only an internal IP (192.168.x.y) from their internet providers, so I guess, I will have to copy the packages over manually with some sort of teamviewer access...
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6228
Location: Room 101

PostPosted: Sun Feb 12, 2017 7:38 pm    Post subject: Reply with quote

Elleni wrote:
Just for the record. After having had troubles with my cloned box again - I had not included /usr/portage, and thus the profile was not symlinked in /etc/portage - I went back and did a new tarball - this time from a livecd and with no exlusions at all. This did the trick. After some adjustements like changing fstab and hostname, creating a user with the right groups and so on, system booted like a charm and the initial problem (not mounting usbsticks) was gone. Thanks again khayyam :)

Elleni ... you're welcome.

Elleni wrote:
Now I just have to figure out how I will confiure the two clients so that my collegues box gets binpkgs from my box via ssh. This wil probably not work anyway as both boxes get only an internal IP (192.168.x.y) from their internet providers, so I guess, I will have to copy the packages over manually with some sort of teamviewer access...

You didn't say, but if they are on the same subnet you can sshfs mount ~portidr/packages to the same on your collegues machine and then use 'emerge --usepkgonly' (again, on the collegues machine). If they are not on the same subnet then you need to use sneeker net (ie, an external hardisk) and similarly '--bind' mount ~packages/.

best ... khay
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum