You are not logged in.

#1 2014-06-23 20:27:06

rikous
Member
From: Catania, Italy
Registered: 2014-06-23
Posts: 8

Unable to mount /home after dd command

Hi everybody,
my intention was to backup the whole usb  pendrive into my home partition  but after the command 'sudo dd if=/dev/sda3 of=/dev/sdb1 bs=8M && sync' where sda3 was my home partition, sdb1 was the usb pendrive, when I restart system my home partition was not recognised anymore.
When i try to mount it with 'mount /dev/sda3 /mnt/home' the output is:

mount: wrong fs type, bad option, bad superblock on /dev/sda3,
       missing codepage or helper program, or other error

       In some cases useful info is found in syslog - try
       dmesg | tail or so.

The output of fdisk -l is:

/dev/sda1              2048  20002047  10000000  83 Linux
/dev/sda2   *     512348160 625141128  56396484+  7 HPFS/NTFS/exFAT
/dev/sda3          20002816 496721919 238359552  83 Linux
/dev/sda4         496723966 512346111   7811073   5 Extended
/dev/sda5         496723968 512346111   7811072  82 Linux swap / Solaris

The output of lsblk:

sda      8:0    0 298,1G  0 disk 
├─sda1   8:1    0   9,5G  0 part /
├─sda2   8:2    0  53,8G  0 part 
├─sda3   8:3    0 227,3G  0 part 
├─sda4   8:4    0     1K  0 part 
└─sda5   8:5    0   7,5G  0 part [SWAP]
sr0     11:0    1  1024M  0 rom  

File /etc/fstab shows:

# /etc/fstab: static file system information
#
# <file system> <dir>   <type>  <options>       <dump>  <pass>
# /dev/sda1
UUID=6a2b1eb1-aec9-415d-b830-ed928655144f       /               ext4            rw,relatime,data=ordered        0 1

# /dev/sda3
UUID=1e7ebf6b-2478-4e4f-ac05-617de18b02e3       /home           ext4            rw,relatime,data=ordered        0 2

# /dev/sda5
UUID=823bd67a-4d9d-4269-a8f6-121a7cbaec3e       none            swap            defaults        0 0

What should I do?

Last edited by rikous (2014-06-23 20:55:12)

Offline

#2 2014-06-23 20:31:37

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,545
Website

Re: Unable to mount /home after dd command

Welcome to the forums.  Please edit your post to enclose file contents or command output code tags.

The dd command you used did exactly what it was supposed to do.  It overwrote your home partition - this is why it is nicknamed 'disk destroyer'.

Do you have a backup of your home partition?  Did you realize there was a problem and quickly interupt the dd command?  If not, how big was the usb?

Your home partition was destroyed.  The question now is only on the likelihood or necessity of trying to recover some of the data.

If misery loves company, you may want to see (or post in) this other thread

EDIT:

You can pretty easily create a new home partition, and make a new filesystem - and you could be up and running in no time.  But if you don't have backups of any data in your home partition, it would then be gone for good.  If you didn't have anything vital there to start with, or you have backups (which you should), then this will be the best approach.  But this is why I'm asking about the size of the usb (how much data was destroyed), and the existence of backups.

Last edited by Trilby (2014-06-23 20:36:27)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2014-06-23 20:55:08

DrShame
Member
Registered: 2014-04-26
Posts: 21

Re: Unable to mount /home after dd command

But if he used /home as "if" and the usb drive as "of" like he writes, then the outcome would be an overwritten usb drive ?

Maybe it's just a matter of checking if the real uuid of the home partition is the same as the one written in fstab ?

Last edited by DrShame (2014-06-23 20:56:04)

Offline

#4 2014-06-23 21:01:49

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,545
Website

Re: Unable to mount /home after dd command

Ah, quite right.  I missed that.  Rikous, can you clarify what the exact command you executed was?  From the resulting symptoms, I gather the usb was the `if` and the home partition was the `of`.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2014-06-23 21:08:10

rikous
Member
From: Catania, Italy
Registered: 2014-06-23
Posts: 8

Re: Unable to mount /home after dd command

dd if=/dev/sda3 of=/dev/sdb1 bs=8M && sync

Offline

#6 2014-06-23 21:10:21

rikous
Member
From: Catania, Italy
Registered: 2014-06-23
Posts: 8

Re: Unable to mount /home after dd command

For recovering files I've just tried testdisk, when I select list files it says that file system is corrupted

Last edited by rikous (2014-06-23 21:10:45)

Offline

#7 2014-06-23 21:23:16

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,545
Website

Re: Unable to mount /home after dd command

Hmm, DrShame is right then - and there may be some good news.  You did not overwrite your home partition with the usb.  You overwrote the usb with your home partition.  However, as your home partition is likely much larger than the usb, I'm not actually sure what dd will do.  It's possible the remaining data "overflowed" into the next item - which could have been nearly anything.  Again, I'm really not sure this is possible - I'll have to check [1].

Just to further check - do you have any idea how long that command took to complete?  DDing a couple hundred gigs should take a very long time - even on fast systems (at least while overwriting the usb drive).

I'd still just like to gather some more data: 1) how big is the usb drive?  2) Can the usb drive currently be accessed from other systems?

EDIT [1]: this is proving difficult to check without destructive experimentation.  Googling for "DD if bigger than of" gives a bunch of results about bra sizes hmm

Last edited by Trilby (2014-06-23 21:31:48)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#8 2014-06-23 21:27:34

rikous
Member
From: Catania, Italy
Registered: 2014-06-23
Posts: 8

Re: Unable to mount /home after dd command

Usb drive is 8 GB and it cant be accessed from other systems, mine neither

Offline

#9 2014-06-23 21:30:04

rikous
Member
From: Catania, Italy
Registered: 2014-06-23
Posts: 8

Re: Unable to mount /home after dd command

P.S. Actually im on my own system with root user because of my home not accessible

Last edited by rikous (2014-06-23 22:34:54)

Offline

#10 2014-06-23 21:41:24

DrShame
Member
Registered: 2014-04-26
Posts: 21

Re: Unable to mount /home after dd command

Do you see the usb drive if you do a "sudo blkid" ? Could be /dev/sdd1 or something similar.

I once repaired a unmountable usb drive by messing with it in windows console while using the diskpart command. After a few attempts i got it right and it started automounting properly again. I guess the same could be done with fdisk or similar under Arch (remove existing partition, create new one of full size etc ...)

But this also erases all data on it smile

Last edited by DrShame (2014-06-23 21:44:28)

Offline

#11 2014-06-23 21:50:33

rikous
Member
From: Catania, Italy
Registered: 2014-06-23
Posts: 8

Re: Unable to mount /home after dd command

Ok ive got some news, ive tried to read my usb drive in another system(ubuntu) and after a long time it was mounted successfully with all files inside. Now the problem is my home partition...

Last edited by rikous (2014-06-23 21:50:59)

Offline

#12 2014-06-24 15:19:52

DrShame
Member
Registered: 2014-04-26
Posts: 21

Re: Unable to mount /home after dd command

Did you try to check and repair the partition with fsck ?

Offline

#13 2014-06-24 16:23:27

Amanda S
Member
Registered: 2013-09-21
Posts: 276
Website

Re: Unable to mount /home after dd command

DrShame wrote:

But if he used /home as "if" and the usb drive as "of" like he writes, then the outcome would be an overwritten usb drive ?

*If* he's statements are correct, yes.

@OP: There's no shame on confessing a mistake tongue Inverting the dd command could happen to anyone who is in a rush. In fact, it almost happened to me once. Luckly that was only the one case, I normaly pay a lot of attention when dealing with dd. I've been using it for over 8 years and it never destroyed a partition I didn't specify. I also only use labels instead of UUID's.

EDIT:

rikous wrote:

Ok ive got some news, ive tried to read my usb drive in another system(ubuntu) and after a long time it was mounted successfully with all files inside. Now the problem is my home partition...

Then you're safe. I'd keep that data in a safe place. Then I'd fill the corrupt drive with zeroes to avoid any problems. Once that's done you can create new partitions, install the system and put your data that is in the USB drive back in the internal one, just remember to backup the MBR after. https://wiki.archlinux.org/index.php/Ma … estoration

Last edited by Amanda S (2014-06-24 16:28:17)


If it ain't broke, you haven't tweaked it enough...

Offline

#14 2014-06-24 18:38:57

rikous
Member
From: Catania, Italy
Registered: 2014-06-23
Posts: 8

Re: Unable to mount /home after dd command

DrShame wrote:

Did you try to check and repair the partition with fsck ?

Yes i did but it reports an error about superblocks and it suggests to use ef2sck but executing this one the error is the same...

Amarildo wrote:

*If* he's statements are correct, yes.

@OP: There's no shame on confessing a mistake tongue Inverting the dd command could happen to anyone who is in a rush. In fact, it almost happened to me once. Luckly that was only the one case, I normaly pay a lot of attention when dealing with dd. I've been using it for over 8 years and it never destroyed a partition I didn't specify. I also only use labels instead of UUID's.

Trust me, i have no problems on confessing a mistake, i remember i did the correct command however there's no way to control that, hystory console is not available anymore...

Amarildo wrote:

Then you're safe. I'd keep that data in a safe place. Then I'd fill the corrupt drive with zeroes to avoid any problems. Once that's done you can create new partitions, install the system and put your data that is in the USB drive back in the internal one, just remember to backup the MBR after. https://wiki.archlinux.org/index.php/Ma … estoration

Thank you, i just did that, everything it's ok now!

Last edited by rikous (2014-06-24 18:45:41)

Offline

#15 2014-06-24 18:45:06

rikous
Member
From: Catania, Italy
Registered: 2014-06-23
Posts: 8

Re: Unable to mount /home after dd command

Thanks to all guys, i had no other choice so i decided to format the partition, set the mountpoint as /home again, I updated /etc/fstab and I have created a new user now, all works again. I rescued a lot of files with photorec especially all personal photos that they were the most important things, now i need to reconfigure some things but it's not a big problem!
Thanks again!

Offline

Board footer

Powered by FluxBB