# invalid partition table



## martins (Jun 29, 2010)

I seems the BSD little devil is trying to discourage me from using FreeBSd.
Once again I'll might need to reinstall it (Hopefully not).

I had my system on the first slice of my laptop's hardrive. The rest was unpartitioned and free. I wanted to create another slice for my data. I ran sysinstall and used fdisk and label. I must have done something wrong, because when I reboot the computer it just says 'Invalid partition table' That's the first and only thing that appears when I power on the computer (I mean after the bios stuff).
Is there a way of recovering from it?

thanks


----------



## zeiz (Jun 29, 2010)

1. What installation media do you have?
2. Did you create the data slice from running FreeBSD or you ran sysinstall from installation media?
3. What did you do exactly when you created the data slice?


----------



## Beastie (Jun 29, 2010)

Option 1. A livefs disc (+240MB) and fdisk(8) if you know what you're doing.
Option 2. TestDisk otherwise.
Option 3. Reinstall if you don't want to waste your time.


----------



## martins (Jun 29, 2010)

Thanks



> What installation media do you have?



I installed from a FreeBSD-8.1-PRERELEASE-201006-amd64-dvd1.iso


> Did you create the data slice from running FreeBSD or you ran sysinstall from installation media?



It was from a running FreeBSD. I created a slice and wanted to 'write' the changes. It asked me if I'm sure I want to do it. Yes. It complained something about disk geometry or blocks and said that if I want to write changes on a live system I need to pass one command. I can't remember what it was (I pasted it - something to do with '16'?) 




> Option 2. TestDisk otherwise.



Is this the option I need to choose?


----------



## Beastie (Jun 29, 2010)

martins said:
			
		

> It complained something about disk geometry or blocks and said that if I want to write changes on a live system I need to pass one command. I can't remember what it was (I pasted it - something to do with '16'?)


I bet the message was telling you to *sysctl kern.geom.debugflags=16 and try again*, which means it couldn't write anything to the disk, which means this probably was not the cause of your problem. But I might be wrong...



			
				martins said:
			
		

> Is this the option I need to choose?


It's called an option for some reason. You know what _you_ must choose more than _I_ do.


----------



## zeiz (Jun 29, 2010)

Since you have dvd1 you have livefs on it. So you may try to correct your partition table with *fdisk* using Fixit environment (boot from dvd>sysinstall>Fixit). You may choose to play with it because you have nothing to loose

However if you don't have valuable data on your disk I would take Beastie's advice and do reinstall from scratch because you may already have nothing on your disk.
During new install create both slices on the same fdisk screen: first (for FreeBSD - should be ad0s1) and the second for data (ad0s2). When you got to labeling screen choose ad0s1 for labeling. Don't "W" anything it will be written automatically after you press OK to commit.

TestDisk is a software /usr/ports/sysutils/testdisk but you even cannot boot now...


----------



## martins (Jun 29, 2010)

Thanks guys, I had a Knoppix DVD handy which included TestDisk. I changed the disk geometry value from 63 to 16 and it works fine.

You both mentioned reinstalling the system to system to save time. It puzzles me. I must be missing something because after 3 days spent on installing ports, it's the last thing I'd think of. Seriously, I like the idea of ports - compiling from source, instead of installing binaries, but it takes AGES so I would do anything not to install it again. Hence, I'd say I'd like to fix it to SAVE my time, not reinstall the system to SAVE my time. I started installing ports 3 days ago and my laptop has been on since then installing stuff. It's not even that I install everything. I just installed the stuff I know and use on linux. I didn't install Gnome/KDe etc - it would probably take all day.

So the question is: What am I missing here? During the installation process I only installed documentation, there was no other options (no additional software) so it was a pretty bare system. When I started installing ports it had to compile lots of libraries, etc. and obviously it takes time.
What do you freebsd people do? Don't you use ports?! Do you use ports for everything that you install after the installation process has finished, or only for stuff that you want to customise (eg. extra options,etc)?

thanks


----------



## zeiz (Jun 29, 2010)

There are many people who prefer to install everything by compiling from sourse.
I am not one of them and I always try to install from binaries (packages). It takes a couple of hours to reinstall everything including FreeBSD itself. There are 4 exceptions from my rule: if I want to change default config somewhere, if some bleeding edge software I'm interested in just appeared in ports and I cannot wait for official packages, if packages simply don't exist (like openoffice.org), and finally if I know that a package is so small that there is almost no difference how to install.
Plus very important (but relatively rare) situation when something bumps and almost everything depends on this "something".
In all other cases I use packages. For example now Xorg has same version as source, Gnome, KDE and most others too... well maybe almost. I keep my ports up-to-date with portsnap and after installing from packages I run
`# pkg_version -vL=` then see if any important packages are to be updated and update them first with
`# portupgrade -RP packagename`
because up-to-date package may already exist. Then run 
`# pkgdb -F`to fix dependencies.

I'm curious what did you compile for 3 days if not Gnome and KDE?


----------



## martins (Jun 29, 2010)

Thanks. I need to look into portsnap as I haven't come across it yet.



> I'm curious what did you compile for 3 days if not Gnome and KDE?



All sorts of stuff Obviously it's not that one thing compiled for 3 days. Another thing is that it's not one of the most powerful laptops so it also affects the speed.

Anyway, I don't have a problem spending a week configuring freebsd as long as it's a recommended way of doing it and there are valid advantages of doing so.


----------



## martins (Jun 29, 2010)

Beastie said:
			
		

> I bet the message was telling you to *sysctl kern.geom.debugflags=16 and try again*, which means it couldn't write anything to the disk, which means this probably was not the cause of your problem. But I might be wrong...



Yes, that was the message.


----------



## zeiz (Jun 29, 2010)

`$ man portsnap`
Most common usage

```
# portsnap fetch extract  ## if using portsnap for the first time
OR
# portsnap fetch update   ## for day-to-day updates
```
First time it downloads a tarball with all the ports (~60MB) and then extracts it. Takes some time, but after 1st time it's really fast because it downloads only deltas.

As to recommended way... well I'm not sure but for example OpenBSD doesn't recommend compiling from source but encourages to use only binaries. They say compilers also have bugs  but official packages are tested.
BTW sometimes it is not even possible to compile successfully because of just 1 broken dependency port: it stops in the middle and that's it - nothing was installed. 
Long discussion... but if my system runs perfectly and I can reinstall it for maximum 3 hours what is the difference if I would build the same packages myself for 3 days?
Moreover I'm always brave enough to experiment because I know it's not a big deal to reinstall.


----------



## martins (Jun 29, 2010)

Fair enough. 

So far The have been very few cases that I really needed to install something from ports. The most notable one was mutt, which AFAIK has certain options disabled by default (smtp, hcache, sasl2), and which I use a lot and xorg (to disable NOUVEAU)

When it comes to installing binaries, is there some equivalent of Slackbuild's queues from Slackware or something similar so that once I've installed all the packages I need I could save the queue of the packages and next time I install the system I could pass the queue to the packages manager to install what I want?


----------



## zeiz (Jun 29, 2010)

I don't know. What I know is that *pkg_add* accepts a queue for example:
`# pkg_add -r xorg portupgrade gnome2 firefox gimp inkscape whateverelse`and all must be installed with dependencies but I've never tried more that 2-3 small packages because Xorg usually must be configured and I like to check Gnome or KDE first before installing anything else.
Same with *portupgrade* which is also able to accept a queue and even install new packages but I never tried it to install such stuff like xorg or KDE from scratch.


----------



## a129878 (Apr 10, 2011)

had this same problem and using one of several bootable utility CDs found both the orginal slice and the new one I had made with *sysinstall* were marked as bootable. Corrected this, by making the original slice the only bootable slice and the system came back.

Mind, /etc/fstab was all messed up, so I had to make sense of this with *ed*.


----------

