[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Help really needed: Formatted / partition by accident.

nick lidakis wrote:
I was having trouble with my monowall router running off a compact flash. I decide to reinstall the monowall boot image onto the CF card. In the process I must have mistyped and accidentally wrote the image to my boot partition i.e. /dev/sda1. The machine now boots into monowall instead of Grub.

Using Google, I can only find articles or HOWTO's on recovering a corrupt or overwritten master boot record.

It sounds as if you have created a new filesystem on /dev/sda1 which used to be your root partition, so it's not only an issue with the MBR. For the rest of my answer, I am assuming this.

> When I did the initial
installation with the latest the net install cd I chose the default desktop partition scheme, which I believe (if I am not mistaken) was /, /usr, and a home partitions. / would have my kernels, root directory and grub.

So my question is, how do I proceed? I can use a rescue CD to boot into the system and mount /, but how would I reinstall what would normally be in /? Do I do a reinstall and skip formatting / home?

You could boot from the rescue CD (assuming it's a Debian one) and mount /dev/sda1 to, say, /mnt/sda1. Then you do 'debootstrap /mnt/sda1' which will install a Debian System on /mnt/sda1 (your / partition), then chroot into /mnt/sda1, adjusting your bootloader config and run the bootloader to install the MBR.

Of course you can keep your /home - just mount it into the new system. With the partition used as /usr it's going to be a bit more difficult as it contains system files from your old installation; if you can, wipe it out and use it as /usr in your new system. So basically you'd do (from the rescue system):

 $ mkdir -p /mnt/sda1

 $ mkfs -t ext3 /dev/sda1  # this will destroy your monowall
                           # installation

 $ mount /dev/sda1 /mnt/sda1

 $ mkdir /mnt/sda1/home

 $ mount /dev/sdaX /mnt/sda1/home  # sdaX is the partition where /home
                                   # resides

 $ mkfs -t ext3 /dev/sdaY   # sdaY is the partition used as /usr
                            # everything that used to be on /usr will
                            # be destroyed

 $ mkdir /mnt/sda1/usr

 $ mount /dev/sdaY /mnt/sda1/usr

 $ debootstrap /mnt/sda1

 $ chroot /mnt/sda1

 [configure your bootloader]

 [run bootloader]

 [adjust fstab]:
   /dev/sda1       /     ext3   defaults    0   0
   /dev/sdaX       /home ext3   defaults    0   0
   /dev/sdaY       /usr  ext3   defaults    0   0
   /dev/sdaZ       none  swap   sw          0   0
   proc            /proc proc   defaults    0   0

 $ exit

 $ reboot

That should be it. You'll lose your old root-partition (which you already did, I think, by installing monowall on /dev/sda1) and your old /usr partition. You should be able to keep /home.

If there's anything important on /usr, you can of course save that as you can still access this partition with the rescue cd.

Any help at all would be appreciated!


	-- Kilian

Reply to: