Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Recovering a partition
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
toothpick
n00b
n00b


Joined: 31 May 2012
Posts: 53

PostPosted: Mon Mar 25, 2013 12:11 am    Post subject: Recovering a partition Reply with quote

Hi,

I was trying to split my root partition to "root" and "/home", so I used gparted to create another partition.
the situation was that gparted did it badly, and I couldn't move my files from my old partition to my new one because of a bad block problem.
therefore I unmounted my root partition and stupidly enough I ran mke2fs on my root partition (which solved the problem btw).
now my root partition is empty... the question is, can I recover it somehow?

Thanks !
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21489

PostPosted: Mon Mar 25, 2013 12:28 am    Post subject: Reply with quote

It would be faster to copy the files from your most recent backup than to try to recover from an inappropriate invocation of mke2fs.
Back to top
View user's profile Send private message
toothpick
n00b
n00b


Joined: 31 May 2012
Posts: 53

PostPosted: Mon Mar 25, 2013 12:42 am    Post subject: Reply with quote

I don't have any backup and I don't care how fast its going to take... I'm willing to wait weeks if I have to... Is there another solution for this?
Back to top
View user's profile Send private message
BillWho
Veteran
Veteran


Joined: 03 Mar 2012
Posts: 1600
Location: US

PostPosted: Mon Mar 25, 2013 1:36 am    Post subject: Reply with quote

toothpick wrote:
I don't have any backup and I don't care how fast its going to take... I'm willing to wait weeks if I have to... Is there another solution for this?

Recovery tools like autopsy and photorec might be able to assist with recovering some jpg and txt/doc files etc., but I can practically guarantee you that you'll never be able to run the former OS from that partition again.

The only sensible option is - well you can probably guess what it is.
_________________
Good luck :wink:

Since installing gentoo, my life has become one long emerge :)
Back to top
View user's profile Send private message
toothpick
n00b
n00b


Joined: 31 May 2012
Posts: 53

PostPosted: Tue Mar 26, 2013 11:51 pm    Post subject: Reply with quote

Thank you for the tip.
I get that photorec can only recover certain files, but what If I want to have my partition data in a file and look inside it to search for a not recovered file (using grep) ?
Do I do it with dd or ddrescue?

Thanks !
Back to top
View user's profile Send private message
BillWho
Veteran
Veteran


Joined: 03 Mar 2012
Posts: 1600
Location: US

PostPosted: Wed Mar 27, 2013 12:19 am    Post subject: Reply with quote

toothpick wrote:
Thank you for the tip.
I get that photorec can only recover certain files, but what If I want to have my partition data in a file and look inside it to search for a not recovered file (using grep) ?
Do I do it with dd or ddrescue?

Thanks !


dd if=/dev/sda3 of=/path/to/file

You would do the opposite to write to the partition

dd if=/path/to/file of=/dev/sda3

You can mount the image file with

mount -o loop /path/to/file /media/img/
_________________
Good luck :wink:

Since installing gentoo, my life has become one long emerge :)
Back to top
View user's profile Send private message
toothpick
n00b
n00b


Joined: 31 May 2012
Posts: 53

PostPosted: Wed Mar 27, 2013 12:34 am    Post subject: Reply with quote

BillWho wrote:

You can mount the image file with

mount -o loop /path/to/file /media/img/


thanks very much :) I have a few questions regarding this...

will I be able to mount the partition as a loopback device even though it was encrypted? (with cryptsetup luksOpen?)
will I be able to use photorec on the image file i just DD'ed to ?
Back to top
View user's profile Send private message
BillWho
Veteran
Veteran


Joined: 03 Mar 2012
Posts: 1600
Location: US

PostPosted: Wed Mar 27, 2013 1:24 am    Post subject: Reply with quote

toothpick wrote:
BillWho wrote:

You can mount the image file with

mount -o loop /path/to/file /media/img/


thanks very much :) I have a few questions regarding this...

will I be able to mount the partition as a loopback device even though it was encrypted? (with cryptsetup luksOpen?)
will I be able to use photorec on the image file i just DD'ed to ?


I'd be surprised if you have a valid luks header. As far as loop mounting it goes, I've never tried it and I really don't think you can.

Maybe if you dd the partition or image to a usb drive and luksOpen /dev/sdd1 name or something similar :?:

The encryption has made things much more complicated :(
_________________
Good luck :wink:

Since installing gentoo, my life has become one long emerge :)
Back to top
View user's profile Send private message
toothpick
n00b
n00b


Joined: 31 May 2012
Posts: 53

PostPosted: Wed Mar 27, 2013 1:51 pm    Post subject: Reply with quote

BillWho wrote:

Maybe if you dd the partition or image to a usb drive and luksOpen /dev/sdd1 name or something similar :?:


how can that be done? (converting a file into a real partition?)
Back to top
View user's profile Send private message
BillWho
Veteran
Veteran


Joined: 03 Mar 2012
Posts: 1600
Location: US

PostPosted: Wed Mar 27, 2013 3:09 pm    Post subject: Reply with quote

toothpick wrote:
BillWho wrote:

Maybe if you dd the partition or image to a usb drive and luksOpen /dev/sdd1 name or something similar :?:


how can that be done? (converting a file into a real partition?)

If you can fit the partition on a flash drive then use dd to copy it there instead of a file. Also, you can use another drive if you have one and a usb adapter to plug it there.

dd if=/dev/sda3 of=/dev/sdd1

For a file

dd if=/path/to/file of=/dev/sdd1

Before doing anything major on my installation I usually

dd if=/dev/sda5 | gzip -c > /media/backup/gentoo/gentooroot.img.gz

Should I have to restore it

gunzip -c /media/backup/gentoo/gentoohroot.img.gz | dd of=/dev/sda5

You might want to look through the cryptsetup man page to see if you can open a container file before struggling with the flash or disk..
_________________
Good luck :wink:

Since installing gentoo, my life has become one long emerge :)
Back to top
View user's profile Send private message
toothpick
n00b
n00b


Joined: 31 May 2012
Posts: 53

PostPosted: Wed Mar 27, 2013 3:20 pm    Post subject: Reply with quote

BillWho wrote:

If you can fit the partition on a flash drive then use dd to copy it there instead of a file. Also, you can use another drive if you have one and a usb adapter to plug it there.

dd if=/dev/sda3 of=/dev/sdd1

For a file

dd if=/path/to/file of=/dev/sdd1


but what about the preparations I have to do on the flash drive? what if it has enough space and already has a partition table? will dd if=/dev/sda3 of=/dev/sdd4 automagically create a new partition with the same size as /dev/sda3? if not, do I have to create a new partition with the same size as /dev/sda3?
Back to top
View user's profile Send private message
BillWho
Veteran
Veteran


Joined: 03 Mar 2012
Posts: 1600
Location: US

PostPosted: Wed Mar 27, 2013 4:11 pm    Post subject: Reply with quote

toothpick wrote:
BillWho wrote:

If you can fit the partition on a flash drive then use dd to copy it there instead of a file. Also, you can use another drive if you have one and a usb adapter to plug it there.

dd if=/dev/sda3 of=/dev/sdd1

For a file

dd if=/path/to/file of=/dev/sdd1


but what about the preparations I have to do on the flash drive? what if it has enough space and already has a partition table? will dd if=/dev/sda3 of=/dev/sdd4 automagically create a new partition with the same size as /dev/sda3? if not, do I have to create a new partition with the same size as /dev/sda3?

I believe you have to create the partition. As long as the size of the target is the same or larger it's fine. What will happen is the target will end up the same size.

So say you setup a partition on the usb of 20gig and the partition you copy is 16gig the resulting target will be 16gig.

You can dd an entire disk. If the source is 750gig and the target 1tb the target will be 750gig with 250gig free at the end. Then you could create another partition from the free space or re size the existing partitions.

Experiment a little with this. You really have nothing to lose :!:
_________________
Good luck :wink:

Since installing gentoo, my life has become one long emerge :)
Back to top
View user's profile Send private message
toothpick
n00b
n00b


Joined: 31 May 2012
Posts: 53

PostPosted: Sat Apr 06, 2013 8:01 pm    Post subject: Reply with quote

thanks very much for your help ! :)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
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