LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-22-2008, 06:16 PM   #1
microcriminal
LQ Newbie
 
Registered: Jul 2008
Distribution: Ubuntu 8.04, Fedora 9, RHEL 5.1
Posts: 12

Rep: Reputation: 0
extracting raw data copied with dd


to resize a logical partition, i recently took a backup of it using dd using the command:
Code:
dd if=/dev/hda5 of=/backup/hda5-22oct2008.bak.dd
then i resized the partition using parted and now i can't restore the backup into my newly resized partition /dev/hda5 with this simple command
Code:
dd if=/backup/hda5-22oct2008.bak.dd of=/dev/hda5
because it messes up the filesystem!!

how can i extract the raw data from /backup/hda5-22oct2008.bak.dd
there must be a way to do it, right?

ps. yeah, i should have just done a simple cp, i know. it was stupid of me to not do it. agreed. but whatever done is done, right? will really appreciate your help though!

Last edited by microcriminal; 10-22-2008 at 06:17 PM.
 
Old 10-22-2008, 06:18 PM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,337

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
See if you can copy from the backup using cp.

-------------------
Steve Stites

P.S. The file system may have been messed up on the backup step in which case you are out of luck. You can check by running fsck against the backup.

Last edited by jailbait; 10-22-2008 at 06:23 PM.
 
Old 10-22-2008, 06:27 PM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
The dd image contains all the filesystem overhead + all the files. As you already have observed, you can't cram all that back into a smaller space.

When you say "extract", I think you mean extract the FILES--so that you can put them into the newly re-sized partition. I believe you can mount the image as if it were a partition. I've never done this, so look at the man page for mount---or maybe Google on "mount loopback".

Next time around, consider re-sizing the partition (data and all) using something like GParted. (After, of course, backing up the data)
 
Old 10-22-2008, 06:45 PM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Depends what you mean by messing with the filesystem. If you made the partition bigger, then dd'd back, it'll recreate the smaller filesystem in the enlarged partition.
Just like you told it to by using dd.

Shouldn't be a problem - most filesystems allow resize in this situation these days
 
Old 10-22-2008, 06:57 PM   #5
drchuck
Member
 
Registered: May 2007
Posts: 61

Rep: Reputation: 17
pixellany got it right. Your backup file is a filesystem image, which can be mounted. As root, create a directory to act as the mount point, for example /LOOP, and mount it as follows:
Code:
mount -t iso9660 /backup/hda5-22oct2008.bak.dd /LOOP -o loop
 
Old 10-25-2008, 05:28 AM   #6
microcriminal
LQ Newbie
 
Registered: Jul 2008
Distribution: Ubuntu 8.04, Fedora 9, RHEL 5.1
Posts: 12

Original Poster
Rep: Reputation: 0
hey guys! thanks a lot for your response! really appreciate it...
i tried mounting the backup like drchuck mentioned but got this error:
Code:
mount: wrong fs type, bad option, bad superblock on /dev/loop0,
       missing codepage or other error
       In some cases useful info is found in syslog - try
       dmesg | tail  or so
the dmesg | tail tells me this:
Code:
Unable to identify CD-ROM format.
any idea about what is going on?

Last edited by microcriminal; 10-25-2008 at 06:28 AM.
 
Old 10-25-2008, 06:11 AM   #7
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
The filesystem type should be ext3 not iso9660
 
Old 10-25-2008, 06:25 AM   #8
microcriminal
LQ Newbie
 
Registered: Jul 2008
Distribution: Ubuntu 8.04, Fedora 9, RHEL 5.1
Posts: 12

Original Poster
Rep: Reputation: 0
yeah, tried with ext3 as well. this is the message i get:

Code:
VFS: Can't find ext3 filesystem on dev loop0.

Last edited by microcriminal; 10-25-2008 at 06:29 AM.
 
Old 10-25-2008, 06:50 AM   #9
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
What is the output of the folowing command?
Code:
file /backup/hda5-22oct2008.bak.dd
If you have used dd to backup a logical partition, it should not be easy to determine the filesystem type. The file command may give you some direction.
 
Old 10-25-2008, 07:48 AM   #10
microcriminal
LQ Newbie
 
Registered: Jul 2008
Distribution: Ubuntu 8.04, Fedora 9, RHEL 5.1
Posts: 12

Original Poster
Rep: Reputation: 0
Code:
root@noc-101 ~]#file /backup/hda5-22oct2008.bak.dd
/backup/hda5-22oct2008.bak.dd: data
shows it to be a data i.e. anything else other than text or exectuable (data is usually 'binary' or non-printable).
not much help with that either i guess?
 
Old 10-25-2008, 08:24 AM   #11
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Nope... I would have expected something like these for a ext3 partition and a logical partition respectively:
Code:
# file ext3.dd
ext3.dd: Linux rev 1.0 ext3 filesystem data (needs journal recovery)
# file extended.dd
extended.dd: x86 boot sector; partition 2: ID=0x5, starthead 254, startsector 121788765, 4209030 sectors, extended partition table
Indeed "data" is the answer when the file command does not recognize any file type. As a last resource you can try to associate a loop device with the file, then try the fdisk -l command to gather some information, for example
Code:
# losetup /dev/loop2 /backup/hda5-22oct2008.bak.dd
# fdisk -l /dev/loop2
When you've done, don't forget to release the loop device using
Code:
# losetup -d /dev/loop2
 
Old 10-25-2008, 08:25 AM   #12
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,371

Rep: Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750
I suggest you try with a loop mount with an offset.
Quote:
mount -o loop,offset=32256 /backup/hda5-22oct2008.bak.dd /foo
where /foo is a mount point.
I have specified an offset of 32256 (=63*512) bytes for a disk with 63 sectors per track and 512 bytes per sector
You should not need the -t option, but it would not hurt to specify if you know the file system type.
When dd is used to image an extended partition, it includes the extended partition table which is in the first sector of a track. When you do a loop mount, you want to skip over this.
 
Old 10-25-2008, 08:39 AM   #13
microcriminal
LQ Newbie
 
Registered: Jul 2008
Distribution: Ubuntu 8.04, Fedora 9, RHEL 5.1
Posts: 12

Original Poster
Rep: Reputation: 0
coculix, trying your way:
Code:
[root@noc-101 ~]# losetup /dev/loop0 /backup/hda5-22oct2008.bak.dd 
[root@noc-101 ~]# fdisk -l /dev/loop0

Disk /dev/loop0: 106 MB, 106896384 bytes
255 heads, 63 sectors/track, 12 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/loop0 doesn't contain a valid partition table
allend, thanks for the insight but still the problem remains
Code:
[root@noc-101 ~]# mount -t ext3 -o loop,offset=32256 /backup/hda5-22oct2008.bak.dd /LOOP
mount: wrong fs type, bad option, bad superblock on /dev/loop1,
       missing codepage or other error
       In some cases useful info is found in syslog - try
       dmesg | tail  or so

[root@noc-101 ~]# dmesg | tail -2
hfs: unable to find HFS+ superblock
VFS: Can't find ext3 filesystem on dev loop1.

Last edited by microcriminal; 10-25-2008 at 08:41 AM.
 
Old 10-25-2008, 08:54 AM   #14
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,371

Rep: Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750
What does fdisk -l show for your disk?
 
Old 10-25-2008, 09:00 AM   #15
microcriminal
LQ Newbie
 
Registered: Jul 2008
Distribution: Ubuntu 8.04, Fedora 9, RHEL 5.1
Posts: 12

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by allend View Post
What does fdisk -l show for your disk?

about that! i already formatted and resized my /dev/hda5 and all i am left with is the /backup/hda5-22oct2008.bak.dd image of the old /dev/hda5

but with colucix's idea, i could get some info out of the image (as i mentioned in post #13)

this is stupid AND embarrassing to say the least!

Last edited by microcriminal; 10-25-2008 at 09:02 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Application for extracting data from MySql jakobverner Linux - Software 4 10-09-2007 03:39 AM
Extracting data from file using sed EneWolverine Programming 7 12-29-2006 09:23 AM
help extracting data from csv file willinusf Linux - General 10 10-27-2006 09:10 PM
Extracting MySQL data from raw files cs-cam Linux - Software 1 06-12-2006 11:22 PM
Why does my data occupy 3x as much space after being copied? didi156 Linux - General 8 03-29-2005 10:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration