# Booting from Install Media to use Shell -> Damaged Installation



## pkc (Sep 1, 2012)

Hi,

I had set up XDM with XFCE, but due to some display incongruity it would not work properly, and I could not exit out of it to return to the shell. I tried several key combinations to try to get out of X, and then rather foolishly started up from the USB installation stick (8.3 amd64) to try to get a shell going to disable XDM so that I could reconfigure it later. 

The 'emergency holographic shell' found in the installation menu never presented itself, and while looking through the list of items in the post-installation configuration for an alternative, I accidentally hit my enter key over 'Fdisk'. So I just accepted the first question ("Do you want to keep your geometry?"), hit Q ('Finish') and 'Cancel' on the next window about the boot manager, and exited the installation. However unfortunately this seems to have committed changes to disk, as I am no longer able to start up.

I guess I basically destroyed my filesystem, but I never altered the partition table, so I presume there is still hope for me. Where should I start in recovering my system?

Thanks.


----------



## jb_fvwm2 (Sep 1, 2012)

Not enough details, but a chance you did not install a boot manager. Maybe describe the partitions, etc that you had setup? Or even boot from a GAG bootloader cdr? If the data on the disk was not destroyed, maybe that is all that is needed as a temporary workaround (a temporary, then a permananet, boot loader. Maybe the forum has a thread on its installation that describes a method to install it that may work...I've sometimes used a 5.x cdr where a 7.x cdr failed, and vice versa maybe.. )


----------



## pkc (Sep 2, 2012)

When I select the boot manager and press 'enter' over the OK button (with the interactive manager selected), it just brings me back to the drive selection screen (ad0/da0). This is strange, since I didn't even get the drive selection screen the first time around, when I messed things up. I have not found a way to get out of this loop without pressing 'cancel' somewhere.

Really, all I need is a shell, so I can run boot0cfg or whatever it is that installs a boot manager. Then presumably I will discover whether my system is intact.

The partitions I had setup I believe were the standard - /home, /var/, /usr, /tmp, and whatever else there is.


----------



## pkc (Sep 6, 2012)

The shell in fact works, but it does not support any sort of boot loader mechanism (or ls, for that matter). The installer no longer displays the 'ad0 vs da0' confirmation dialog I was commenting on earlier, so I am able to enter and exit fdisk freely. However, it seems that the changes are not being written - my computer still reports 'Operating system not found', which presumably would not happen if there were a bootloader in place. Am I missing something with regards to committing changes to disk? It is clear that sysinstall committed some sort of change somewhere when I started it up the first time (i.e., to fix XDM), but of what sort I'm not sure.

I do realize it was completely idiotic to start from the installation boot to fix something X-related, but now I worry that I will need to do a clean installation.

EDIT: Also, I mixed up the partitions with something else, jb_fvwm2, when you asked me about that. I am using the entire disk for FreeBSD. So 0-63 is 'unused', and 63 onwards is 'freebsd'. The latter has been set to bootable in fdisk. I would just say, 'Use entire disk', but I fear that the filesystem will be overwritten if I do that. (If it hasn't already been overwritten.)


----------



## kpa (Sep 6, 2012)

It's hard to tell what the state of the disk really is without better details. Post the output of (run in the shell):

`# gpart show`


----------



## pkc (Sep 6, 2012)

Thanks for your reply, kpa. I understand, but my main problem right now is that I do not have access to a shell, as far as I can tell. (Otherwise I would've just installed the boot manager myself, if that's the problem). The 'emergency holographic shell' from the installer only comes with 'pwd' and 'cd', as far as I can tell. It may be important that I am booting from USB stick (the only method available to me I think)


----------



## kpa (Sep 6, 2012)

Select 'Fixit' from the menu and then the type of medium you booted from, that will give you a shell.


----------



## pkc (Sep 6, 2012)

Hm, it didn't work in my 8.3-R stick, but the one with 8.2 works. I mounted my slices, and everything seems to be intact. However, even after running boot0cfg -B /dev/ad0, the computer cannot boot.

EDIT: I didn't include gpart show because I assume that was re: data integrity, but if it is still useful I will post it.


----------



## kpa (Sep 6, 2012)

I'd still like to see it, it provides the same information as fdisk(8) but displays the it in much more readable (at least in my opinion) form. I'm just guessing but you might be just missing the active flag on the first slice of the disk.


----------



## pkc (Sep 6, 2012)

here we are -


```
=>      63         625142385  ad0    MBR        (298G)
        63         625142385  1      freebsd        (298G)

=>             0  625142385   ad0s1  BSD                (298G)
               0    2097152   1      freebsd-ufs        (1.0G)
         2097152    8388608   2      freebsd-swap        (4.0G)
        10485760   15937536   4      freebsd-ufs        (7.6G)
        26423296    2097152   5      freebsd-ufs        (1.0G)
        28520448  596621937   6      freebsd-ufs        (284G)

=>      0    3907583    da0    BSD     
        0         16           - free - 
       16    2124544    1      !0
  2124560    1783023           - free -
```

Pretty sure that's accurate


----------



## kpa (Sep 6, 2012)

All right, the active flag seems to be missing, try this:

`# gpart set -a active -i 1 ad0`


----------



## pkc (Sep 6, 2012)

Excellent, it boots normally. Thanks for your help.


----------

