(Created page with "==Data Recovery Tips: [http://comorecuperararchivosborrados.com/ como recuperar archivos borrados disco duro]== Measures can be taken that lessen the blow when laptop failure...")
 
(Remove space)
 
(38 intermediate revisions by one user not shown)
Line 1: Line 1:
==Data Recovery Tips: [http://comorecuperararchivosborrados.com/ como recuperar archivos borrados disco duro]==
 
  
Measures can be taken that lessen the blow when laptop failure occurs. Understanding and spotting caution signs can really make a difference for successful data recovery.
+
== Building a minimal RootFS with Busybox, GLIBC and DropBear ==
  
Caution must at all times be used when dealing with exhausting force failure or some other type of computer problem. Reacting with panic will regularly make the issue worse.
+
[http://www.busybox.net/ BusyBox] is a collection of cut down versions of common UNIX utilities compiled into a single small executable. This makes BusyBox an ideal foundation for resource constrained systems.
  
Do's
+
=== Prerequisites ===
  
Backup your information frequently.
+
Install the following prerequisites (assuming an Ubuntu 14.04 build machine):
If you believe there's something mistaken with your laptop shut it down, do not continue to power up as a result of you may do more damage.
+
If you right here a clunk, clunk sound while you power up the drive, close down! Do not panic nor turn the ability button on and off.
+
Package the pressure properly while you send it in to an information recovery specialist. You can lead to further damage to the onerous pressure if it is poorly packaged.
+
Packaging Instructions
+
The easiest packaging subject material to make use of when sending out a drive is the unique field it came in. If the power got here in an anti-static bag only, or was part of a computer system, then using foam rubber can be your next logical choice. Remember to wrap the force in an anti-static bag earlier than packaging.
+
  
Too many times folks use packaging materials that are not a hit in conserving the force secure such as bubble wrap, foam peanuts or paper. Bubble wrap can be utilized if you absolutely can not get your fingers on foam rubber. Just make certain that the pressure is packaged in one of these approach that it cannot move round inside the box.
+
<PRE>
 +
apt-get install gcc-arm-linux-gnueabi
 +
apt-get install libncurses5-dev
 +
apt-get install gawk
 +
</PRE>
  
Don'ts
+
=== BusyBox ===
  
Do not ever think that knowledge recovery is impossible; even in the worst cases, similar to natural screw ups data restoration experts were in a position to retrieve helpful data.
+
BusyBox can be built either as a single static binary requiring no external libraries, or built requiring shared libraries such as GLIBC (default). This setting can be found under BusyBox Settings -> Build Options -> Build BusyBox as a static binary (no shared libs).  
Never do away with the quilt from the hard drive; this may increasingly handiest cause further damage.
+
Do no longer strive information recovery with recurrently to be had instrument utility programs.
+
Do no longer rest your computer on a portable object or piece of furniture. Shock and vibration can lead to critical harm to the onerous drive.
+
Do no longer subject the force to extreme temperatures adjustments both sizzling and cold.
+
In the case the place a drive has been exposed to water, fire and even smoke don't attempt to energy up, the location calls for a professional.
+
  
Let's get to the necessary part first - if you might have simply lost your data, skip prior this introduction and move in an instant to our first tip, so you'll be able to start your rescue operation. If not, a couple of minutes spent now might allow you to so much within the future. Pay different consideration to our third tip.
+
I generally choose to build BusyBox to require GLIBC as it is highly likely you will want to run additional applications that will require GLIBC sometime in the future.  
  
I always considered myself as a reliable man with reliable data. I by no means deleted my recordsdata accidentally, I made regular backups and had an influence supply for my pc to give protection to me against surges and outages. However last year I skilled two instances of data loss where I needed to make use of recovery software. The first used to be a lifeless arduous force that'd infrequently served a year. Subsequently, I by accident deleted a big mission file that used to be too massive for the Recycle Bin. Happily I've were given all my data back, way to excellent recommendation and somewhat preparation.
+
<PRE>
 +
wget https://busybox.net/downloads/busybox-1.32.1.tar.bz2
 +
tar -xjf busybox-1.32.1.tar.bz2
 +
cd busybox-1.32.1/
 +
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- defconfig
 +
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- menuconfig
 +
</PRE>
  
These at hand pointers will will let you keep assured within the face of knowledge loss, regardless of how it occurs.
+
At the menu, you can configure BusyBox options. Once configured, you can build BusyBox:
  
Tip #1: Use your device as little as imaginable till you recuperate all your lost files. The extra process taking place in your arduous disk, the greater the danger that some of your lost information might be written over.
+
<PRE>
 +
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-
 +
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- install CONFIG_PREFIX=/home/export/rootfs
 +
</PRE>
  
- Don’t copy any recordsdata to the disk containing your lost data;
+
=== GLIBC ===
- Avoid browsing the web, as a result of your web browser saves cache files at the disk;
+
- Don’t release any unnecessary programs, because they may be able to additionally use your disk;
+
- Don’t restart your computer.
+
  
Tip #2: Before you cross further, take steps to liberate some area at the disk containing your misplaced files. The extra free space your device has, the fewer chance of overwriting any lost files with new ones. You can do a number of of the next things.
+
GLIBC is the [http://www.gnu.org/software/libc/libc.html GNU C Library] and includes common system calls required by executables running on your system.
  
- Delete vintage files that you simply don’t want anymore (you too can transfer them to another source, like a USB flash drive, instead of deleting);
+
Download, build and install GLIBC:
- Empty your Recycle Bin - to ensure that you haven’t placed any necessary files in there through mistake;
+
- Empty your browser cache. For Internet Explorer, click on the "Tools" menu, then choose "Internet Options". Then, at the "General" tab, click on the "Delete Files..." button.
+
  
Tip #3: To install any instrument after information damage will increase the danger of your data being overwritten, so in case you haven’t had any information issues yet, imagine installing a data restoration program just in case. Prevention is at all times better than cure, and a restoration application is just right insurance in your data. However, in the event you don’t yet have a restoration program, in finding one and - if conceivable - keep away from installing it to the disk where your misplaced information are located.
+
<PRE>
 +
wget http://ftp.gnu.org/gnu/libc/glibc-2.33.tar.xz
 +
tar -xJf glibc-2.33.tar.xz
 +
mkdir glibc-build
 +
cd glibc-build/
 +
../glibc-2.33/configure arm-linux-gnueabi --build=i686-pc-linux-gnu CXX=arm-linux-gnueabi-g++ --prefix= --enable-add-ons
 +
make
 +
make install install_root=/home/export/rootfs
 +
</PRE>
  
Most restoration programs work somewhat similarly. You want to make a choice the disk where the misplaced information are located, allow this system examine the content material of the disk - this will take a while - after which select the record you need to recover. Then, provide a region where you wish to have to save that file. You will have to attempt to steer clear of recuperating files to the same disk. You may use another hard drive, a community or removable media like a floppy disk or USB flash drive.
+
Some programs may require libgcc_s.so, otherwise you will receive an error:
 +
<PRE>
 +
error while loading shared libraries: libgcc_s.so.1: cannot open shared object file: No such file or directory
 +
</PRE>
  
After you get well your files, take a look at that they are correct. If you’ve recovered applications, check that they nonetheless run, or if you’ve recovered documents, check that your words are nonetheless there. Even the best restoration tool can’t ensure 100% results. If a few parts of your files had been overwritten - meaning that other knowledge used to be saved to their area on your disk - after recovery they may contain invalid information. Depending on the type of report involved, partly recovered files like this can also be mended through different utilities.
+
libgcc_s.so.1 can be copied over from your arm-linux-gnueabi installation:
 +
 
 +
<PRE>
 +
cp /usr/lib/gcc-cross/arm-linux-gnueabi/4.7.3/libgcc_s.so.1 /home/export/rootfs/lib
 +
</PRE>
 +
 
 +
=== Preparing RootFS ===
 +
 
 +
Once BusyBox and GLIBC has been cross-compiled, you will want to create the remainder of the root file system. Start by creating the necessary directory structure:
 +
 
 +
<PRE>
 +
mkdir proc sys dev etc/init.d usr/lib
 +
</PRE>
 +
 
 +
Now we must mount the /proc & /sys filesystem and populate the /dev nodes. This can be done at runtime by creating a file called etc/init.d/rcS and adding:
 +
 
 +
<PRE>
 +
#!bin/sh
 +
mount -t proc none /proc
 +
mount -t sysfs none /sys
 +
echo /sbin/mdev > /proc/sys/kernel/hotplug
 +
/sbin/mdev -s
 +
</PRE>
 +
 
 +
and make executable:
 +
 
 +
<PRE>
 +
chmod +x etc/init.d/rcS
 +
</PRE>
 +
 
 +
You should now have a basic, yet quite functional, BusyBox root file system.
 +
 
 +
=== DropBear (Optional) ===
 +
 
 +
[https://matt.ucc.asn.au/dropbear/dropbear.html DropBear] is a small SSH server and client and is useful to allow remote shell access to your system.
 +
 
 +
Download, build and install DropBear:
 +
 
 +
<PRE>
 +
wget https://matt.ucc.asn.au/dropbear/releases/dropbear-2020.81.tar.bz2
 +
tar -xjf dropbear-2020.81.tar.bz2
 +
cd dropbear-2020.81
 +
./configure --host=arm-linux-gnueabi --prefix=/ --disable-zlib CC=arm-linux-gnueabi-gcc LD=arm-linux-gnueabi-ld
 +
make
 +
make install DESTDIR=/home/export/rootfs
 +
</PRE>
 +
 
 +
DropBear requires RSA and DSS (Digital Signature Standard) encryption keys to be generated. I normally do this on the target, but you could generate the keys on the host if you have the dropbearkey executable installed.
 +
 
 +
To generate your keys:
 +
<PRE>
 +
mkdir /etc/dropbear
 +
dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key 
 +
dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key
 +
</PRE>
 +
 
 +
You will also require users and passwords to validate login credentials:
 +
 
 +
<PRE>
 +
touch /etc/passwd
 +
touch /etc/group
 +
adduser root -u 0
 +
</PRE>
 +
 
 +
Unless otherwise specified, root will be given a default home directory of /home/root. However as this doesn't exist, DropBear will close your connection immediately after successfully logging in. To address this, simply create a home directory for root:
 +
 
 +
<PRE>
 +
mkdir /home /home/root
 +
</PRE>
 +
 
 +
DropBear can now be started by running:
 +
 
 +
<PRE>
 +
dropbear
 +
</PRE>
 +
 
 +
and you should be able to remotely login to your system using the root user.
 +
 
 +
If you get an error after logging in, "Server refused to allocate pty" check you have Device Drivers > Character devices > Legacy (BSD) PTY support enabled in your kernel. (Especially applicable to Beaglebone kernels)
 +
 
 +
Alternatively, make sure you have mounted the /dev/pts filesystem (after /dev has been mounted)
 +
 
 +
<PRE>
 +
mkdir /dev/pts
 +
mount -t devpts none /dev/pts
 +
</PRE>
 +
 
 +
=== ldconfig ===
 +
 
 +
ldconfig is used to configure dynamic linker run-time bindings. It creates symbolic links and a cache to the most recent shared libraries. As you build upon your root filesystem and add additional libraries, you may need to run ldconfig.
 +
 
 +
ldconfig will search for libraries in the trusted directory /lib. Additional search paths can be added to the ld.so.conf configuration file. ldconfig looks for a configuration file in /etc/ld.so.conf and generates a warning if this cannot be found. Suppress the warning and extend the search range to include /usr/lib by:
 +
 
 +
<PRE>
 +
echo /usr/lib > etc/ld.so.conf
 +
</PRE>
 +
 
 +
ldconfig will also generate a cache at /etc/ld.so.cache. If this file doesn't exist, it will be automatically generated.
 +
 
 +
Finally, to update the dynamic linker run-time bindings with verbose output, execute:
 +
 
 +
<PRE>
 +
ldconfig -v
 +
</PRE>
 +
 
 +
=== Read Only Filesystems ===
 +
 
 +
If you are using a root file system residing on flash memory, to improve longevity it may be desirable to either mount your rootfs as read only, or to move as many of the frequently written to files (for example /var) to a temporary volatile file system stored in RAM. 
 +
 
 +
The following is an expanded etc/init.d/rcS file demonstrating this.
 +
 
 +
We mount /var and /dev as tmpfs. The device nodes are generated using mdev at boot and from hotplug, hence we move these to a temp file system otherwise they could not be generated on a read only root filesystem.
 +
 
 +
<PRE>
 +
#!bin/sh
 +
mount -t proc none /proc
 +
mount -t sysfs none /sys
 +
mount -t tmpfs none /var
 +
mount -t tmpfs none /dev
 +
mkdir /dev/pts
 +
mount -t devpts none /dev/pts
 +
echo /sbin/mdev > /proc/sys/kernel/hotplug
 +
/sbin/mdev -s
 +
mkdir /var/log
 +
syslogd
 +
dropbear
 +
</PRE>
 +
 
 +
syslogd writes system messages to /var/log/messages and is something you probably don't want constantly writing to flash. After mounting /var as a temp file system, we create the /var/log directory for systemd.

Latest revision as of 11:31, 3 April 2021

Building a minimal RootFS with Busybox, GLIBC and DropBear

BusyBox is a collection of cut down versions of common UNIX utilities compiled into a single small executable. This makes BusyBox an ideal foundation for resource constrained systems.

Prerequisites

Install the following prerequisites (assuming an Ubuntu 14.04 build machine):

apt-get install gcc-arm-linux-gnueabi
apt-get install libncurses5-dev
apt-get install gawk

BusyBox

BusyBox can be built either as a single static binary requiring no external libraries, or built requiring shared libraries such as GLIBC (default). This setting can be found under BusyBox Settings -> Build Options -> Build BusyBox as a static binary (no shared libs).

I generally choose to build BusyBox to require GLIBC as it is highly likely you will want to run additional applications that will require GLIBC sometime in the future.

wget https://busybox.net/downloads/busybox-1.32.1.tar.bz2
tar -xjf busybox-1.32.1.tar.bz2
cd busybox-1.32.1/
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- menuconfig

At the menu, you can configure BusyBox options. Once configured, you can build BusyBox:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- 
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- install CONFIG_PREFIX=/home/export/rootfs

GLIBC

GLIBC is the GNU C Library and includes common system calls required by executables running on your system.

Download, build and install GLIBC:

wget http://ftp.gnu.org/gnu/libc/glibc-2.33.tar.xz
tar -xJf glibc-2.33.tar.xz
mkdir glibc-build
cd glibc-build/
../glibc-2.33/configure arm-linux-gnueabi --build=i686-pc-linux-gnu CXX=arm-linux-gnueabi-g++ --prefix= --enable-add-ons
make
make install install_root=/home/export/rootfs 

Some programs may require libgcc_s.so, otherwise you will receive an error:

error while loading shared libraries: libgcc_s.so.1: cannot open shared object file: No such file or directory 

libgcc_s.so.1 can be copied over from your arm-linux-gnueabi installation:

cp /usr/lib/gcc-cross/arm-linux-gnueabi/4.7.3/libgcc_s.so.1 /home/export/rootfs/lib 

Preparing RootFS

Once BusyBox and GLIBC has been cross-compiled, you will want to create the remainder of the root file system. Start by creating the necessary directory structure:

mkdir proc sys dev etc/init.d usr/lib

Now we must mount the /proc & /sys filesystem and populate the /dev nodes. This can be done at runtime by creating a file called etc/init.d/rcS and adding:

#!bin/sh
mount -t proc none /proc
mount -t sysfs none /sys
echo /sbin/mdev > /proc/sys/kernel/hotplug
/sbin/mdev -s

and make executable:

chmod +x etc/init.d/rcS 

You should now have a basic, yet quite functional, BusyBox root file system.

DropBear (Optional)

DropBear is a small SSH server and client and is useful to allow remote shell access to your system.

Download, build and install DropBear:

wget https://matt.ucc.asn.au/dropbear/releases/dropbear-2020.81.tar.bz2
tar -xjf dropbear-2020.81.tar.bz2
cd dropbear-2020.81
./configure --host=arm-linux-gnueabi --prefix=/ --disable-zlib CC=arm-linux-gnueabi-gcc LD=arm-linux-gnueabi-ld
make
make install DESTDIR=/home/export/rootfs

DropBear requires RSA and DSS (Digital Signature Standard) encryption keys to be generated. I normally do this on the target, but you could generate the keys on the host if you have the dropbearkey executable installed.

To generate your keys:

mkdir /etc/dropbear
dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key  
dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key 

You will also require users and passwords to validate login credentials:

touch /etc/passwd
touch /etc/group
adduser root -u 0

Unless otherwise specified, root will be given a default home directory of /home/root. However as this doesn't exist, DropBear will close your connection immediately after successfully logging in. To address this, simply create a home directory for root:

mkdir /home /home/root

DropBear can now be started by running:

dropbear

and you should be able to remotely login to your system using the root user.

If you get an error after logging in, "Server refused to allocate pty" check you have Device Drivers > Character devices > Legacy (BSD) PTY support enabled in your kernel. (Especially applicable to Beaglebone kernels)

Alternatively, make sure you have mounted the /dev/pts filesystem (after /dev has been mounted)

mkdir /dev/pts
mount -t devpts none /dev/pts

ldconfig

ldconfig is used to configure dynamic linker run-time bindings. It creates symbolic links and a cache to the most recent shared libraries. As you build upon your root filesystem and add additional libraries, you may need to run ldconfig.

ldconfig will search for libraries in the trusted directory /lib. Additional search paths can be added to the ld.so.conf configuration file. ldconfig looks for a configuration file in /etc/ld.so.conf and generates a warning if this cannot be found. Suppress the warning and extend the search range to include /usr/lib by:

echo /usr/lib > etc/ld.so.conf

ldconfig will also generate a cache at /etc/ld.so.cache. If this file doesn't exist, it will be automatically generated.

Finally, to update the dynamic linker run-time bindings with verbose output, execute:

ldconfig -v

Read Only Filesystems

If you are using a root file system residing on flash memory, to improve longevity it may be desirable to either mount your rootfs as read only, or to move as many of the frequently written to files (for example /var) to a temporary volatile file system stored in RAM.

The following is an expanded etc/init.d/rcS file demonstrating this.

We mount /var and /dev as tmpfs. The device nodes are generated using mdev at boot and from hotplug, hence we move these to a temp file system otherwise they could not be generated on a read only root filesystem.

#!bin/sh
mount -t proc none /proc
mount -t sysfs none /sys
mount -t tmpfs none /var
mount -t tmpfs none /dev
mkdir /dev/pts
mount -t devpts none /dev/pts
echo /sbin/mdev > /proc/sys/kernel/hotplug
/sbin/mdev -s
mkdir /var/log
syslogd
dropbear

syslogd writes system messages to /var/log/messages and is something you probably don't want constantly writing to flash. After mounting /var as a temp file system, we create the /var/log directory for systemd.