script de recuperaçao de partiçao

1. script de recuperaçao de partiçao

Wilson
wilcat

(usa Ubuntu)

Enviado em 06/06/2018 - 15:44h

Boa tarde, dou novo em programação linux, porem.conheço o sistema ha algum tempo, minha duvida e a seguinte: Tenho um hd com tres partições, duas ntfs e uma ext3, os arquivos de recuperação estão na ext3 e tem um script chamado autorun.sh, porem nao consigo fazer a recuperação porque nao acessa a partição. Alguns pode me dar uma mãozinha?


  


2. Re: script de recuperaçao de partiçao

Alberto Federman Neto.
albfneto

(usa openSUSE)

Enviado em 06/06/2018 - 17:12h

Primeira coisa que eu tentaria....

Usando um ambiente de live DVD ou live pendrive, vc acessa as partições, ou enxerga elas? no Gparted?

script autorun.sh, acho que é rodar e não para recuperar.

vc está querendo recuperar a suas partições ou quer fazer um script que recupere? Pq recuperar é com fsck para as Ext e com ntfsfix para as NTFS.
¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨
Albfneto,
Ribeirão Preto, S.P., Brasil.
Usuário Linux, Linux Counter: #479903.
Distros Favoritas: Sabayon, Gentoo, openSUSE, Mageia e OpenMandriva.


3. Re: script de recuperaçao de partiçao

Wilson
wilcat

(usa Ubuntu)

Enviado em 06/06/2018 - 18:18h

Vejo sim....so que o autorun da partição ext3 e pra recuperar a unidade ntfs....nao tenho muito.conhecimento de programação linux, por isso que gostaria de saber se tem como recuperar....o arquivo de recuperação e .gz e o partimage so le arquivos .img....nao sei o que faço ja tentei tudo....copiei ate os arquivos da ext3 e reformatei o hd criando as tres partições....mas nada....

eis o arquivo?

#!/bin/sh
#set -x

# Defaults if no configuration file
IMAGEDEV=/dev/sda
IMAGEPART=/dev/sda1
MNT_CDROM=/livemnt/boot
TEMP=/tmp/$$

# Shortcuts for console colors
ltred=$(echo -e '\e[01;31m') # light red
dkred=$(echo -e '\e[00;31m') # dark red
white=$(echo -e '\e[01;37m') # white
ltgry=$(echo -e '\e[00;37m') # gray

# Look for config file and process if present
CONFIG=$MNT_CDROM/NewTek/etc/tc.cfg
[ -r $CONFIG ] && . $CONFIG


##########################################
# Common logic and other handy functions #
##########################################

Abort () {
echo "Looks like you know what you're doing!"
echo "Goodbye..."
exit
}

trap "echo Try pressing reset or powering off" 2
trap "Abort" 15

Reimage () {
echo "Creating new restore image"
cd $MNT_CDROM
mount -o remount,rw $MNT_CDROM
$MNT_CDROM/NewTek/bin/tc.mkimage CreateHDD
err=$?
if [ "$err" -ne 0 ] ; then
while : ; do
echo "Imaging FAILED with error $err"
read JUNK
done
fi
mount -o remount,ro $MNT_CDROM
sync
cat <<-EOF
Imaging Finished!!!

It is now safe to power down.
EOF
}

NewTekCheck () {
if [ "$1" = NewTekAbort ] ; then Abort ; fi
if [ "$1" = NewTekReimage ] ; then Reimage ; fi
}

Fail () {
cat <<-EOF
${dkred}
!!!!!!!!!!!!!!!!!!!!
!!! - FAILED - !!!
!!!!!!!!!!!!!!!!!!!!
${ltgry}
EOF

while : ; do
echo "Power OFF or press RESET to continue... "
read JUNK
if [ "$JUNK" = NewTekAbort ] ; then Abort ; fi
done
}

Finished () {
cat <<-EOF
${white}
!!!!!!!!!!!!!!!!!!!!
!!! - FINISHED - !!!
!!!!!!!!!!!!!!!!!!!!
${ltgry}
EOF

while : ; do
echo "Power OFF or press RESET to continue... "
read JUNK
NewTekCheck "$JUNK"
done
}

UserYes () {
while : ; do

echo -n "${1}Enter Yes to continue, power off to abort : "

read JUNK
NewTekCheck "$JUNK"
if [ "$JUNK" = Yes ] ; then break ; fi
done
}

UserYesNo () {
while : ; do

echo -n "${1}Enter Yes to continue, No to cancel : "

read JUNK
NewTekCheck "$JUNK"
if [ "$JUNK" = Yes ] ; then
return 0
elif [ "$JUNK" = No -o "$JUNK" = no ] ; then
return 1
fi
done
}

# Identify System Partition
GetSysPart () {
# System drive should be where we mounted SystemRescueCD
sed -n "\:$MNT_CDROM:{s/ .*$//;s:/dev/::;p}" /proc/mounts
}

# Identify System Drive
GetSysDev () {
# System drive should be where we mounted SystemRescueCD
sed -n "\:$MNT_CDROM:{s/[0-9]* .*$//;s:/dev/::;p}" /proc/mounts
}

# Detect disks
# $1 = Source device (optional, not added to results)
DetectDisks () {
local DEVFILE DEV FIRST=Y
for DEVFILE in /sys/bus/scsi/devices/[0-9]*/block/* ; do
DEV="$(basename $DEVFILE)"
if [ "$DEV" != "$1" ] ; then
case "$DEV" in
# Only use disk drives, not CD/DVD, tape, etc.
sd*)
if [ $FIRST = Y ] ; then
echo -n "$DEV"
FIRST=N
else
echo -n " $DEV"
fi
;;
esac
fi;
done
}

GetDevParams () {
local DEV VALUE

for DEV in "$@" ; do
while read LINE ; do
# Trim left-hand side
VALUE="${LINE#*:}"

# Trim any leading spaces
VALUE="${VALUE#${VALUE%%[! ]*}}"

# Store interesting values as environment variables for use later
case "${LINE%%:*}" in
"Device Model")
eval ${DEV}Model=\"$VALUE\" ;;
"Serial Number")
eval ${DEV}Serial=\"$VALUE\" ;;
"Firmware Version")
eval ${DEV}Rev=\"$VALUE\" ;;
"User Capacity")
VALUE="${VALUE%% *}"
eval ${DEV}Size=${VALUE//,/} ;;
esac
done <<-EOF
$(smartctl -i "/dev/$DEV")
EOF

eval ${DEV}Partitions=\"$(sfdisk -d /dev/$DEV 2>/dev/null | sed -n '/^\/dev/p' | egrep -v "(Id= [0f])" | sed 's/ .*$//;s:/dev/::')\"

done

}

# Count number of passed arguments
# $1 - $n = Things to count
Count () {
echo $#
}

# Convert a value into something human readable, showing at least
# two significant digits (ie: 1.0T)
# $1 = Value to convert
# $2 = Value to use for K (typically 1000 or 1024)
# Optional: Defaults to 1024
HRead () {
bc <<-EOF
a=$1
b=0
k=${2:-1024}
while ( a > (k*10) && b < 8 ) {
a=a/k
b=b+1
}
if (a >= k && b < 8) {
b=b+1
x=a/k
y=(a-(x*k)) * 10 / k
print x,".",y
} else {
print a
}
if (b==1) print "K"
if (b==2) print "M"
if (b==3) print "G"
if (b==4) print "T"
if (b==5) print "P"
if (b==6) print "E"
if (b==7) print "Z"
if (b==8) print "Y"
EOF
}

# Copy a single partitions from source to destination
# $1 = Source partition
# $2 = Target partition
CopyPartition () {
# Handy sortcuts
local SRCPART="/dev/$1"
local TGTPART="/dev/$2"
local TMPPART="/tmp/$1"

# See if source partition is mounted...
# ...the linux rescue partition should be mounted read-only
set -- $(sed -n "\:$SRCPART:p" /proc/mounts)
if [ -n "$1" ] ; then
IFS="$IFS,"
set -- $4
IFS="$OIFS"

while [ "$#" -ge 1 ] ; do
case $1 in
ro) # Mounted read-only, create alternate device to use for cloning
rsync -qva "$SRCPART" "$TMPPART"
SRCPART="$TMPPART"
;;
rw) # FAIL: Source partition is mounted read-write
echo "Source partition $SRCPART is mounted read-write!"
Fail
;;
esac
shift
done
fi

# Determine partition filesystem type
TYPE=$(blkid -s TYPE -o value "$SRCPART")
echo $TYPE

case $TYPE in
ntfs)
ntfsclone -O "$TGTPART" "$SRCPART" || Fail ;;
#partclone.ntfs -bIR -o "$TGTPART" -s "$SRCPART" || Fail ;;
ext*)
partclone.extfs -bIR -o "$TGTPART" -s "$SRCPART" || Fail ;;
*)
partclone.dd -bIR -o "$TGTPART" -s "$SRCPART" || Fail ;;
esac
}

# Copy a single partitions from source to destination
# $1 = Source partition
# $2 = Target partition
CopyPartition () {
# Handy sortcuts
local SRCPART="/dev/$1"
local TGTPART="/dev/$2"
local TMPPART="/tmp/$1"

# See if source partition is mounted...
# ...the linux rescue partition should be mounted read-only
set -- $(sed -n "\:$SRCPART:p" /proc/mounts)
if [ -n "$1" ] ; then
IFS="$IFS,"
set -- $4
IFS="$OIFS"

while [ "$#" -ge 1 ] ; do
case $1 in
ro) # Mounted read-only, create alternate device to use for cloning
rsync -qva "$SRCPART" "$TMPPART"
SRCPART="$TMPPART"
;;
rw) # FAIL: Source partition is mounted read-write
echo "Source partition $SRCPART is mounted read-write!"
Fail
;;
esac
shift
done
fi

# Determine partition filesystem type
TYPE=$(blkid -s TYPE -o value "$SRCPART")
echo $TYPE

case $TYPE in
ntfs)
ntfsclone -O "$TGTPART" "$SRCPART" || Fail ;;
#partclone.ntfs -bIR -o "$TGTPART" -s "$SRCPART" || Fail ;;
ext*)
partclone.extfs -bIR -o "$TGTPART" -s "$SRCPART" || Fail ;;
*)
partclone.dd -bIR -o "$TGTPART" -s "$SRCPART" || Fail ;;
esac
}

# List Drive
# $1 = Index
# $2 = Device
ListDrive () {
local SIZE MODEL SERIAL FWREV
eval SIZE=\"\$$2Size\"
eval MODEL=\"\$$2Model\"
eval SERIAL=\"\$$2Serial\"
eval FWREV=\"\$$2Rev\"

SIZE=$(HRead $SIZE 1000)

printf "%9s %5s %-30s %-20s %-8s\n" "$1" "$SIZE" "$MODEL" "$SERIAL" "$FWREV"
}

# Allow user to choose a disk
# $1 = Disk "type" (for user prompts)
# $@ = Device choices
SelectDisk () {
local LABEL="$1"
shift
local MaxVal=$#

clear

cat <<EOF
${white}
Select $LABEL Disk:
${ltgry}
More than one potential $LABEL disk was detected.
Please select the $LABEL disk.

Disk Size Model Serial Number FW Rev
---- ----- ------------------------------ -------------------- --------
EOF

x=0
while [ $# -gt 0 ] ; do
x=$(($x + 1))

ListDrive "$x)" "$1"
eval local Drive$x=\"$1\"

shift

done

cat <<EOF

-----------------------------------------------------------------------
EOF
echo -n " Disk to use as $LABEL: "

read OPT ARGS
NewTekCheck "$OPT"

if [ -z "${OPT//[0-9]/}" -a -n "$OPT" ] ; then
if [ "$OPT" -ne 0 -a "$OPT" -le $MaxVal ] ; then
eval echo "\$Drive$OPT" >&2
return 0
fi
fi
return 1
}

NewTekArgs () {
# Get any NewTek= string from the kernel command line
NewTekArg=$(sed '{s/^NewTek=//;t end;s/.* NewTek=//;t end;s/.*//;};:end;s/ .*//' /proc/cmdline)
IFS=','
set -- $NewTekArg
IFS="$OIFS"
while [ $# -ne 0 ] ; do
case $1 in
*=*)
eval NewTek$1 ;;
*)
eval NewTek$1=Y ;;
esac
shift
done
}

######################
# Main program start #
######################

# Disable console blanking, to avoid scaring users!
setterm -blank 0

clear

# Source script based on desired action
# Factory restore
# Clone system drive
# Restore from backup drive

# See if we were passed any parameters
NewTekArgs

case $NewTekTask in
clone)
. $MNT_CDROM/NewTek/bin/autorun.clone
;;
restore)
. $MNT_CDROM/NewTek/bin/autorun.restore
;;
factory)
. $MNT_CDROM/NewTek/bin/autorun.factory
;;
*)
. $MNT_CDROM/NewTek/bin/autorun.factory
;;
esac







Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts