You are not logged in.

#1 2010-08-26 21:03:07

archnoobie
Member
Registered: 2009-10-29
Posts: 33

overwritten boot partition

I'm currently on my netbook, and I was trying to set up a boot disk for my desktop replacement. I used dd to set up a usb drive, but before I got it right, I typed /dev/sda instead of /dev/sdb. My boot partition formed the first 512MB of the sda disk, so it's gone, but my computer is still up. Is there a way to fix my boot partition while still on this computer or possibly with a recovery disk without losing other information on the disk. A second concern. By doing that, have I overwritten my entire partition table on my disk? Am I completely out of luck on this one? I don't want to reboot yet for fear of losing tools I may be able to use right now. Thanks for any help anyone may offer.

EDIT: I might also add that /dev/sda2 is 2GB of swap space, so should my partition table not be clobbered, those two partitions will have absorbed the blunt of the blow.

Last edited by archnoobie (2010-08-26 21:04:38)

Offline

#2 2010-08-26 21:30:12

ziarkaen
Member
Registered: 2009-06-21
Posts: 20

Re: overwritten boot partition

OK Go onto the ArchLinux IRC channel if you can.  You can get quicker help there.

Secondly, how large was the file you were DDing?  The partition table isnt that much of a problem, but you want to know exactly what it overwrote.


ziarkaen

Offline

#3 2010-08-26 21:30:33

tomd123
Developer
Registered: 2008-08-12
Posts: 565

Re: overwritten boot partition

"EDIT: I might also add that /dev/sda2 is 2GB of swap space, so should my partition table not be clobbered, those two partitions will have absorbed the blunt of the blow."

It depends on how the partition was laid out.
I would assume that /dev/sda1 would be overwritten before sda2 so. I don't really know what to tell you, maybe you could try recreating the non overwritten partitions. But also take a look at undelete for your fs type.

Sorry, don't know how else I can help you with this.

Offline

#4 2010-08-26 21:40:48

tomd123
Developer
Registered: 2008-08-12
Posts: 565

Re: overwritten boot partition

just an fyi, you should probably say goodbye to the data that *was* overwritten.

Offline

#5 2010-08-26 21:43:34

ziarkaen
Member
Registered: 2009-06-21
Posts: 20

Re: overwritten boot partition

Certainly don't turn off the computer unitl you get a definite "you're screwed" from someone knowledgeable on IRC or here.

Please provide output of "cfdisk -Ps /dev/sda", "cat /etc/fstab", and what you think the partition layout was.  Swap can be used as cannon fodder, but if / was in the firing line, you have more serious problems.  If you have messed up your filesystem, "ls -l /" would probably return in error.


ziarkaen

Offline

#6 2010-08-27 02:39:10

archnoobie
Member
Registered: 2009-10-29
Posts: 33

Re: overwritten boot partition

The physical layout should have been

[ 512MB boot | 2GB swap | < var first, opt, tmp, and usr in between, root last > | about 100GB home ]
  sda1             sda2              sda  5 - 9                                                            sda4

The file was the x86_64 version of the arch iso which should have been about 370MB, so it shouldn't have even gotten past the first partition.

sudo cfdisk -Ps /dev/sda
Partition Table for /dev/sda

               First       Last
 # Type       Sector      Sector   Offset    Length   Filesystem Type (ID) Flag
-- ------- ----------- ----------- ------ ----------- -------------------- ----
 1 Primary           0      696319      0#     696320 Hidden HPFS/NTF (17) Boot
   Pri/Log      696320   488396799      0   487700480 Free Space           None
# /etc/fstab: static file system information
#
# <file system>        <dir>         <type>    <options>          <dump> <pass>
devpts                 /dev/pts      devpts    defaults            0      0
shm                    /dev/shm      tmpfs     nodev,nosuid        0      0

#/dev/cdrom             /media/cd   auto    ro,user,noauto,unhide   0      0
#/dev/dvd               /media/dvd  auto    ro,user,noauto,unhide   0      0
#/dev/fd0               /media/fl   auto    user,noauto             0      0

LABEL=boot /boot ext2 defaults 0 1
LABEL=home /home ext4 defaults 0 1
LABEL=opt /opt ext4 defaults 0 1
LABEL=root / ext4 defaults 0 1
LABEL=swap swap swap defaults 0 0
LABEL=tmp /tmp ext4 defaults 0 1
LABEL=usr /usr ext4 defaults 0 1
LABEL=var /var reiserfs defaults 0 1

EDIT: "ls -l /" works fine. The only error has been "ls -l /boot". I unmounted it earlier trying to figure it out, but it didn't remount after which makes perfect sense.

Last edited by archnoobie (2010-08-27 02:46:44)

Offline

#7 2010-08-27 04:48:48

archnoobie
Member
Registered: 2009-10-29
Posts: 33

Re: overwritten boot partition

I think I've gotten it all sorted out. Thanks to any and all who helped.

First, I didn't reboot, so I still had my partition table in various places of the system including the kernel and the disk.

Second, testdisk is the tool you want. I used testdisk to analyze my underlying disk structure and recreate the partition table.

Now for a reboot to see if I correctly set up my boot partition again.

Offline

Board footer

Powered by FluxBB