How to Recover Data with Linux

Data recovery with Linux distributions.

While used successfully many times, the following information has the possibility of making your data permanently inaccessible. When in doubt, visit one of the ITS centers. Data recovery is never guaranteed.

Overview

Explain how to recover data with Linux.

Difficulty Level

Advanced users only.

Part I - Obtaining Linux

What is Linux?

Linux is the backbone (known as the kernel) of a family of operating systems. In a similar sense, Windows is a family of operating systems (2000, XP, Vista, etc). Some of the most popular operating systems in the Linux family are Ubuntu, Fedora, and Knoppix. In this tutorial we will be using Knoppix to preform the data recovery, but any Linux distribution should work fine. The first step is to download a Linux Live CD. When you turn your computer on your operating system (lets say Windows Vista) is loaded from the harddisk into the ram. When you use a live CD, the operating system is loaded from a CD disk to the ram. The benefit of this is that you do not need to make any changes to the harddisk to run this operating system, every thing is done from the CD. In fact, one can use a live operating system off of a CD even if there isn't a harddisk in the computer! Linux subscribes to the philosophy of open source software, in other words, Linux is completely free. Some companies may develop operating systems built on Linux which they try to sell (such as Red Hat), but the majority of distributions are free. Knoppix is one of these free operating systems.

Downloading Knoppix

1) Click to following link to connect to ftp.kernel.org (Knoppix Download)
2) Accept the license agreement
3) The versions are listed from oldest to most recent (look at the dates)
4) Scroll down to the latest version. It will be called something like "KNOPPIX_xxxx-EN.iso" (as of this document, the latest version is "KNOPPIX_V6.0.1CD-2009-02-08-EN.iso")
5) Verify the file size, it will be around 650000KB (as opposed to the other files which are about 1 KB)
6) Click on it. Select "Save File". Wait for the file to download.

Downloading Knoppix - Alternative

1) Visit the Knoppix official website - knoppix.net
2) Click on the link "Get Knoppix"
3) Knoppix offers several different ways to get their OS
a) Download from one of the mirrors
c) Pay $1.95 for them to mail you a CD
The easiest way is to just download from one of the mirrors so that is the way we will cover here.
4) Scroll down to "Download Knoppix for free with FTP"
5) Click "Mirror list on the official site"
6) There are three columns, "Download From", "Protocol", and "Site Sponsor"
7) Pick a Site Sponsor (closer locations download faster)
8) In the same row as the Site Sponsor you wish to download from, select <http> from the protocol column.
9) Follow steps 2-6 as listed above.
Note: The Site Sponsor may list the file size in terms of MB instead of KB. (650000KB is about the same as 650MB)

Burning the CD

The file you just downloaded is a called an ISO (note the extension .iso). An ISO is an exact replica (called an image) of a CD Disk. Windows cannot natively burn an ISO file to a CD, fortunately there are many free programs which allow you to do this. We recommend using ImgBurn. You can download it here from Softpedia. (ImgBurn Download)

  1. Run ImgBurn. You will be presented with this screen:
  2. Click "Write image file to disk." You will be presented with this screen:
  3. At the top, under "Source", it says "Please select a file." Click the magnifying glass on top of the folder
  4. Navigate to the directory where you downloaded Knoppix and select the ISO
  5. In ImgBurn, under "Destination", make sure your CD drive is selected and there is a blank CD-R in the drive (700MB or more).
  6. Press the green "Play" button in ImgBurn. It will burn the ISO to the CD, eject the CD, pull the CD back in, verify the CD, then eject it again.

Part II - Using Linux

Starting Linux

  1. Insert your Linux Live CD into your CD dive and reboot the computer
  2. If you have a Dell Bookstore computer then press the F12 key when the computer is first booting up (at the Dell Logo)
  3. If you do not have a Dell Bookstore Computer, a message should display while booting such as "<Key Here> for boot options" or "<Key Here> for boot manager." The most common keys are <Esc>, <F2>, and <F12>.
  4. When you enter the boot list (white text on a black background), use the arrow keys to select your CD Drive
  5. You will see two boot screens.
    First this:

    Then This:
  6. After Knoppix has finished booting, you will be presented with the LDXE (Lightway X11 Desktop Enviroment).
    Your screen will look like this:
  7. Click the Terminal icon at the bottom left of the screen
  8. Type "fdisk -l" and press enter
  9. Take note of what drives appear and their names. In the example there are 3 devices. A harddisk (sda1 40.0GB), a usb drive (sdb1 4110MB), and a second usb drive (sdc1 1031MB).
  10. We want to take data off of the harddisk and put it onto the second usb drive to back it up.

Data backup

  1. Click the PCMan icon at the bottom left of the screen.
  2. Navigate to /media/
  3. Select the folder that corresponds to your harddrive. Alternativly you can just click the harddrive icon in the left panel of PCMan.
  4. Open a new windows and navigate to (or click the icon for) your usb drive.
  5. In this example the harddrive is open on the left window and the usb drive (with some data already on it) is opened in the right window.
  6. Now you can simply click and drag to copy files from the harddisk to the usb drive.

Data backup - Alternative

Mount the drives

If Knoppix failed to auto-mount the drives then you must use terminal to manually mount them.

The commands we will use in this section:

1) Click the terminal icon at the bottom left of the screen
2) Type "su" and press enter. Type "fdisk -l" and press enter
3) Take note of which one is the harddisk (It should read HPFS/NTFS under System and have a much larger disk size). In this case the harddisk is /dev/sda1
4) When you mount a device you first enter the program to mount with (such as ntfs-3g) then you enter the device (dev/sda1) then you enter where to mount it to (/mnt/sda1).
5) Type "ntfs-3g /dev/sda1 /mnt/sda1" and press enter (you have now mounted the harddisk)
6) Looking at the result from "fdisk -l", take note of which is the usb drive. In this case, the usb drive we want to use is /dev/sdc1.
7) Type "mount dev/sdc1 /mnt/sdc1" (you have now mounted the usb drive)
8) Now that the dirves are mounted you should be able to copy the data graphical as illustrated above in "Data backup" (substitute /media/ for /mnt/). If you are unable to copy the data graphically, below are the steps to copy data via terminal.

Copy data

The commands we will use in this section:

1) Open terminal
2) You want to navigate to where you mounted the usb drive (in this example we mounted it to /mnt/sdc1". You use the command "cd" to navigate directories. Type "cd /mnt/sdc1" and press enter
3) Type "ls" and press enter. This lists the files in the directory. Files are green, folders and blue. There is a folder called "Documents" on the usb drive, that is where we are going to copy the files to
4) Now we want to navigate to the harddisk. We mounted to "/mnt/sda1". Type "cd /mnt/sda1" and press enter
5) Now type "ls" and press enter to see the files on the harddisk. Because it is mounted as NTFS the files are green and the folders and blue with a green background.
6)You can navigate into directories by typing "cd <directory name>". For example, to enter the "dell" folder we would type "cd dell" and press enter (note: folders with spaces in the name must be enclosed with quotations). To then list the files in that folder you type "ls" and then press enter. To return "up" to the previous directory type "cd .." and press enter.
7) We are going to copy the file "boot.ini" to the "Documents" folder on the usb drive. Type "cp boot.ini /mnt/sdc1/Documents" and press enter.
8) Now navigate to the "Documents" folder on the usb drive by type "cd /mnt/sdc1/Documents" and pressing enter.
9) Type "ls" to view the files in the folder. We can see that boot.ini has been successfully copied to the "Documents" folder on the usb drive.

Copy entire folders

The commands we will use in this section:

1) To copy an entire folder, navigate to the directory where the folder is located
2) Use the command "du -hs" to see how large the folder is
3) Use the command "cp -r <folder to copy> <location to copy to>
4) Look at the example screenshot to see the process of copying an entire folder.

Unmouting the drives (shutting down)

The commands we will use in this section:

  1. You have finished copying all the data, now it is time to unmount the drives and turn off the machine.
  2. Use the command "umount <drive to unmount> <where the drive is mounted>". In this case we use "umount /dev/sda1 /mnt/sda1". The harddisk is now unmounted.
  3. To unmount a plug and play device like the usb drive we add the switch "-l" to the command. In this case we type "umount -l /dev/sdc1 /mnt/sdc1" and we have now unmounted the usb drive.
  4. To shut down the machine we type "shutdown -h now" and press enter. When the machines prompts you to eject the cd and press enter, do so. We're now finished backing up data via Linux.

Sources and Relevant Links

ImgBurn Download

Knoppix Download


#top

SU image
Information Technology and Services
Syracuse, NY 13244-4100
T: 315.443.2677
http://its.syr.edu
Couldn't find it in Answers? Need Additional Help? Click here