Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
ddrescue & btrfs [done]
View unanswered posts
View posts from last 24 hours

Goto page 1, 2, 3  Next  
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
idella4
Retired Dev
Retired Dev


Joined: 09 Jun 2006
Posts: 1600
Location: Australia, Perth

PostPosted: Fri Nov 05, 2010 7:26 am    Post subject: ddrescue & btrfs [done] Reply with quote

I have a post in kernel & hardware which has clearly gone cold.
I am trying to restore some data from a corrupted partition. It all started as a curiosity experiment to use btrfs.
Following another post by an advocate who had pursued btrfs closely, it appeared btrfs is somewhat of a lemon at this point. Its performance is riddled with errors and predictably my experimental partition broke.
The partition contained kernels and a distfiles folder of many past packages and a portage in an image file.
This was some months ago. The data is entirely non critical. As an exercise I'd just like to retrieve it and put it back and delete my corrupted btrfs file.
I used dd to copy the partition to a file gen2.img, 48.2 Gig. This is because the partition was 48.2 Gig at the time but it was only about half filled.
The btrfs utils' btrfsck is a lemon. It just doesn't work. After trying it I read more past posts and they confirm this.

Mounting gen2.img results in dealing with the failed state of the btrees and metadata.
Attempts to copy out data just produces errors and it hangs. Another post lead me to ddrescue.
ddrescue advises to copy out segments of the corrupted data of origin, such as the first 500 mb or 2 gig.
Doing this results in a a file ok but it's not usable. Mounting the output file, call it rescue.img, results in

It tries very hard to read the partition/drive you point it at and make an image. Naturally, this includes all the defects too.

Code:

genny suse # mount -o loop rescue.img /mnt/ftp
genny suse # mount -o loop rescue.img /mnt/ftp
mount: wrong fs type, bad option, bad superblock on /dev/loop1,
       missing codepage or helper program, or other error
       In some cases useful info is found in syslog - try
       dmesg | tail  or so

genny suse # tail /var/log/messages
Nov  5 23:19:20 genny init: Id "s1" respawning too fast: disabled for 5 minutes
Nov  5 23:19:53 genny kernel: [ 3780.806009] device fsid 3040bc2891641def-d82a5bf1c9c6afa7 devid 1 transid 10531 /dev/loop1
Nov  5 23:19:53 genny kernel: [ 3780.806745] attempt to access beyond end of device
Nov  5 23:19:53 genny kernel: [ 3780.806748] loop1: rw=0, want=91300760, limit=88005224
Nov  5 23:19:53 genny kernel: [ 3780.806757] attempt to access beyond end of device
Nov  5 23:19:53 genny kernel: [ 3780.806760] loop1: rw=0, want=91300760, limit=88005224
Nov  5 23:19:53 genny kernel: [ 3780.806768] attempt to access beyond end of device
Nov  5 23:19:53 genny kernel: [ 3780.806770] loop1: rw=0, want=91562904, limit=88005224
Nov  5 23:19:53 genny kernel: [ 3780.806777] btrfs: failed to read tree root on loop1
Nov  5 23:19:53 genny kernel: [ 3780.810041] btrfs: open_ctree failed

genny suse # ls -l
total 44002640
drwx------ 2 root root       16384 Nov  5 11:56 lost+found
-rw-r--r-- 1 root root 45058674688 Nov  5 23:18 rescue.img


Now here is a new problem. ext4 is missing correct space readings. This partition of 50 gig but it's claiming 100% filled at 45 gig. I shall reboot and see if it corrects. However, the problem is that whem attempting to copy out a segment, on mounting rescue.img, it is looking for the end of the drive at around 48 gig. This makes a mockery of its own advice to copy out segments, unless these segments are ot intended to be mounted and produce a set of files and folders. For me, anything less than a mountable image file that orders the data content in a dolphin type may is missing the mark.

I shall have to reboot to acquire what I intended and edit this entry to outline the shortcoming.

ok,
Code:

idella@genny ~ $ df /mnt/suse
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda1             51613016  47254464   1736748  97% /mnt/suse

idella@genny /mnt/suse $ ls -l
total 45554080
drwx------ 2 root root       16384 Nov  5 11:56 lost+found
-rw-r--r-- 1 root root 46647347712 Nov  5 23:34 rescue.img
idella@genny /mnt/suse $ sudo -s
genny suse # mount -o loop rescue.img /mnt/ftp
.genny suse # mount -o loop rescue.img /mnt/ftp
mount: according to mtab /mnt/suse/rescue.img is already mounted on /mnt/ftp as loop
genny suse # ls /mnt/ftp
boot                          linux-2.6.31-xen-r10          packages
distfiles                     linux-2.6.32-xen-r1           stage3-amd64-20091231.tar.bz2
linux-2.6-xen                 linux-2.6.32.19-xen           store.img
linux-2.6.30-gentoo-r8        linux-2.6.34-gentoo-r2        usr
linux-2.6.30-gentoo-r8-amd64  linux-2.6.34-gentoo-r2-amd64  xen-3.4-testing.hg
linux-2.6.31-gentoo-r6        linux-2.6.34-xen-amd64        xen-sources-2.6.34.ebuild
linux-2.6.31-gentoo-r6-amd64  old
genny suse # umount /mnt/ftp



This is a hang. The above is my data in the saved gen2.img. So rescue.img is more or less a copy of gen2.img.
reboot

This

Code:

idella@genny /mnt/suse $ sudo btrfsck rescue.img
parent transid verify failed on 41647026176 wanted 10501 found 10514
parent transid verify failed on 41647026176 wanted 10501 found 10514
parent transid verify failed on 41647026176 wanted 10501 found 10514


proves that rescue.img is more a less a partial clone of gen2.img.
I have already had some tips from Neddy;
Quote:

[ddrescue] tries very hard to read the partition/drive you point it at and make an image. Naturally, this includes all the defects too.


/mnt/suse is formatted ext4. The output file rescue.img I have finally determined is a btrfs file image.
This undermines everything I have done.
The intent is to output a file in an intact file system that is usable. i.e. a file in ext4 with the data.
So, the rescue.img file contains the data allright, just as does gen2.img, but they are corrupted.

The tool for the job should be btrfsck but it suffers the features of an experimental fs in development; it doesn't yet work.
e.g.

Code:

idella@genny /mnt/fedora/store $ sudo btrfs-debug-tree -e gen2.img
Password:
parent transid verify failed on 41647026176 wanted 10501 found 10514
parent transid verify failed on 41647026176 wanted 10501 found 10514
parent transid verify failed on 41647026176 wanted 10501 found 10514

idella@genny /mnt/fedora/store $ sudo btrfsck gen2.img
Password:
parent transid verify failed on 41647026176 wanted 10501 found 10514
parent transid verify failed on 41647026176 wanted 10501 found 10514
parent transid verify failed on 41647026176 wanted 10501 found 10514


Does anyone know how to use ddrescue properly?
Is there another way to approach this?
Please refrain from any more tops along the lines of fixing the metadata and btrees. That amounts to writing a proper btrfsck in place of the developers. I'm not a C programmer developer as much as I wish I were.

I have a second query. Prior to formatting /dev/sda1 50 gig partition, it had a suse on it.
I used tar to make a suseimg.tar.bz2 on a /mnt/gentoo as a copy of the system. The tar file was about 14 gig.
On attempting to untar the system back onto /dev/sda1, I was floored to observe

Code:

idella@genny /mnt/suse $ ls -l /mnt/gentoo
total 10268
drwxrwsr-x 3 root portage     4096 Nov  5 10:21 distfiles
drwx------ 2 root root       16384 Nov  5 05:48 lost+found
drwxr-xr-x 3 root root        4096 Nov  5 10:21 packages
-rw------- 1 root root    10485760 Nov  5 05:57 pide41bebf.tmp
-rw-r--r-- 1 root root         140 Nov  5 12:09 suse.img.tar.bz2


I have saved systems like this before. What could possibly have happened to the suse.img.tar.bz2?
I'm served up with a completely separate data retrieval exercise.
_________________
idella4@aus


Last edited by idella4 on Tue Nov 09, 2010 8:31 pm; edited 3 times in total
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54424
Location: 56N 3W

PostPosted: Fri Nov 05, 2010 7:52 pm    Post subject: Reply with quote

idella4,

You have a broken btrfs. When you use dd or ddrescue, you have a file on an ext4 filesystem containing a image of your broken btrfs.
There is no magic to convert a broken btrfs filestem to ext4.

Many filesystems store key metadats at the front of the filesystem. e.g. vfat. As long as you have everything up to the root directory, you can mount such a truncated filesystem. I think the same its true of ext2 and ext3. Its not a good idea to put the metadata at the front as it slows down access to the end of the filesystem, unless the metadata is cached. Maybe btrfs has distributed metadata.

In short, you fix your btrfs file system or go fishing for your data yourself, on the broken filesystem. They are really your only choices.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
idella4
Retired Dev
Retired Dev


Joined: 09 Jun 2006
Posts: 1600
Location: Australia, Perth

PostPosted: Sat Nov 06, 2010 7:30 am    Post subject: Reply with quote

NeddySeagoon wrote:


There is no magic to convert a broken btrfs filestem to ext4.


roger that. That's not what I was actually trying to do.
From what I said in the reply your your last IM, I as just making an output file. From ddrescue's own docs [can't remember which source] it recommends to make file segments. I am posting this because trying to do it doesn't work. Now having used it before, I was expecting the output file to just be a file on the resident destination partition. /mnt/gentoo was the btrfs partition. It's now re-formatted to ext4. So I made a 2G file of the first 2 gig. I can
cat /mnt/rescue.img, but I can't mount it. Now logically rescue.img of size 2 gig is an ext4 file on an ext4 partition.

From my introductory post in this thread here is my problem;

Code:

genny suse # mount -o loop rescue.img /mnt/ftp
mount: wrong fs type, bad option, bad superblock on /dev/loop1,
       missing codepage or helper program, or other error
       In some cases useful info is found in syslog - try
       dmesg | tail  or so

genny suse # tail /var/log/messages
Nov  5 23:19:20 genny init: Id "s1" respawning too fast: disabled for 5 minutes
Nov  5 23:19:53 genny kernel: [ 3780.806009] device fsid 3040bc2891641def-d82a5bf1c9c6afa7 devid 1 transid 10531 /dev/loop1
Nov  5 23:19:53 genny kernel: [ 3780.806745] attempt to access beyond end of device
Nov  5 23:19:53 genny kernel: [ 3780.806748] loop1: rw=0, want=91300760, limit=88005224
Nov  5 23:19:53 genny kernel: [ 3780.806757] attempt to access beyond end of device
Nov  5 23:19:53 genny kernel: [ 3780.806760] loop1: rw=0, want=91300760, limit=88005224
Nov  5 23:19:53 genny kernel: [ 3780.806768] attempt to access beyond end of device
Nov  5 23:19:53 genny kernel: [ 3780.806770] loop1: rw=0, want=91562904, limit=88005224
Nov  5 23:19:53 genny kernel: [ 3780.806777] btrfs: failed to read tree root on loop1
Nov  5 23:19:53 genny kernel: [ 3780.810041] btrfs: open_ctree failed


Mounting rescue.img in std mount, it's trying to read the end of file/folder at pos 91300760 [want=91300760]. This pos is near the end of file, so I had to clear my 50 gig /dev/sda1 /mnt/suse to make room for an output file of size 48Gig. [This incidentally lead to saving suse which got lost in the suseimg.tar.bz2, a separate issue] On making it and mounting it, the file rescue.img has done exactly as you said and it became a part clone of gen2.img; it inherited the corruption I was attempting to bypass and also the btrfs identity.
In making rescue.img, ddrescue's output reported no read errors, no errors in reading all 48 gig. I's no better than gen2.img

Quote:

In short, you fix your btrfs file system or go fishing for your data yourself, on the broken filesystem. They are really your only choices.


roger that. The task is to help me implement this.

Years ago in windows I was forever losing data and partitions and acquiring free data retrieval software, so I developed an interest in it because it kept happening and I kept needing it. On switching to linux, I am much more savvy and have not really touched it since.
This is really my first encounter, and it's on experimental btrfs with repeatable data, so I no longer really lose data, until suseimg.tzr.bz2!
This is a bit like taking on xen & libvirt, only this time with you in my corner you have more knowledge on the subject. [Will you ever get around to xen??]
I am merely sharpening my linux low level skills and this is low level. I'm asking you to help use dd or ddrescue competently.

Here is the data

Code:

idella@genny /mnt/fedora/store $ sudo mount -o loop gen2.img /mnt/ftp
Password:
idella@genny /mnt/fedora/store $ ls -l /mnt/ftp
total 3202253
drwxr-xr-x 1 root   root           352 Jan 26  2010 boot
drwxrwsr-x 1 root   portage     139746 Aug 25 00:17 distfiles
drwxr-xr-x 1 root   root          1214 Aug 22 21:12 linux-2.6-xen
drwxr-xr-x 1 root   root          1236 Jul 31 21:27 linux-2.6.30-gentoo-r8
drwxr-xr-x 1 root   root          1208 Aug  1 08:48 linux-2.6.30-gentoo-r8-amd64
drwxr-xr-x 1 root   root           412 Aug 12 06:18 linux-2.6.31-gentoo-r6
drwxr-xr-x 1 root   root          1214 Jul 29 03:57 linux-2.6.31-gentoo-r6-amd64
drwxr-xr-x 1 root   root          1428 Aug 18 02:05 linux-2.6.31-xen-r10
drwxr-xr-x 1 root   root           452 Aug 12 09:19 linux-2.6.32-xen-r1
lrwxrwxrwx 1 root   root            13 Aug 17 01:17 linux-2.6.32.19-xen -> linux-2.6-xen
drwxr-xr-x 1 root   root           412 Aug 12 08:12 linux-2.6.34-gentoo-r2
drwxr-xr-x 1 root   root          1040 Aug  5 08:51 linux-2.6.34-gentoo-r2-amd64
drwxr-xr-x 1 root   root           888 Aug  5 04:03 linux-2.6.34-xen-amd64
drwxr-xr-x 1 root   root            40 Aug 12 11:26 old
drwxr-xr-x 1 root   root           596 Aug 22 22:45 packages
-rw-r--r-- 1 idella users    140897100 Jan 21  2010 stage3-amd64-20091231.tar.bz2
-rw-r--r-- 1 root   root    4294968320 Aug 25 00:25 store.img
drwxr-xr-x 1 root   root            14 Aug 20 20:10 usr
drwxr-xr-x 1 root   root           344 Jul 26 08:12 xen-3.4-testing.hg
-rw-r--r-- 1 root   root           798 Jun  1 15:09 xen-sources-2.6.34.ebuild


You and anyone else would probably and properly advise to delete more than half of it. The exercise it to retrieve data.

Quote:

The skip and seek options are also useful in data recovery. See man dd.


Code:

idella@genny /mnt/fedora/store $ man dd

.................
       seek=BLOCKS
              skip BLOCKS obs-sized blocks at start of output

       skip=BLOCKS
              skip BLOCKS ibs-sized blocks at start of input


I have no idea what this is telling me or how it heps.

Quote:

Use dd to get a piece of the file. On an undamaged disk dd and ddrescure work in exactly the same way
.... ddrescure should never ouput a trail of partial files.


Yes they do!!! From perusing ddrescue's man, I use

Code:

idella@genny /mnt/fedora/store $ sudo dd if=gen2.img of=segment count=5000000   
5000000+0 records in
5000000+0 records out
2560000000 bytes (2.6 GB) copied, 114.648 s, 22.3 MB/s
idella@genny /mnt/fedora/store $ sudo mount -o loop segment /mnt/ftp
mount: wrong fs type, bad option, bad superblock on /dev/loop0,
       missing codepage or helper program, or other error
       In some cases useful info is found in syslog - try
       dmesg | tail  or so

idella@genny /mnt/fedora/store $ sudo tail /var/log/messages
Nov  7 02:23:17 genny kernel: [  592.111915] attempt to access beyond end of device
Nov  7 02:23:17 genny kernel: [  592.111918] loop0: rw=0, want=91300760, limit=5000000
Nov  7 02:23:17 genny kernel: [  592.111928] attempt to access beyond end of device
Nov  7 02:23:17 genny kernel: [  592.111930] loop0: rw=0, want=91300760, limit=5000000
Nov  7 02:23:17 genny kernel: [  592.111938] attempt to access beyond end of device
Nov  7 02:23:17 genny kernel: [  592.111940] loop0: rw=0, want=91562904, limit=5000000
Nov  7 02:23:17 genny kernel: [  592.111947] btrfs: failed to read tree root on loop0
Nov  7 02:23:17 genny kernel: [  592.115025] btrfs: open_ctree failed
Nov  7 02:23:18 genny sudo:   idella : TTY=pts/3 ; PWD=/mnt/fedora/store ; USER=root ; COMMAND=/bin/tail /var/log/messages
Nov  7 02:23:18 genny sudo: pam_unix(sudo:session): session opened for user root by idella(uid=0)


Code:

idella@genny /mnt/fedora/store $ sudo ddrescue -i 0 -s 2000000000 gen2.img /mnt/gentoo/rescue.img

Press Ctrl-C to interrupt
rescued:   844366 kB,  errsize:       0 B,  current rate:   18743 kB/s
rescued:        2 GB,  errsize:       0 B,  current rate:   12189 kB/s
   ipos:     1999 MB,   errors:       0,    average rate:   22335 kB/s
   opos:     1999 MB,     time from last successful read:       0 sen2.img /mnt/gentoo/rescue.
Finished             


and rescue.img is unmountable. Simply, what am I doing wrong???????????????????????????????????????????
This is confounding your tips. That said, mounting the file is my idea. Mounting it should provide the data in processed readable form.
How else would you access the data to read and use it?
They are both recording from gen2.img data which must contain the start and end point of some files or folders that have their end point located at or near the very end of gen2.img

From my understanding, a segment file of any selected 2 gig is makeable and accessible, and man ddrescue cites a -C option to not read beyond the stipulated limit in the log file.
ok, can you tell me how to get it to work? I try including it and it skips out and says nothing to do! The info is just light on with some good examples, and they assume the source is a partition or whole drive rather than an image file located in a partition. At this point, the gen2.img need be repaired in order to re-write it back to /mnt/gentoo.

Neddy, repairing it requires the knowledge base of a btrfs developer, not me unless you can help me acquire this level of knowledge! As I said in the IM, I tried reading the description of the btrfs design and I couldn't understand a word of it. Can you?

I can cat rescue.img and observe the data. I suppose I can bung it into kwrite an read it, and I can use a hexeditor, which I have done in the past and shall have to figure what it's called and emerge it if I move to that path. The hexedit path is clearly viable, since you can read and copy out any selected content.
At this low level, the user needs to understand how files and folders are constructed, how non-contiguous segments are linked and how to access and join non-contiguous segments, how to identify file types and a file's beginning and end, and ofcourse how to put this all together and make a sensible selection of data to copy out that is meaningful and usable, and so on!!!!!!!!. When I last used a hex editor, I didn't know this stuff and I still don't.

Of the content, the kernels are re-emergeable. The store.img I may not even use again and I have made repeats of it anyway. The folder that I do miss if any is distfiles. It have gentoo 32 & 64, and I have moved towards using one portage for both systems, saving huge file space by avoiding doubling up.
That said, the distfiles folder was huge, containing content of my intermittent gentoo package collections over years. e.g. ked-3.5.9. I did have both systems at the time pointing both system's portage to the common distfiles folder. The content of that I could well retrieve with hexedit, if I knew how to use it.

BTW anyone else can answer. Is it only Neddy equipped to address these queries?
_________________
idella4@aus
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54424
Location: 56N 3W

PostPosted: Sat Nov 06, 2010 2:25 pm    Post subject: Reply with quote

idella4,

dd and ddrescue clone the area of a disk you point them to. The only difference is how they handle areas that cannot be read from the drive.
You have no such areas. Your btrfs filesystem underlying drive reads every block properly. There are no CRC errors or bad blocks.
Unfortunately, the filesystem metadata stored in some of these blocks is not correct, so mount won't work. No amount of low level copying of data will change that.

Emerge hexedit, make your image file read only, so you don't change it accidently and go fishing for
Code:
# Automatically generated make config: don't edit

When hexedit finds that, you have found the top of a kernel .config. Now you need some luck ... you need the file to be contiguious. .config files are fairly small and are always written in one go, so on a filesystem that is not close to full, you have a good chance.
Mark the start of the .config file and scroll through until you find the end. Mark the end of the .config. Now you can write it out to a file somewhere else. man hexedit. You rarely do data recovery in situ.

Repeat the search mark and save process ...
The down side is that you will find .config files that have been deleted but not yet overwritten - you can't tell as the metadata is damaged.
Be patient. It takes a long time to search 50G.

To attempt to fix the metadata, you first have to understand what it is and where it is. Don't bother. When you know enough to edit the metadata on dsk, you will know as much about btrfs as the developers do.

I would be tempted to suggest you try sleuthkit, but its unlikely to support btrfs yet.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
idella4
Retired Dev
Retired Dev


Joined: 09 Jun 2006
Posts: 1600
Location: Australia, Perth

PostPosted: Sat Nov 06, 2010 3:01 pm    Post subject: Reply with quote

ok Neddy, thanks.
Quote:

No amount of low level copying of data will change that.


says use of dd or ddrescue isn't going to help much. I can deal with that. I shall emerge this hexedit and spark it up.
Now, once finding a kernel .config, tht's all well & good, but can you continue and elaborate an how to use hexedit to read and copy out a kernel comprising 5-700 mb of files and folders. My crude understanding at this point is to identify files and copy them out. kernels compiled or not are huge.

If push came to shove I could live with not re-acquiring kernels. I have all those kernel configs in my /boot and can replicate all as easy as pie.
The folder I would like back is distfiles which contains about 3 gig of gentoo packages.
Can tou provide the tips on how to find those files within kexedit. Most of those files will likely be contiguous.
Better still, How to capture the folder and all content in one hit.

What IS a CRC error?
_________________
idella4@aus


Last edited by idella4 on Sat Nov 06, 2010 3:22 pm; edited 1 time in total
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54424
Location: 56N 3W

PostPosted: Sat Nov 06, 2010 3:21 pm    Post subject: Reply with quote

idella4,

The kernel is hundreds of binary files - don't even think about it. True, they will all be in one directory but you have no idea if the directory structure is intact or not.
Nor do you know where to find it, nor how to read it when you do. Thats all documented of course but its not needed.

Once you have recovered the .config file, you can get the kernel sources, patch sets and use the recovered .config to recreate the kernel or am I missing something?
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
idella4
Retired Dev
Retired Dev


Joined: 09 Jun 2006
Posts: 1600
Location: Australia, Perth

PostPosted: Sat Nov 06, 2010 3:23 pm    Post subject: Reply with quote

yes, sure, that's true. We are on the same page Neddy. That is exactly why I wasn't so hot on the hexedit option in the initial post.
It was fundamental that a kernel of that size and complexity would take weeks to copy out one file at a time, unless one could write a program in C to do it it one hit, but you point out the folder and the content can't be reliably tracked from faulty metadata.
I can see now you were thinking I particularly wanted the kernel configs again. They were all happily saved in their normal place in boot.
Like I said, I'm treating this as an exercise in going about data retrieval. At this point a number of basic points are in place re the btrfs and metadata.

ok, we both understand the whole kernels are re-emergeable. The distfiles are too, but only the one that exist in the current portage tree.

the gentoo package files, how to track and copy them out I think is all that's really left.
I presume just ascii search for .tar.bz2??
_________________
idella4@aus


Last edited by idella4 on Sat Nov 06, 2010 3:36 pm; edited 1 time in total
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54424
Location: 56N 3W

PostPosted: Sat Nov 06, 2010 3:33 pm    Post subject: Reply with quote

idella4,

The direct search and find fails for tarballs. There is nothing to search for and what there is has been compressed with bzip2.
The traditional way would be to search for the file name as this will normally find a directory entry, then decode the directory entry to find the start of the file and the length. Then copy that much data from that location on the filesystem. After the copy, test to see what you got.

You need to know how to read btrfs directory entries, what the reference point is for the start of the file ...
You don't even know that the dir entries are intact.

The last difficulty is that I'm fairly sure btrfs uses tail packing, so the last part of your file maybe somewhere else on the disk. With binary files, thats a disaster. With a kernel .config, you can always patch it up.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
idella4
Retired Dev
Retired Dev


Joined: 09 Jun 2006
Posts: 1600
Location: Australia, Perth

PostPosted: Sat Nov 06, 2010 3:44 pm    Post subject: Reply with quote

Hmmm, ok. [Your 2 IMs are still in my outbox]
Quote:

The direct search and find fails for tarballs


I am a bit puzzled. Help me out here.

Quote:

With binary files, thats a disaster.


I'm referring to gentoo packages. Source code. Binary files are those that are compiled. Seems to me a gentoo package is a directory structure of source code that emerge calls gcc to compile and install.

Quote:

You need to know how to read btrfs directory entries


ok sure. My gen2.img contains one distfiles folder with 3 - 4 gig of gentoo packages. Now I'm still writing my thoughts in the post and have yet to try it.
The distfiles folder has only the one level of data, the packages. What is it you are thinking when citing the btrfs directory entries?
?? the fact that a source code package comprises a number of directories? Otherwise you know about btrfs detail well enough to know that a tar file utilises a dir dtructure as an entry in the file system. Either way, uggggggh!
A number of simple small files would likely be retrievable, such as patches. At this point it's not worth the effort given it's non critical data.

Based upon your last reply, I'm not inclined to bother trying to search for the packages. If it's not the directory structure that poses defeat then the bzip2 state will instead. All of the above require a file's structure to be intact to be accessed and made copyable by a linux system in a linux file system.

That said, I am still mapping out a stupidly mammoth task of searching for some hundreds of packages files and copying them out one at a time.
At this point it appears this learning exercises concludes that it's a lost cause, which is fair enough seeing it stems from an experimental fs.

That rather brings us back to the need to fix the btrfs metadata, which means the gen2.img need wait for a fully operational btrfsck. As you virtually stated yourself, you need to be a btrfs developer to address the broken btrfs state.
Time to retire. Check again tomorrow. Tx for your input as usual.
_________________
idella4@aus
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54424
Location: 56N 3W

PostPosted: Sat Nov 06, 2010 5:00 pm    Post subject: Reply with quote

idella4,

By
Quote:
direct search and find
I mean the way you search the filesystem for a known file fragment when you are searching for a text file.

When you said "packages" I assumed you intended the content of /usr/portage/packages (the binary tarballs) not the content of /usr/portage/distfiles (the source files)
Gentoo source code consists of one or more files in /usr/portage/distfiles plus zero or more files in the ./files dir beside the ebuild.

Lets be clear about what even a working btrfsck will do for you.
It will make the filesystem metadata self consistent - thats all. That does not mean it will restore all the pointers to your data stored on the filesystem. Nor does it mean that your data will be intact, even if the directory entries exist. Thats no different from any other fsck. Think about what e2fsck does and all the fragments that can end up in lost+found.

Even a fsck may not fix your filesystem ... in many cases it will make things worse, not better, which is why you need an image before you run fsck on any filesystem
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
idella4
Retired Dev
Retired Dev


Joined: 09 Jun 2006
Posts: 1600
Location: Australia, Perth

PostPosted: Sat Nov 06, 2010 5:33 pm    Post subject: Reply with quote

Neddy,

good, ok. Just to tidy up, I am puzzled by

Quote:

plus zero or more files in the ./files dir beside the ebuild.


so we are addressing my understanding of a gentoo 'package' in distfiles. [At the risk of being cheeky I did point out my distfiles folder in the root of the gen2.img file] But, no drama. yes there is also the packages folder which I am not concerned about overall.
Could you just explain the ./files beside the ebuild? Just don't follow. The ebuld is in /usr/portage/<package-sub-dir>/

Code:

idella@genny /mnt/fedora/store $ sudo mount -o loop gen2.img /mnt/ftp

idella@genny /mnt/fedora/store $ ls /mnt/ftp/packages/
Packages     app-shells  dev-libs    net-libs      sys-apps   sys-kernel   x11-base
app-admin    app-vim     dev-perl    net-misc      sys-auth   sys-libs     x11-drivers
app-arch     dev-db      dev-util    net-nds       sys-block  sys-process  x11-libs
app-editors  dev-java    media-gfx   net-wireless  sys-devel  virtual      x11-misc
app-misc     dev-lang    media-libs  perl-core     sys-fs     x11-apps     x11-proto

idella@genny /mnt/fedora/store $ ls /mnt/ftp/distfiles/*/
btrfs-progs


This last looks like some error in reading.

Code:

idella@genny /mnt/fedora/store $ ls -l /mnt/ftp/distfiles/btr*
-rw-rw-r-- 1 portage portage 118119 Jul 29 13:26 /mnt/ftp/distfiles/btrfs-progs-0.19.tar.bz2


As an example of the large content in it, just b*

Code:

idella@genny /mnt/fedora/store $ ls -l /mnt/ftp/distfiles/b*
-rw-rw-r-- 1 root    root           0 Nov 18  2009 /mnt/ftp/distfiles/baselayout-1.12.11.1.tar.bz2                                                                                         
-rw-rw-r-- 1 root    portage   269861 Nov 14  2009 /mnt/ftp/distfiles/baselayout-1.12.13.tar.bz2                                                                                           
-rw-rw-r-- 1 portage portage    23232 Feb 16  2010 /mnt/ftp/distfiles/baselayout-2.0.1.tar.bz2
-rw-rw-r-- 1 root    root     2529838 Aug 20  2008 /mnt/ftp/distfiles/bash-3.2.tar.gz
-rw-rw-r-- 1 root    portage  6230779 Nov 15  2009 /mnt/ftp/distfiles/bash-4.0.tar.gz
-rw-rw-r-- 1 portage portage  6598300 May  2  2010 /mnt/ftp/distfiles/bash-4.1.tar.gz
-rw-rw-r-- 1 portage portage   135741 Jan 31  2010 /mnt/ftp/distfiles/bash-completion-1.1.tar.bz2                                                                                           
-rw-rw-r-- 1 portage portage   197574 Jul 25 05:43 /mnt/ftp/distfiles/bash-completion-1.2.tar.bz2                                                                                           
-rw-rw-r-- 1 root    root        1539 Aug 20  2008 /mnt/ftp/distfiles/bash32-001
-rw-rw-r-- 1 root    root        1524 Aug 20  2008 /mnt/ftp/distfiles/bash32-002
-rw-rw-r-- 1 root    root        4599 Aug 20  2008 /mnt/ftp/distfiles/bash32-003
-rw-rw-r-- 1 root    root        2585 Aug 20  2008 /mnt/ftp/distfiles/bash32-004
-rw-rw-r-- 1 root    root        5910 Aug 20  2008 /mnt/ftp/distfiles/bash32-005
-rw-rw-r-- 1 root    root        1298 Aug 20  2008 /mnt/ftp/distfiles/bash32-006
-rw-rw-r-- 1 root    root        1375 Aug 20  2008 /mnt/ftp/distfiles/bash32-007
-rw-rw-r-- 1 root    root        1302 Aug 20  2008 /mnt/ftp/distfiles/bash32-008
-rw-rw-r-- 1 root    root        1882 Aug 20  2008 /mnt/ftp/distfiles/bash32-009
-rw-rw-r-- 1 root    root        6293 Aug 20  2008 /mnt/ftp/distfiles/bash32-010
-rw-rw-r-- 1 root    root        4776 Aug 20  2008 /mnt/ftp/distfiles/bash32-011
-rw-rw-r-- 1 root    root        2555 Aug 20  2008 /mnt/ftp/distfiles/bash32-012
-rw-rw-r-- 1 root    root        1852 Aug 20  2008 /mnt/ftp/distfiles/bash32-013
-rw-rw-r-- 1 root    root        8141 Aug 20  2008 /mnt/ftp/distfiles/bash32-014
-rw-rw-r-- 1 root    root        2293 Aug 20  2008 /mnt/ftp/distfiles/bash32-015
-rw-rw-r-- 1 root    root        1620 Aug 20  2008 /mnt/ftp/distfiles/bash32-016
-rw-rw-r-- 1 root    root        2611 Aug 20  2008 /mnt/ftp/distfiles/bash32-017
-rw-rw-r-- 1 root    root        2433 Aug 20  2008 /mnt/ftp/distfiles/bash32-018
-rw-rw-r-- 1 root    root        8618 Aug 20  2008 /mnt/ftp/distfiles/bash32-019
-rw-rw-r-- 1 root    root        5182 Aug 20  2008 /mnt/ftp/distfiles/bash32-020
-rw-rw-r-- 1 root    root        1814 Aug 20  2008 /mnt/ftp/distfiles/bash32-021
-rw-rw-r-- 1 root    root        3034 Aug 20  2008 /mnt/ftp/distfiles/bash32-022
-rw-rw-r-- 1 root    root        1321 Aug 20  2008 /mnt/ftp/distfiles/bash32-023
-rw-rw-r-- 1 root    root        3228 Aug 20  2008 /mnt/ftp/distfiles/bash32-024
-rw-rw-r-- 1 root    root        1935 Aug 20  2008 /mnt/ftp/distfiles/bash32-025
-rw-rw-r-- 1 root    root        2438 Aug 20  2008 /mnt/ftp/distfiles/bash32-026
-rw-rw-r-- 1 root    root        2690 Aug 20  2008 /mnt/ftp/distfiles/bash32-027
-rw-rw-r-- 1 root    root        1750 Aug 20  2008 /mnt/ftp/distfiles/bash32-028
-rw-rw-r-- 1 root    root        1330 Aug 20  2008 /mnt/ftp/distfiles/bash32-029
-rw-rw-r-- 1 root    root        1558 Aug 20  2008 /mnt/ftp/distfiles/bash32-030
-rw-rw-r-- 1 root    root        1961 Aug 20  2008 /mnt/ftp/distfiles/bash32-031
-rw-rw-r-- 1 root    root        1304 Aug 20  2008 /mnt/ftp/distfiles/bash32-032
-rw-rw-r-- 1 root    root        2181 Aug 20  2008 /mnt/ftp/distfiles/bash32-033
-rw-rw-r-- 1 root    portage     5156 Nov 14  2009 /mnt/ftp/distfiles/bash40-001
-rw-rw-r-- 1 root    portage     1220 Nov 14  2009 /mnt/ftp/distfiles/bash40-002
-rw-rw-r-- 1 root    portage     1749 Nov 14  2009 /mnt/ftp/distfiles/bash40-003
-rw-rw-r-- 1 root    portage     1347 Nov 14  2009 /mnt/ftp/distfiles/bash40-004
-rw-rw-r-- 1 root    portage     2021 Nov 14  2009 /mnt/ftp/distfiles/bash40-005
-rw-rw-r-- 1 root    portage     1133 Nov 14  2009 /mnt/ftp/distfiles/bash40-006
-rw-rw-r-- 1 root    portage     6920 Nov 14  2009 /mnt/ftp/distfiles/bash40-007
-rw-rw-r-- 1 root    portage     1196 Nov 15  2009 /mnt/ftp/distfiles/bash40-008
-rw-rw-r-- 1 root    portage     1821 Nov 15  2009 /mnt/ftp/distfiles/bash40-009
-rw-rw-r-- 1 root    portage     2152 Nov 15  2009 /mnt/ftp/distfiles/bash40-010
-rw-rw-r-- 1 root    portage     1383 Nov 15  2009 /mnt/ftp/distfiles/bash40-011
-rw-rw-r-- 1 root    portage     1459 Nov 15  2009 /mnt/ftp/distfiles/bash40-012
-rw-rw-r-- 1 root    portage     4629 Nov 15  2009 /mnt/ftp/distfiles/bash40-013
-rw-rw-r-- 1 root    portage     3709 Nov 15  2009 /mnt/ftp/distfiles/bash40-014
-rw-rw-r-- 1 root    portage     1914 Nov 15  2009 /mnt/ftp/distfiles/bash40-015
-rw-rw-r-- 1 root    portage     3032 Nov 15  2009 /mnt/ftp/distfiles/bash40-016
-rw-rw-r-- 1 root    portage     1496 Nov 15  2009 /mnt/ftp/distfiles/bash40-017
-rw-rw-r-- 1 root    portage     2614 Nov 15  2009 /mnt/ftp/distfiles/bash40-018
-rw-rw-r-- 1 root    portage     3309 Nov 15  2009 /mnt/ftp/distfiles/bash40-019
-rw-rw-r-- 1 root    portage     2666 Nov 14  2009 /mnt/ftp/distfiles/bash40-020
-rw-rw-r-- 1 root    portage     1547 Nov 14  2009 /mnt/ftp/distfiles/bash40-021
-rw-rw-r-- 1 root    portage     1592 Nov 14  2009 /mnt/ftp/distfiles/bash40-022
-rw-rw-r-- 1 root    portage     2148 Nov 14  2009 /mnt/ftp/distfiles/bash40-023
-rw-rw-r-- 1 root    portage     3049 Nov 14  2009 /mnt/ftp/distfiles/bash40-024
-rw-rw-r-- 1 root    portage     3435 Nov 14  2009 /mnt/ftp/distfiles/bash40-025
-rw-rw-r-- 1 root    portage     1433 Nov 14  2009 /mnt/ftp/distfiles/bash40-026
-rw-rw-r-- 1 root    portage     2010 Nov 14  2009 /mnt/ftp/distfiles/bash40-027
-rw-rw-r-- 1 root    portage     5567 Nov 15  2009 /mnt/ftp/distfiles/bash40-028
-rw-rw-r-- 1 root    portage     3119 Jan 17  2010 /mnt/ftp/distfiles/bash40-029
-rw-rw-r-- 1 root    portage     1649 Jan 17  2010 /mnt/ftp/distfiles/bash40-030
-rw-rw-r-- 1 root    portage     1633 Jan 17  2010 /mnt/ftp/distfiles/bash40-031
-rw-rw-r-- 1 root    portage     1154 Jan 17  2010 /mnt/ftp/distfiles/bash40-032
-rw-rw-r-- 1 root    portage     1380 Jan 17  2010 /mnt/ftp/distfiles/bash40-033
-rw-rw-r-- 1 root    portage     2160 Jan 17  2010 /mnt/ftp/distfiles/bash40-034
-rw-rw-r-- 1 root    portage     1884 Jan 17  2010 /mnt/ftp/distfiles/bash40-035
-rw-rw-r-- 1 portage portage     1445 May  2  2010 /mnt/ftp/distfiles/bash41-001
-rw-rw-r-- 1 portage portage     1799 May  2  2010 /mnt/ftp/distfiles/bash41-002
-rw-rw-r-- 1 portage portage     1407 May  2  2010 /mnt/ftp/distfiles/bash41-003
-rw-rw-r-- 1 portage portage     1705 May  2  2010 /mnt/ftp/distfiles/bash41-004
-rw-rw-r-- 1 portage portage     1626 May  2  2010 /mnt/ftp/distfiles/bash41-005
-rw-rw-r-- 1 portage portage     2166 Jul 24 03:11 /mnt/ftp/distfiles/bash41-006
-rw-rw-r-- 1 portage portage     1610 Jul 24 03:11 /mnt/ftp/distfiles/bash41-007
-rw-rw-r-- 1 root    portage   290069 Aug 19  2008 /mnt/ftp/distfiles/bc-1.06.95.tar.bz2
-rw-rw-r-- 1 root    root       74756 Aug 18  2008 /mnt/ftp/distfiles/bdftopcf-1.0.0.tar.bz2
-rw-rw-r-- 1 portage portage    95983 Jan 30  2010 /mnt/ftp/distfiles/bdftopcf-1.0.2.tar.bz2
-rw-rw-r-- 1 root    portage   774280 Nov 14  2009 /mnt/ftp/distfiles/beecrypt-4.1.2.tar.gz
-rw-rw-r-- 1 portage portage   882758 Jul  2 16:40 /mnt/ftp/distfiles/beecrypt-4.2.1.tar.gz
-rw-rw-r-- 1 portage portage    31171 Aug 19 17:10 /mnt/ftp/distfiles/bignum-0.23.tar.gz
-rw-rw-r-- 1 root    root       36676 Aug 18  2008 /mnt/ftp/distfiles/bigreqsproto-1.0.2.tar.bz2                                                                                           
-rw-rw-r-- 1 root    portage    48575 Jan 18  2010 /mnt/ftp/distfiles/bigreqsproto-1.1.0.tar.bz2                                                                                           
-rw-rw-r-- 1 portage portage   152400 May  1  2010 /mnt/ftp/distfiles/bin86-0.16.17.tar.gz
-rw-rw-r-- 1 root    root       17342 Aug 20  2008 /mnt/ftp/distfiles/binutils-2.18-patches-1.8.tar.bz2                                                                                     
-rw-rw-r-- 1 root    portage    17221 Nov 14  2009 /mnt/ftp/distfiles/binutils-2.18-patches-1.9.tar.bz2                                                                                     
-rw-rw-r-- 1 root    portage 14962245 Aug 20  2008 /mnt/ftp/distfiles/binutils-2.18.tar.bz2
-rw-rw-r-- 1 portage portage     8648 Feb 16  2010 /mnt/ftp/distfiles/binutils-2.20-patches-1.1.tar.bz2                                                                                     
-rw-rw-r-- 1 portage portage    14913 Jul 24 06:29 /mnt/ftp/distfiles/binutils-2.20.1-patches-1.1.tar.bz2                                                                                   
-rw-rw-r-- 1 portage portage 17501436 Jul 24 06:29 /mnt/ftp/distfiles/binutils-2.20.1.tar.bz2
-rw-rw-r-- 1 portage portage 17506655 Feb 16  2010 /mnt/ftp/distfiles/binutils-2.20.tar.bz2
-rw-rw-r-- 1 root    portage  1080319 Nov 12  2009 /mnt/ftp/distfiles/bison-2.3.tar.bz2
-rw-rw-r-- 1 portage portage  1467784 Feb 16  2010 /mnt/ftp/distfiles/bison-2.4.1.tar.bz2
-rw-rw-r-- 1 portage portage  1616117 Jul 24 03:25 /mnt/ftp/distfiles/bison-2.4.2.tar.bz2
-rw-rw-r-- 1 portage portage  1652612 Aug 20 02:53 /mnt/ftp/distfiles/bison-2.4.3.tar.bz2
-rw-rw-r-- 1 root    root      129364 Nov 23  2009 /mnt/ftp/distfiles/bitmap-1.0.3.tar.bz2
-rw-rw-r-- 1 root    root      140565 Jan 18  2010 /mnt/ftp/distfiles/bitmap-1.0.4.tar.bz2
-rw-rw-r-- 1 portage portage   998208 Jan 20  2010 /mnt/ftp/distfiles/bluez-4.39.tar.gz
-rw-rw-r-- 1 portage portage   997733 Jul 25 06:30 /mnt/ftp/distfiles/bluez-4.69.tar.gz
-rw-rw-r-- 1 root    portage     5537 Nov 13  2009 /mnt/ftp/distfiles/boost-patches-1.35.0-5.tbz2                                                                                           
-rw-rw-r-- 1 root    portage 23416747 Nov 13  2009 /mnt/ftp/distfiles/boost_1_35_0.tar.bz2
-rw-rw-r-- 1 portage portage 33348161 Jan 30  2010 /mnt/ftp/distfiles/boost_1_41_0.tar.bz2
-rw-rw-r-- 1 portage portage 33426755 Jul 25 06:11 /mnt/ftp/distfiles/boost_1_42_0.tar.bz2
-rw-rw-r-- 1 root    root       32261 Nov 12  2009 /mnt/ftp/distfiles/bridge-utils-1.2.tar.gz
-rw-rw-r-- 1 root    portage    32657 Nov 23  2009 /mnt/ftp/distfiles/bridge-utils-1.4.tar.gz
-rw-rw-r-- 1 portage portage   202405 Aug 20 17:06 /mnt/ftp/distfiles/bsddb3-5.0.0.tar.gz
-rw-rw-r-- 1 portage portage   118119 Jul 29 13:26 /mnt/ftp/distfiles/btrfs-progs-0.19.tar.bz2
-rw-rw-r-- 1 portage portage  2466883 Feb 17  2010 /mnt/ftp/distfiles/bugzilla-3.4.3.tar.gz
-rw-rw-r-- 1 root    root        3094 Aug 20  2008 /mnt/ftp/distfiles/build-docbook-catalog-1.2.bz2                                                                                         
-rw-rw-r-- 1 portage portage     3049 Jul 25 05:44 /mnt/ftp/distfiles/build-docbook-catalog-1.5.bz2                                                                                         
-rw-rw-r-- 1 root    portage  2199685 Nov 15  2009 /mnt/ftp/distfiles/busybox-1.14.2.tar.bz2
-rw-rw-r-- 1 portage portage  1987727 Feb 17  2010 /mnt/ftp/distfiles/busybox-1.15.3.tar.bz2
-rw-rw-r-- 1 portage portage  2007183 Jul 24 10:15 /mnt/ftp/distfiles/busybox-1.16.0.tar.bz2
-rw-rw-r-- 1 portage portage  2091108 Aug 20 02:53 /mnt/ftp/distfiles/busybox-1.17.1.tar.bz2
-rw-rw-r-- 1 root    root     1765399 Nov 13  2009 /mnt/ftp/distfiles/busybox-1.8.2.tar.bz2
-rw-rw-r-- 1 root    portage   841402 Aug 20  2008 /mnt/ftp/distfiles/bzip2-1.0.5.tar.gz


sorry about that~

Oh, think I've got you now. No I don't.

Code:

idella@genny /mnt/fedora/store $ ls -ls /usr/portage/sys-kernel/gentoo-sources/     
total 200
144 -rw-r--r-- 1 root root 145263 Oct 27 03:37 ChangeLog
 12 -rw-r--r-- 1 root root   9466 Oct 27 08:07 Manifest
  4 -rw-r--r-- 1 root root   1251 Feb 22  2010 gentoo-sources-2.6.16-r13.ebuild
  4 -rw-r--r-- 1 root root    773 Oct 24 22:37 gentoo-sources-2.6.32-r20.ebuild
  4 -rw-r--r-- 1 root root    771 Jul 18 22:07 gentoo-sources-2.6.33-r2.ebuild
  4 -rw-r--r-- 1 root root    780 Aug 10 07:34 gentoo-sources-2.6.33-r3.ebuild
  4 -rw-r--r-- 1 root root    769 Aug 12 20:21 gentoo-sources-2.6.34-r1.ebuild
  4 -rw-r--r-- 1 root root    776 Oct 17 02:07 gentoo-sources-2.6.34-r11.ebuild
  4 -rw-r--r-- 1 root root    773 Oct 24 23:37 gentoo-sources-2.6.34-r12.ebuild
  4 -rw-r--r-- 1 root root    772 Aug 28 23:07 gentoo-sources-2.6.34-r6.ebuild
  4 -rw-r--r-- 1 root root    782 Oct 20 06:40 gentoo-sources-2.6.35-r11.ebuild
  4 -rw-r--r-- 1 root root    777 Oct 22 01:37 gentoo-sources-2.6.36.ebuild
  4 -rw-r--r-- 1 root root    361 Apr 26  2010 metadata.xml


./files loses me entirely. was looking for /usr/portage/sys-kernel/gentoo-sources/files, but no. The above example points out two things,

many /usr/portage sub-directories have no more sub-directories, and some do,
Currently IF I wanted to re-acquire kernel 2.6.30 I need retrieve it from gen2.img since it's been retired from the portage tree.

Anyway I think this point is trivial. It does appear that the distfiles folder contains as I described one level of package files.
I think you are referring to some other files related to the ebuild that are required for emerge to effectively install a selected package.
That's not the issue because portage in the gentoo systems is intact. The issue is distfiles as it was located in the non system partition /mnt/gentoo named to reflect its content. My systems are names /mnt/genny within the 64 system and /mnt/gentoo64 within genny, which is what I am currently in.
So, I think this is where I am at.

The packages files in distfiles may be able to be copied. The question is how.
Using hexedit one file at a time id really quite a silly thing to do for this volume of data.
While the btrfs is corrupted, it is in fact usable in a very limited way. After several attempts, I have in fact copied a handful of files from gen2.img.
They include /mnt/ftp/stage3-amd64-20091231.tar.bz2 and a few of the packages in distfiles.
So the structure of metadata is compromised but is intact for a large number of files.
Generally when mounting it in e.g. /mnt/ftp, it quickly does a hang.

I have wondered about using dd on it directly. If it does go wrong it does a hang which is fairly non destructive.
What do you think of a simple bash script that uses a loop to copy each sequential file listed in distfiles using dd and copying it to the same name of the selected file; a simple for loop. I've not written such a bash script before but that's a fairly simple exercise and belongs right here in portage & programming. You'd need a variable to name each selected file and use that variable to name the destination file. The worst it can do is pull a hang.
Each time it pulls up, can adjust the starting point to where it left off and keep running it until it gets to the end. It will copy some, just a question aof how many it can capture.

Quote:

in many cases it will make things worse, not better, which is why you need an image before you run fsck on any filesystem


well that's exactly what I have in gen2.img. btrfsck doesn't repair or ruin it.
Months ago I told you about my freshly updated /mnt/genny being trashed. It was in reiserfs. reisrfsck turned the system into hundreds of files and folders saved under lost&found, so I can follow you re fsck.

Quote:

which is why you need an image before you run fsck on any filesystem


That is interesting. I would have thought fsck was the first port of call. However what you say make sense considering what reiserfsck did to genny.
That stated, that leaves an alarming prospect to any file corruption. I thought fsck was the fixit tool. If not fsck, does that mean any linux file system can't truly be fixed from a form of file corruption? Do you really need a form a intermittent full system back to a separated drive or partition to fall back to a previous healthy state?
_________________
idella4@aus
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54424
Location: 56N 3W

PostPosted: Sat Nov 06, 2010 8:59 pm    Post subject: Reply with quote

idella4,

idella4 wrote:
Could you just explain the ./files beside the ebuild? Just don't follow. The ebuld is in /usr/portage/<package-sub-dir>/

Large files that contribute to a package are downloaded to /usr/portage/distfiles. Small patches applied by the ebuild are usually distributed with the portage tree and can be found in /usr/portage/<category>/<package>/files. e.g. /usr/portage/x11-drivers/nvidia-drivers/files/ holds a number of patches for nvidia drivers. These files are as much a part of the sources as the files in /usr/portage/distfiles

gentoo-sources is a bad example. Its patches are usually provided in two files in distfiles.

Your loop approach is only as good as the metadata that describes the files. Nobody knows how good that is.

[quote"idella4"]does that mean any linux file system can't truly be fixed from a form of file corruption?[/quote]It applies to all filesystems not only linux.
What fsck does for you depends on the damage. Its a matter of luck. Yes, the only secure way of recovering from filesystem damage is a validated backup.
The validated bit is very important.
How you backup depends on your system use. Monthly full backups, weekly incremental backup and maybe daily incremental backups too.
Exactly what constitutes 'full' depends on how fast you need your system back. Full may just mean user data as everything else can be rebuilt on Gentoo.

If you really want old distfiles back, it can be arranged but depending on how old they are, it may be a long process.
Firstly ask on the forums, I never flush my distfiles :)
If nobody here has the files, file an bug against infra asking for the files you need.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
idella4
Retired Dev
Retired Dev


Joined: 09 Jun 2006
Posts: 1600
Location: Australia, Perth

PostPosted: Sun Nov 07, 2010 1:52 am    Post subject: Reply with quote

Neddy wrote
Quote:

Large files that contribute to a package are downloaded to /usr/portage/distfiles. Small patches applied by the ebuild are usually distributed with the portage tree and can be found in /usr/portage/<category>/<package>/files. e.g. /usr/portage/x11-drivers/nvidia-drivers/files/ holds a number of patches for nvidia drivers. These files are as much a part of the sources as the files in /usr/portage/distfiles

yes, roger that.

I wrote
Quote:

I think you are referring to some other files related to the ebuild that are required for emerge to effectively install a selected package.
That's not the issue because portage in the gentoo systems is intact. The issue is distfiles as it was located in the non system partition /mnt/gentoo named to reflect its content.

Neddy wrote
Quote:

Your loop approach is only as good as the metadata that describes the files. Nobody knows how good that is.

Yes, well quite right. I was thinking if I get most of them back that's a fair result. From all we've discussed, it's pretty clear a full retrieval is not feasible short of sending gen2.img to the btrfs devs to repair the metadata.

Neddy said
Quote:

If you really want old distfiles back, it can be arranged but depending on how old they are, it may be a long process

Well you pick your battles, don't you.
I picked xen and libvirt and made lots of headway over months.
This one appears to have run its course over a few days.
You could say the corruption was a disguised blessing since it finally purged huge volumes of old redundant packages and kernels.
The kernels listed I have already played with and recompiled and tested and experimented and have [likely] finished with.
For now I'm finished using xen having exhausted the exercises and challenges I found with them.
Gentoo kernels 2.6.30 & 31 & 34 are now old kernels.
I would prefer my distfiles folder back, but in the light of the above it's not really very logical.
I'd like it back more out of the principal of objecting to data loss that I didn't choose to let go.
I just can't see the point in re-acquiring it the long hard way when I don't even need it.
I was extremely put out losing the suseimg.tar.bz2 out of that principal, not because I needed it or was using it.

edit:

ok Neddy, I am in business. I could have done this from the very beginning. It crossed my mind but I never got my self organised to actually do it.

Code:
 
idella@genny /mnt/fedora/store $ sudo dd if=/mnt/ftp/distfiles/30375-akode-2.0.2.tar.bz2 of=/mnt/gentoo/distfiles/4.3-klipper_empty_actions.patch.bz2

idella@genny /mnt/fedora/store $ ls -l /mnt/ftp/distfiles/[2-4]*
-rw-rw-r-- 1 portage portage 363054 Jan 30  2010 /mnt/ftp/distfiles/2.0.10.tar.bz2
-rw-rw-r-- 1 portage portage 367303 Jul 25 06:27 /mnt/ftp/distfiles/2.0.14.tar.bz2
-rw-rw-r-- 1 root    portage 357732 Nov 13  2009 /mnt/ftp/distfiles/2.0.5.tar.bz2
-rw-rw-r-- 1 root    root    472605 Aug 25  2008 /mnt/ftp/distfiles/30375-akode-2.0.2.tar.bz2
-rw-rw-r-- 1 portage portage  10010 Jan 21  2010 /mnt/ftp/distfiles/4.3-klipper_empty_actions.patch.bz2                                                                                     
idella@genny /mnt/fedora/store $ ls -l /mnt/gentoo/distfiles/total 2060
-rw-r--r-- 1 root    portage 363054 Nov  7 22:37 2.0.10.tar.bz2
-rw-r--r-- 1 root    portage 367303 Nov  7 22:38 2.0.14.tar.bz2
-rw-r--r-- 1 root    portage 357732 Nov  7 22:39 2.0.5.tar.bz2
-rw-r--r-- 1 root    portage 472605 Nov  7 22:46 30375-akode-2.0.2.tar.bz2
-rw-r--r-- 1 root    portage 472605 Nov  7 22:48 4.3-klipper_empty_actions.patch.bz2
-rw-rw-r-- 1 portage portage  62581 Nov  5 10:21 ddrescue-1.12.tar.gz
-rw-rw-r-- 1 root    portage      0 Nov  5 11:13 zip232.tar.gz


According to my bash scrollback settings I have only about 5,950 more lines to go. Hence the idea of the loop in a bash script.
Speaking of scripts, I bet this could be done in any scripting language; python, perl, ruby.
Comments, and not restricted to just Neddy. This is programming so this is for all who peruse.
_________________
idella4@aus
Back to top
View user's profile Send private message
idella4
Retired Dev
Retired Dev


Joined: 09 Jun 2006
Posts: 1600
Location: Australia, Perth

PostPosted: Sun Nov 07, 2010 7:24 am    Post subject: Reply with quote

bump. This thread has just taken a turn.

ok Neddy, I am in business. I could have done this from the very beginning. It crossed my mind but I never got my self organised to actually do it.


Code:

idella@genny /mnt/fedora/store $ sudo dd if=/mnt/ftp/distfiles/30375-akode-2.0.2.tar.bz2 of=/mnt/gentoo/distfiles/4.3-klipper_empty_actions.patch.bz2

idella@genny /mnt/fedora/store $ ls -l /mnt/ftp/distfiles/[2-4]*
-rw-rw-r-- 1 portage portage 363054 Jan 30  2010 /mnt/ftp/distfiles/2.0.10.tar.bz2
-rw-rw-r-- 1 portage portage 367303 Jul 25 06:27 /mnt/ftp/distfiles/2.0.14.tar.bz2
-rw-rw-r-- 1 root    portage 357732 Nov 13  2009 /mnt/ftp/distfiles/2.0.5.tar.bz2
-rw-rw-r-- 1 root    root    472605 Aug 25  2008 /mnt/ftp/distfiles/30375-akode-2.0.2.tar.bz2
-rw-rw-r-- 1 portage portage  10010 Jan 21  2010 /mnt/ftp/distfiles/4.3-klipper_empty_actions.patch.bz2                                                                                     
idella@genny /mnt/fedora/store $ ls -l /mnt/gentoo/distfiles/total 2060
-rw-r--r-- 1 root    portage 363054 Nov  7 22:37 2.0.10.tar.bz2
-rw-r--r-- 1 root    portage 367303 Nov  7 22:38 2.0.14.tar.bz2
-rw-r--r-- 1 root    portage 357732 Nov  7 22:39 2.0.5.tar.bz2
-rw-r--r-- 1 root    portage 472605 Nov  7 22:46 30375-akode-2.0.2.tar.bz2
-rw-r--r-- 1 root    portage 472605 Nov  7 22:48 4.3-klipper_empty_actions.patch.bz2
-rw-rw-r-- 1 portage portage  62581 Nov  5 10:21 ddrescue-1.12.tar.gz
-rw-rw-r-- 1 root    portage      0 Nov  5 11:13 zip232.tar.gz


According to my bash scrollback settings I have only about 5,950 more lines to go. Hence the idea of the loop in a bash script.
Speaking of scripts, I bet this could be done in any scripting language; python, perl, ruby.
Comments, and not restricted to just Neddy. This is programming so this is for all who peruse.

Now the "algorithm' does have a glitch. To succeed in the dd copy, it actually takes

Code:

idella@genny /mnt/fedora/store $ sudo dd if=/mnt/ftp/distfiles/Archive-Tar-1.40.tar.gz of=/mnt/gentoo/distfiles/Archive-Tar-1.40.tar.gz
^Z
[6]+  Stopped                 sudo dd if=/mnt/ftp/distfiles/Archive-Tar-1.40.tar.gz of=/mnt/gentoo/distfiles/Archive-Tar-1.40.tar.gz
idella@genny /mnt/fedora/store $ sudo dd if=/mnt/ftp/distfiles/Archive-Tar-1.40.tar.gz of=/mnt/gentoo/distfiles/Archive-Tar-1.40.tar.gz
94+1 records in
94+1 records out
48243 bytes (48 kB) copied, 0.0004454 s, 108 MB/s
idella@genny /mnt/fedora/store $ ls -l /mnt/gentoo/distfiles/total 2172
-rw-r--r-- 1 root    portage 363054 Nov  7 22:37 2.0.10.tar.bz2
-rw-r--r-- 1 root    portage 367303 Nov  7 22:38 2.0.14.tar.bz2
-rw-r--r-- 1 root    portage 357732 Nov  7 22:39 2.0.5.tar.bz2
-rw-r--r-- 1 root    portage 472605 Nov  7 22:46 30375-akode-2.0.2.tar.bz2
-rw-r--r-- 1 root    portage 472605 Nov  7 22:48 4.3-klipper_empty_actions.patch.bz2
-rw-r--r-- 1 root    portage  63521 Nov  7 23:09 AppConfig-1.66.tar.gz
-rw-r--r-- 1 root    portage  48243 Nov  7 23:13 Archive-Tar-1.40.tar.gz


That is; [dd if=sorce-file of=destination-file]; Contol Z; [dd if=sorce-file of=destination-file]
So it does a hang on the first dd use. Do control Z to interrupt, and do it again and it succeeds.
So who know what is occurring, it succeeds on the 2nd invokation of dd.
like so

Code:

idella@genny /mnt/fedora/store $ sudo dd if=/mnt/ftp/distfiles/Archive-Tar-1.54.tar.gz of=/mnt/gentoo/distfiles/Archive-Tar-1.54.tar.gz
^Z
[7]+  Stopped                 sudo dd if=/mnt/ftp/distfiles/Archive-Tar-1.54.tar.gz of=/mnt/gentoo/distfiles/Archive-Tar-1.54.tar.gz
idella@genny /mnt/fedora/store $ ls -l /mnt/gentoo/distfiles/A*
-rw-r--r-- 1 root portage 63521 Nov  7 23:09 /mnt/gentoo/distfiles/AppConfig-1.66.tar.gz
-rw-r--r-- 1 root portage 48243 Nov  7 23:13 /mnt/gentoo/distfiles/Archive-Tar-1.40.tar.gz
-rw-r--r-- 1 root portage     0 Nov  7 23:30 /mnt/gentoo/distfiles/Archive-Tar-1.54.tar.gz
idella@genny /mnt/fedora/store $ sudo dd if=/mnt/ftp/distfiles/Archive-Tar-1.54.tar.gz of=/mnt/gentoo/distfiles/Archive-Tar-1.54.tar.gz
101+1 records in
101+1 records out
51966 bytes (52 kB) copied, 0.000872709 s, 59.5 MB/s


Note the first attempt creates the empty destination file of the same source name.
The second attempt [for whatever reason] succeeds. The listing of the destination file lists the file fully copied.

I have not studied bash scripting per se. If anything I should probably consider writing it in C.
It was the unit "Unix and C" that introduced me to linux [7] years back. The unit used a basic bash shell in which we wrote and ran our C program.
I've not touched it since then. I would need to revise C from scratch.
This is easy. C can call basic linux commands.
First is needed a text variable to represent source selected source file; e.g. selected_file
A text variable [or parameter] e.g. source_file to represent each sequential file in /mnt/ftp/distfiles/
A text variable [or parameter] e.g. dest_file to represent each copied file in /mnt/gentoo/distfiles/
The content of dd_file will change on each increment.

A basic loop with content
{
source_file = dest_file = selected_file; [The selected sequential file name is passed onto both source_file & dest_file]
dd if=/mnt/ftp/source_file of=/mnt/gentoo/dest_file;
code for Control Z;
dd if=/mnt/ftp/source_file of=/mnt/gentoo/dest_file;
}
until loop meets exit state.
done

The coupling of the dd named file probably isn't required. If it's just s string, then one dd_file should suffice.

{
dd_file = selected_file; [The selected sequential file name is passed onto dd_file]
dd if=/mnt/ftp/dd_file of=/mnt/gentoo/dd_file;
code for Control Z;
dd if=/mnt/ftp/dd_file of=/mnt/gentoo/dd_file;
}
until loop meets exit state.
done

How hard is that?
This is the programming forum. Any takers???
_________________
idella4@aus


Last edited by idella4 on Sun Nov 07, 2010 8:23 am; edited 2 times in total
Back to top
View user's profile Send private message
avendesora
Veteran
Veteran


Joined: 16 Aug 2002
Posts: 1739
Location: Betelgeuse vicinity

PostPosted: Sun Nov 07, 2010 7:35 am    Post subject: Reply with quote

Hello,
Using dd to copy complete files is a bit strange. 'cp' is the more usual tool, or tar.
Have tried the usual tar pipe tar thing?
Code:
cd /mnt/ftp/distfiles
tar cf - . | (cd /mnt/where/you/want/them; tar xvf -)

If you know it's going to fail, you could try the --ignore-failed-read option (to the first tar). Not sure if that option works with real i/o errors.

Other option maybe:
Code:
cp -a /mnt/ftp/distfiles /mnt/other

Or if you've already done some copying:
Code:

export TARGET=/where/ever
cd /mnt/ftp/distfiles
for i in *; do
  if [ ! -f $TARGET/$i ] ; do
    cp $i $TARGET/$i
  done
done

You can put some error handling in that one too. (Like listing the files that failed to copy.)

Obviously none of this will un-corrupt corrupted files. But the hashes portage maintains will detect those if you try to emerge the corresponding package.
Back to top
View user's profile Send private message
idella4
Retired Dev
Retired Dev


Joined: 09 Jun 2006
Posts: 1600
Location: Australia, Perth

PostPosted: Sun Nov 07, 2010 7:57 am    Post subject: Reply with quote

avendesora,

ok thanks. You posted while I was editing and adding the loop structure.

Re-read all the post.
This is a broken btrfs. How broken, very or only just can't tell. What I can tell is the following;

I have tried cp and tar. They don't work. As I said, it results in a hang.
After days of experimenting I've just discovered dd works as described.
Now it somehow gets out of jail. Using cp and tar, Control z fails. It's stuck and you cannot escape or unmount gen2.img.
Have to reboot to liberate the mounting of gen2.img

Code:

export TARGET=/where/ever
cd /mnt/ftp/distfiles
for i in *; do
  if [ ! -f $TARGET/$i ] ; do
    cp $i $TARGET/$i
  done
done


Well that's more or less it. Unfortunately all my entry for the loop content was not in place when you posted.
Can you adjust the above to using dd? As I posted, you need a variable for source and destination files for dd.
Then you need to call control Z. and repeat the dd line. then done.
_________________
idella4@aus
Back to top
View user's profile Send private message
avendesora
Veteran
Veteran


Joined: 16 Aug 2002
Posts: 1739
Location: Betelgeuse vicinity

PostPosted: Sun Nov 07, 2010 8:18 am    Post subject: Reply with quote

All the variables are there.

Frankly, that ^Z does not make any sens. Plus, when are you killing those stopped dd's? Are they dying when you ^Z them, or when you bring them back from stopped state? Does it work if you ^C rather than ^Z? What do you have in dmesg when the process hangs?

BIG WARNING: the following, untested, will leave a stopped (^Z'ed) dd for each copied file.

Code:
export TARGET=/where/ever
cd /mnt/ftp/distfiles
for i in *; do
  if [ ! -f $TARGET/$i ] ; do
    dd if=$i of=$TARGET/$i &
    kill -STOP $!
    dd if=$i of=$TARGET/$i
  done
done
Back to top
View user's profile Send private message
idella4
Retired Dev
Retired Dev


Joined: 09 Jun 2006
Posts: 1600
Location: Australia, Perth

PostPosted: Sun Nov 07, 2010 8:45 am    Post subject: Reply with quote

avendesora,

that's it, very good.

Quote:

Frankly, that ^Z does not make any sens.

fair enough, I'm just going with the flow. Sure it doesn't make sense, but that is what is happening.
Quote:

Does it work if you ^C rather than ^Z?

No.

Code:

idella@genny /mnt/fedora/store $ sudo dd if=/mnt/ftp/distfiles/Archive-Tar-1.60.tar.gz of=/mnt/gentoo/distfiles/Archive-Tar-1.60.tar.gz
Password:
^C^Z
[8]+  Stopped                sudo dd if=/mnt/ftp/distfiles/Archive-Tar-1.60.tar.gz of=/mnt/gentoo/distfiles/Archive-Tar-1.60.tar.gz
idella@genny /mnt/fedora/store $ ls -l /mnt/gentoo/distfiles/A*
-rw-r--r-- 1 root portage 63521 Nov  7 23:09 /mnt/gentoo/distfiles/AppConfig-1.66.tar.gz
-rw-r--r-- 1 root portage 48243 Nov  7 23:13 /mnt/gentoo/distfiles/Archive-Tar-1.40.tar.gz
-rw-r--r-- 1 root portage 51966 Nov  7 23:31 /mnt/gentoo/distfiles/Archive-Tar-1.54.tar.gz
-rw-r--r-- 1 root portage     0 Nov  8 00:28 /mnt/gentoo/distfiles/Archive-Tar-1.60.tar.gz

You can see I called control C which didn't work, then control Z which did. Then see it has created the empty dest file.

Code:

idella@genny /mnt/fedora/store $ sudo dd if=/mnt/ftp/distfiles/Archive-Tar-1.60.tar.gz of=/mnt/gentoo/distfiles/Archive-Tar-1.60.tar.gz
103+1 records in
103+1 records out
52988 bytes (53 kB) copied, 0.000880025 s, 60.2 MB/s


Never mind about the why. Remember this is a compromised btrfs system on which only dd has the desired outcome.
Quote:

What do you have in dmesg when the process hangs?

Code:

idella@genny /mnt/fedora/store $ sudo dd if=/mnt/ftp/distfiles/Archive-Tar-1.66.tar.gz of=/mnt/gentoo/distfiles/Archive-Tar-1.66.tar.gz
^Z
[10]+  Stopped                 sudo dd if=/mnt/ftp/distfiles/Archive-Tar-1.66.tar.gz of=/mnt/gentoo/distfiles/Archive-Tar-1.66.tar.gz
idella@genny /mnt/fedora/store $ sudo tail /var/log/messages
Nov  8 00:38:01 genny kernel: [ 9144.616089] parent transid verify failed on 41647026176 wanted 10501 found 10514
Nov  8 00:38:01 genny kernel: [ 9144.616126] parent transid verify failed on 41647026176 wanted 10501 found 10514
Nov  8 00:38:01 genny kernel: [ 9144.616162] parent transid verify failed on 41647026176 wanted 10501 found 10514
Nov  8 00:38:01 genny kernel: [ 9144.616199] parent transid verify failed on 41647026176 wanted 10501 found 10514
Nov  8 00:38:01 genny kernel: [ 9144.616235] parent transid verify failed on 41647026176 wanted 10501 found 10514
Nov  8 00:38:01 genny kernel: [ 9144.616271] parent transid verify failed on 41647026176 wanted 10501 found 10514
Nov  8 00:38:01 genny kernel: [ 9144.616308] parent transid verify failed on 41647026176 wanted 10501 found 10514
Nov  8 00:38:01 genny kernel: [ 9144.616344] parent transid verify failed on 41647026176 wanted 10501 found 10514
Nov  8 00:38:05 genny sudo:   idella : TTY=pts/3 ; PWD=/mnt/fedora/store ; USER=root ; COMMAND=/bin/tail /var/log/messages
Nov  8 00:38:05 genny sudo: pam_unix(sudo:session): session opened for user root by idella(uid=0)

idella@genny /mnt/fedora/store $ sudo dd if=/mnt/ftp/distfiles/Archive-Tar-1.66.tar.gz of=/mnt/gentoo/distfiles/Archive-Tar-1.66.tar.gz
106+1 records in
106+1 records out
54332 bytes (54 kB) copied, 0.000802945 s, 67.7 MB/s

idella@genny /mnt/fedora/store $ sudo tail /var/log/messages
Nov  8 00:38:06 genny kernel: [ 9149.617166] parent transid verify failed on 41647026176 wanted 10501 found 10514
Nov  8 00:38:06 genny kernel: [ 9149.617203] parent transid verify failed on 41647026176 wanted 10501 found 10514
Nov  8 00:38:06 genny kernel: [ 9149.617239] parent transid verify failed on 41647026176 wanted 10501 found 10514
Nov  8 00:38:06 genny kernel: [ 9149.617275] parent transid verify failed on 41647026176 wanted 10501 found 10514
Nov  8 00:38:06 genny kernel: [ 9149.617311] parent transid verify failed on 41647026176 wanted 10501 found 10514
Nov  8 00:38:06 genny kernel: [ 9149.617348] parent transid verify failed on 41647026176 wanted 10501 found 10514
Nov  8 00:38:08 genny sudo:   idella : TTY=pts/3 ; PWD=/mnt/fedora/store ; USER=root ; COMMAND=/bin/dd if=/mnt/ftp/distfiles/Archive-Tar-1.66.tar.gz of=/mnt/gentoo/distfiles/Archive-Tar-1.66.tar.gz
Nov  8 00:38:08 genny sudo: pam_unix(sudo:session): session opened for user root by idella(uid=0)
Nov  8 00:38:10 genny sudo:   idella : TTY=pts/3 ; PWD=/mnt/fedora/store ; USER=root ; COMMAND=/bin/tail /var/log/messages
Nov  8 00:38:10 genny sudo: pam_unix(sudo:session): session opened for user root by idella(uid=0)

_________________
idella4@aus
Back to top
View user's profile Send private message
idella4
Retired Dev
Retired Dev


Joined: 09 Jun 2006
Posts: 1600
Location: Australia, Perth

PostPosted: Sun Nov 07, 2010 9:17 am    Post subject: Reply with quote

avendesora,

almost there.

ok; I have made /mnt/fedora/store/gen2.img read only as Neddy suggested.
I have made a test folder at /mnt/gentoo/distfiles/ to give the destination location a clean empty folder and doesn't
have to compete with already present files.

Code:

idella@genny ~/bin $ sudo nano ./copy.sh
..............

export TARGET=/mnt/gentoo/test
cd /mnt/ftp/distfiles
for i in *; do                                   for all file content in current directory; do
  if [ ! -f $TARGET/$i ] ; do                    if file $i doesn't exist in target folder; do
    dd if=$i of=$TARGET/$i &                     dd of source and destination file and
    kill -STOP $!                                do a control Z of $!
    dd if=$i of=$TARGET/$i                       repeat dd line
  done                                           done
done                                             done
^C

idella@genny ~/bin $ sudo ./copy.sh
./copy.sh: line 4: syntax error near unexpected token `do'
./copy.sh: line 4: `  if [ ! -f $TARGET/$i ] ; do'


A simple bash syntax error. I'm relying on you. I can check on some similar code in some startup scripts to compare.
It doesn't get started so hasn't tested the dd lines.
It looks ok to me and since you knocked it up quickly it makes me think it's a basic beginner level tested loop structure,
however.

ok, one little adjustment and some very good progress
Code:

idella@genny ~/bin $ sudo nano ./copy.sh
export TARGET=/mnt/gentoo/test
cd /mnt/ftp/distfiles
for i in ./*; do
#  if [ ! -f $TARGET/$i ] : do
    dd if=$i of=$TARGET/$i &
    kill -STOP $!
    dd if=$i of=$TARGET/$i
  done

There is one little syntax error in if [ ! -f $TARGET/$i ] ; do. So for the sake of removing the checking of its presence in $TARGET,
the script effectively copied the content of /mnt/ftp/[1-3]* & [A-Z]*

It got up to
Code:

idella@genny ~/bin $ ls -ld /mnt/gentoo/test/audiofile-0.2.7.tar.gz
-rw-r--r-- 1 root root 502448 Nov  8 01:38 /mnt/gentoo/test/audiofile-0.2.7.tar.gz
idella@genny ~/bin $ ls -ld /mnt/gentoo/test/audit-1.7.4.tar.gz
-rw-r--r-- 1 root root 0 Nov  8 01:38 /mnt/gentoo/test/audit-1.7.4.tar.gz


So file audit-1.7.4.tar.gz posed an extra problem, which was expected.
So how do I adjust it to carry on from there. I'd say pass over the problem file audit-1.7.4.tar.gz.
All that's need is to echo i to the console so as to see what number i is at file audit-1.7.4.tar.gz, then edit the script to start at the next number file.
easy
_________________
idella4@aus
Back to top
View user's profile Send private message
avendesora
Veteran
Veteran


Joined: 16 Aug 2002
Posts: 1739
Location: Betelgeuse vicinity

PostPosted: Sun Nov 07, 2010 10:03 am    Post subject: Reply with quote

Sorry for the syntax. The correct if syntax would be:
Code:
if [ -f $TARGET/$i ]; then
...
fi

With that test, you can just restart the script and it will skip all files that already exist in the target.
If you want to skip a file, just create an empty file with the same name in the target before running the script.

To get some status, just echo stuff:
Code:
export TARGET=/where/ever
cd /mnt/ftp/distfiles
for i in *; do
  if [ ! -f $TARGET/$i ] ; then
    echo "dd'ing $i"
    dd if=$i of=$TARGET/$i &
    kill -STOP $!
    dd if=$i of=$TARGET/$i
  else
    echo "skipping $i"
  fi
done


Edit: $i is not a number, it's a file name. The test of the existence of $i in target will do the restart "where it left at".
BTW, this script would not work properly if some file names had spaces in them. Plenty of ways to handle that, but it's unnecessary here.
Back to top
View user's profile Send private message
idella4
Retired Dev
Retired Dev


Joined: 09 Jun 2006
Posts: 1600
Location: Australia, Perth

PostPosted: Sun Nov 07, 2010 10:51 am    Post subject: Reply with quote

avendesora,

very good. tx for the script, it does work
What doesn't work is the btrfs where it is broken. I've got up to

Code:

./firefox-3.6.6.source.tar.bz2


and have clearly hit a snag, in the btrfs structure. Restarting the script picks up where it left off which is good.

Code:

skipping kdegames-4.4.5.tar.bz2
skipping kdegraphics-3.5.9.tar.bz2
skipping kdegraphics-4.3.1.tar.bz2
skipping kdegraphics-4.3.3.tar.bz2
dd'ing kdegraphics-4.3.4.tar.bz2
7074+1 records in
7074+1 records out
3621926 bytes (3.6 MB) copied, 0.0747507 s, 48.5 MB/s
dd'ing kdegraphics-4.4.5.tar.bz2



Nursing it along. I effectively copies out several dozen mb worth of files, then it does this. If I remove that last file that it is stopped at then re-run the script, it manages to copy the file. I appears that the large volume of copying is taxing the underlying systems memory management such as caches or whatever. I suspected that there would be some files that wouldn't copy due to the btrfs errors. That may yet be the case.
Currently there are a handful of files that haven't copied which I shall later track and re-attempt.
A reboot clearly clears the systems memory caches and such and running the script again recommences copying, then it pulls up after less than a minute.
The btrfs faults is having an impact somewhere. On stopping the script the gen2.img cannot be unmounted. Have to reboot to overcome it.

A few more reboots should see it complete.
_________________
idella4@aus
Back to top
View user's profile Send private message
idella4
Retired Dev
Retired Dev


Joined: 09 Jun 2006
Posts: 1600
Location: Australia, Perth

PostPosted: Sun Nov 07, 2010 2:13 pm    Post subject: Reply with quote

bump.
I suspect avendesora has left the building for now.
That's good. Finally completed the distfiles folder. The next step is to tackle a kernel.
This is not critical since a kernel can be re-emerged except that these kernels are mostly retired from the current portage tree.

To tackle a kernel I need one adjustment to the script. I need an equivalent script for directories.
In the uppermost directory of the kernel

export TARGET=//mnt/gentoo/linux-2.6.30-gentoo-r8
cd /mnt/ftp/linux-2.6.30-gentoo-r8
for [a folder] in ./*; do
if [ ! -folder $TARGET/$i ] ; then

I am only guessing intuitively. Trying

Code:

export TARGET=/mnt/gentoo/linux-2.6.30-gentoo-r8
cd /mnt/ftp/linux-2.6.30-gentoo-r8
for dir in ./; do
if [ ! -d $TARGET/dir ] ; then
    mkdir dir &
    kill -STOP $! &
    mkdir dir
  else
    echo "skipping dir"
  fi
done


It's not quire right. I'm still reading but someone like
_________________
idella4@aus


Last edited by idella4 on Sun Nov 07, 2010 3:02 pm; edited 1 time in total
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54424
Location: 56N 3W

PostPosted: Sun Nov 07, 2010 2:52 pm    Post subject: Reply with quote

idella4,

The script depends on the (broken) btrfs file system to find the blocks for dd to copy.
If file system errors ask dd to do something it can't do, it will stop with an error.
dd can take various action in the face of an error, none of which will recover the data, however it will keep going
man dd:
       noerror
              continue after read errors
might help get to the end but you will have some broken files
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
avendesora
Veteran
Veteran


Joined: 16 Aug 2002
Posts: 1739
Location: Betelgeuse vicinity

PostPosted: Sun Nov 07, 2010 3:03 pm    Post subject: Reply with quote

idella4: Real Bad Idea (tm).

Your ^Z'ed dd approach is only livable (barely) for a reasonable number of files since it creates an essentially dead process per file. The kernel source has thousands (>30k) of files - you might very well kill your system. Keep in mind that having a bunch of processes failing on I/O is generally something to avoid - you might hit weird bugs in other parts of the system leading to hard locks and such, which could be damaging to your other (valid) data.
Plus if any of the files necessary to build your kernel is damaged, all your efforts are wasted. (Added bonus: you might not see the damage, and the stuff might compile... booting that is mayhem - how good are your offline backups?)

Either:
- you managed to read the kernel tarballs, and they are not corrupt, in which case you're done (except for the config which you should try to recover separately if they are somewhere on that image).
Or:
- you don't have those, or they are corrupt, in which case you need to download them again (google will very likely find all the ones you're missing).

If you really want to try the wacky dd thing with a whole kernel tree, you'll have to do it yourself.
Hints: I think you'll need a two step approach. Find rebuild the directory structure in the target (possibly using 'find . -type d'), then 'copy' the files (possibly using 'find . -type f'). You could also try the more adventurous avenue of a recursive version of the previous script, which could build the target hierarchy as it goes.

Also don't use any kernel (compiled) image from that dead btrfs unless you have a way of knowing it's not damaged (like a hash of it stored somewhere other than on that failed partition). Probably won't boot at all if it's damaged, but you never know.


You keep the pieces if you hard-lock your live system, boot something that came straight out of that failed partition, or somehow manage to build a kernel from non-verified source.
Back to top
View user's profile Send private message
idella4
Retired Dev
Retired Dev


Joined: 09 Jun 2006
Posts: 1600
Location: Australia, Perth

PostPosted: Sun Nov 07, 2010 3:06 pm    Post subject: Reply with quote

Neddy

yes. agreed. I got to the end. It appears I only have a handful of broken files.

Code:

idella@genny ~/bin $ ls -l /mnt/gentoo/distfiles/[A-D]*
-rw-r--r-- 1 root root   63521 Nov  8 01:38 /mnt/gentoo/distfiles/AppConfig-1.66.tar.gz
-rw-r--r-- 1 root root   48243 Nov  8 01:38 /mnt/gentoo/distfiles/Archive-Tar-1.40.tar.gz
-rw-r--r-- 1 root root   51966 Nov  8 01:38 /mnt/gentoo/distfiles/Archive-Tar-1.54.tar.gz
-rw-r--r-- 1 root root   52988 Nov  8 01:38 /mnt/gentoo/distfiles/Archive-Tar-1.60.tar.gz
-rw-r--r-- 1 root root   53736 Nov  8 01:38 /mnt/gentoo/distfiles/Archive-Tar-1.64.tar.gz
-rw-r--r-- 1 root root   54332 Nov  8 01:38 /mnt/gentoo/distfiles/Archive-Tar-1.66.tar.gz
-rw-r--r-- 1 root root   17184 Nov  8 01:38 /mnt/gentoo/distfiles/Archive_Tar-1.3.5.tgz
-rw-r--r-- 1 root root   23171 Nov  8 01:38 /mnt/gentoo/distfiles/Attribute-Handlers-0.87.tar.gz                                                                                           
-rw-r--r-- 1 root root   50394 Nov  8 01:38 /mnt/gentoo/distfiles/Authen-SASL-2.12.tar.gz
-rw-r--r-- 1 root root   36196 Nov  8 01:38 /mnt/gentoo/distfiles/Authen-SASL-2.13.tar.gz
-rw-r--r-- 1 root root   44634 Nov  8 01:38 /mnt/gentoo/distfiles/Authen-SASL-2.15.tar.gz
-rw-r--r-- 1 root root   30867 Nov  8 01:38 /mnt/gentoo/distfiles/BeautifulSoup-3.0.8.tar.gz
-rw-r--r-- 1 root root   71460 Nov  8 01:38 /mnt/gentoo/distfiles/BeautifulSoup-3.1.0.1.tar.gz
-rw-r--r-- 1 root root  239661 Nov  8 01:38 /mnt/gentoo/distfiles/CGI.pm-3.48.tar.gz
-rw-r--r-- 1 root root  683047 Nov  8 01:38 /mnt/gentoo/distfiles/Chart-2.4.1.tar.gz
-rw-r--r-- 1 root root   12315 Nov  8 01:38 /mnt/gentoo/distfiles/Class-Accessor-0.34.tar.gz
-rw-r--r-- 1 root root    5660 Nov  8 01:38 /mnt/gentoo/distfiles/Class-Data-Inheritable-0.08.tar.gz                                                                                       
-rw-r--r-- 1 root root    6056 Nov  8 01:38 /mnt/gentoo/distfiles/Class-ISA-0.36.tar.gz
-rw-r--r-- 1 root root    6187 Nov  8 01:38 /mnt/gentoo/distfiles/Class-Loader-2.03.tar.gz
-rw-r--r-- 1 root root   90428 Nov  8 01:38 /mnt/gentoo/distfiles/Class-MethodMaker-2.15.tar.gz                                                                                             
-rw-r--r-- 1 root root    7793 Nov  8 01:38 /mnt/gentoo/distfiles/Class-Singleton-1.4.tar.gz
-rw-r--r-- 1 root root   49950 Nov  8 01:38 /mnt/gentoo/distfiles/Class-Trigger-0.14.tar.gz
-rw-r--r-- 1 root root  144702 Nov  8 01:38 /mnt/gentoo/distfiles/Compress-Raw-Bzip2-2.020.tar.gz                                                                                           
-rw-r--r-- 1 root root  143452 Nov  8 01:38 /mnt/gentoo/distfiles/Compress-Raw-Bzip2-2.021.tar.gz                                                                                           
-rw-r--r-- 1 root root  124546 Nov  8 01:38 /mnt/gentoo/distfiles/Compress-Raw-Bzip2-2.024.tar.gz                                                                                           
-rw-r--r-- 1 root root  124417 Nov  8 01:38 /mnt/gentoo/distfiles/Compress-Raw-Bzip2-2.027.tar.gz                                                                                           
-rw-r--r-- 1 root root  124417 Nov  8 01:38 /mnt/gentoo/distfiles/Compress-Raw-Bzip2-2.030.tar.gz                                                                                           
-rw-r--r-- 1 root root  211988 Nov  8 01:38 /mnt/gentoo/distfiles/Compress-Raw-Zlib-2.020.tar.gz                                                                                           
-rw-r--r-- 1 root root  213228 Nov  8 01:38 /mnt/gentoo/distfiles/Compress-Raw-Zlib-2.021.tar.gz                                                                                           
-rw-r--r-- 1 root root  213407 Nov  8 01:38 /mnt/gentoo/distfiles/Compress-Raw-Zlib-2.024.tar.gz                                                                                           
-rw-r--r-- 1 root root  221081 Nov  8 01:38 /mnt/gentoo/distfiles/Compress-Raw-Zlib-2.027.tar.gz                                                                                           
-rw-r--r-- 1 root root  220697 Nov  8 01:38 /mnt/gentoo/distfiles/Compress-Raw-Zlib-2.030.tar.gz                                                                                           
-rw-r--r-- 1 root root  468591 Nov  8 01:38 /mnt/gentoo/distfiles/ConsoleKit-0.2.3.tar.gz
-rw-r--r-- 1 root root  393694 Nov  8 01:38 /mnt/gentoo/distfiles/ConsoleKit-0.3.0.tar.bz2
-rw-r--r-- 1 root root  398080 Nov  8 01:38 /mnt/gentoo/distfiles/ConsoleKit-0.4.1.tar.bz2
-rw-r--r-- 1 root root    4011 Nov  8 01:38 /mnt/gentoo/distfiles/Console_Getopt-1.2.3.tgz
-rw-r--r-- 1 root root    6002 Nov  8 01:38 /mnt/gentoo/distfiles/Convert-ASCII-Armour-1.4.tar.gz                                                                                           
-rw-r--r-- 1 root root   74625 Nov  8 01:38 /mnt/gentoo/distfiles/Convert-ASN1-0.22.tar.gz
-rw-r--r-- 1 root root   17895 Nov  8 01:38 /mnt/gentoo/distfiles/Crypt-Blowfish-2.12.tar.gz
-rw-r--r-- 1 root root   20232 Nov  8 01:38 /mnt/gentoo/distfiles/Crypt-CAST5_PP-1.04.tar.gz
-rw-r--r-- 1 root root   22639 Nov  8 01:38 /mnt/gentoo/distfiles/Crypt-CBC-2.30.tar.gz
-rw-r--r-- 1 root root   15369 Nov  8 01:38 /mnt/gentoo/distfiles/Crypt-DES-2.05.tar.gz
-rw-r--r-- 1 root root    2328 Nov  8 01:38 /mnt/gentoo/distfiles/Crypt-DES_EDE3-0.01.tar.gz
-rw-r--r-- 1 root root   39534 Nov  8 01:38 /mnt/gentoo/distfiles/Crypt-DSA-1.16.tar.gz
-rw-r--r-- 1 root root    7045 Nov  8 01:38 /mnt/gentoo/distfiles/Crypt-IDEA-1.08.tar.gz
-rw-r--r-- 1 root root  108477 Nov  8 01:38 /mnt/gentoo/distfiles/Crypt-OpenPGP-1.04.tar.gz
-rw-r--r-- 1 root root  136299 Nov  8 01:38 /mnt/gentoo/distfiles/Crypt-Primes-0.50.tar.gz
-rw-r--r-- 1 root root   57548 Nov  8 01:38 /mnt/gentoo/distfiles/Crypt-RIPEMD160-0.04.tar.gz
-rw-r--r-- 1 root root   52393 Nov  8 01:38 /mnt/gentoo/distfiles/Crypt-RSA-1.99.tar.gz
-rw-r--r-- 1 root root    8770 Nov  8 01:38 /mnt/gentoo/distfiles/Crypt-Random-1.25.tar.gz
-rw-r--r-- 1 root root   28994 Nov  8 01:38 /mnt/gentoo/distfiles/Crypt-Rijndael-1.09.tar.gz
-rw-r--r-- 1 root root  122980 Nov  8 01:38 /mnt/gentoo/distfiles/Crypt-SSLeay-0.57.tar.gz
-rw-r--r-- 1 root root   13505 Nov  8 01:38 /mnt/gentoo/distfiles/Crypt-Twofish-2.14.tar.gz
-rw-r--r-- 1 root root  122524 Nov  8 01:38 /mnt/gentoo/distfiles/DBD-mysql-4.005.tar.gz
-rw-r--r-- 1 root root  129065 Nov  8 01:38 /mnt/gentoo/distfiles/DBD-mysql-4.013.tar.gz
-rw-r--r-- 1 root root  131270 Nov  8 01:38 /mnt/gentoo/distfiles/DBD-mysql-4.014.tar.gz
-rw-r--r-- 1 root root  132396 Nov  8 01:38 /mnt/gentoo/distfiles/DBD-mysql-4.016.tar.gz
-rw-r--r-- 1 root root  132878 Nov  8 01:38 /mnt/gentoo/distfiles/DBD-mysql-4.017.tar.gz
-rw-r--r-- 1 root root  495124 Nov  8 01:38 /mnt/gentoo/distfiles/DBI-1.601.tar.gz
-rw-r--r-- 1 root root  414484 Nov  8 01:38 /mnt/gentoo/distfiles/DBI-1.609.tar.gz
-rw-r--r-- 1 root root  534200 Nov  8 01:38 /mnt/gentoo/distfiles/DBI-1.611.tar.gz
-rw-r--r-- 1 root root  566429 Nov  8 01:38 /mnt/gentoo/distfiles/DBI-1.612.tar.gz
-rw-r--r-- 1 root root   12812 Nov  8 01:38 /mnt/gentoo/distfiles/Daemon-Generic-0.61.tar.gz
-rw-r--r-- 1 root root    5497 Nov  8 01:38 /mnt/gentoo/distfiles/Data-Buffer-0.04.tar.gz
-rw-r--r-- 1 root root   93517 Nov  8 01:38 /mnt/gentoo/distfiles/Data-ObjectDriver-0.06.tar.gz                                                                                             
-rw-r--r-- 1 root root  195253 Nov  8 01:38 /mnt/gentoo/distfiles/DateTime-0.53.tar.gz
-rw-r--r-- 1 root root  176473 Nov  8 01:38 /mnt/gentoo/distfiles/DateTime-Format-Mail-0.3001.tar.gz                                                                                       
-rw-r--r-- 1 root root   15613 Nov  8 01:38 /mnt/gentoo/distfiles/DateTime-Format-W3CDTF-0.05.tar.gz                                                                                       
-rw-r--r-- 1 root root 1055901 Nov  8 01:38 /mnt/gentoo/distfiles/DateTime-Locale-0.44.tar.gz
-rw-r--r-- 1 root root  521582 Nov  8 01:38 /mnt/gentoo/distfiles/DateTime-TimeZone-1.09.tar.gz                                                                                             
-rw-r--r-- 1 root root  703028 Nov  8 01:38 /mnt/gentoo/distfiles/Dev86src-0.16.17.tar.gz
-rw-r--r-- 1 root root    8262 Nov  8 01:38 /mnt/gentoo/distfiles/Digest-1.16.tar.gz
-rw-r--r-- 1 root root   13623 Nov  8 01:38 /mnt/gentoo/distfiles/Digest-HMAC-1.01.tar.gz
-rw-r--r-- 1 root root    6989 Nov  8 01:38 /mnt/gentoo/distfiles/Digest-HMAC-1.02.tar.gz
-rw-r--r-- 1 root root   17054 Nov  8 01:38 /mnt/gentoo/distfiles/Digest-MD2-2.03.tar.gz
-rw-r--r-- 1 root root   45255 Nov  8 01:38 /mnt/gentoo/distfiles/Digest-MD5-2.39.tar.gz
-rw-r--r-- 1 root root   45686 Nov  8 01:38 /mnt/gentoo/distfiles/Digest-MD5-2.40.tar.gz
-rw-r--r-- 1 root root   40002 Nov  8 01:38 /mnt/gentoo/distfiles/Digest-SHA-5.48.tar.gz
-rw-r--r-- 1 root root   38723 Nov  8 01:38 /mnt/gentoo/distfiles/Digest-SHA1-2.11.tar.gz
-rw-r--r-- 1 root root   39073 Nov  8 01:38 /mnt/gentoo/distfiles/Digest-SHA1-2.12.tar.gz
-rw-r--r-- 1 root root   39078 Nov  8 01:38 /mnt/gentoo/distfiles/Digest-SHA1-2.13.tar.gz
-rw-r--r-- 1 root root 2064010 Nov  8 01:38 /mnt/gentoo/distfiles/DirectFB-0.9.25.1.tar.gz
-rw-r--r-- 1 root root 2771039 Nov  8 01:38 /mnt/gentoo/distfiles/DirectFB-1.2.7.tar.gz
-rw-r--r-- 1 root root 2900292 Nov  8 01:38 /mnt/gentoo/distfiles/DirectFB-1.4.2.tar.gz


Quote:

If file system errors ask dd to do something it can't do, it will stop with an error.

As you can see, the dd copy sometimes worked off the bat, sometimes required a control Z and a repeat.
On the repeat, it succeeded the copy and reported it copied; no error
Haven't tried any yet, but they have copied and report the matching size of the source files in gen2.img
_________________
idella4@aus


Last edited by idella4 on Sun Nov 07, 2010 3:32 pm; edited 2 times in total
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Goto page 1, 2, 3  Next
Page 1 of 3

 
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