# Updating Xorg with KMS instructions question.



## neilms (Sep 10, 2013)

Hello,

I am wishing to install X.Org on a laptop with FreeBSD 9.1 that uses a Mobile Intel GMA 4500M graphics adapter.

In the past I have managed to get X working on this system without any special modifications, but it was not stable. In particular, the system would hang when I tried to log out and my only way of shutting down was to pull the plug. This would have eventually ruined my hard disk, so I had to stop using FreeBSD altogether. Now I am going to try again from scratch to get this system working properly.

I have read other threads here that show that to get an Intel graphics card to work properly, the default kernel needs to be rebuilt. Many people with this particular problem are referred to this thread: http://forums.freebsd.org/showpost.php?p=187947&postcount=3. The problem is that these instructions were posted on August 22nd 2012 and since then it appears that the handbook has been substantially updated. 

In particular:


> 1. Checkout FreeBSD 9.1 or 9-Stable (or HEAD): See Handbook Section 25.6
> 2. Checkout a current snapshot of ports: See Handbook Section 5.5



Now, the current handbook Section 25.6 has no entry. Section 25 refers to "DTrace" and only goes up to section 25.5. Furthermore, Section 5.5 now explains "PKGNG for binary package management".

To follow the instructions in the original thread, I just need to be clear about the current sections of the handbook that I need to follow. Could someone please clarify this?


----------



## SirDice (Sep 10, 2013)

neilms said:
			
		

> Checkout FreeBSD 9.1 or 9-Stable (or HEAD): See Handbook Section 25.6


I think that's now 24.6.



> Checkout a current snapshot of ports: See Handbook Section 5.5


Is now 5.6.


----------



## wblock@ (Sep 10, 2013)

Edited.  Incidentally, it is not necessary to rebuild the kernel if you already have FreeBSD 9.1.


----------



## neilms (Sep 10, 2013)

wblock@ said:
			
		

> Edited.  Incidentally, it is not necessary to rebuild the kernel if you already have FreeBSD 9.1.



Are you saying that with 9.1-RELEASE, all I need to do is edit /etc/make.conf?

I have already deleted /usr/src and /usr/ports with rm -r and have retrieved 9-STABLE and the latest ports tree using Subversion. So I am probably past the point of no return now anyway. I need to see if the original `make` command is what I need to use.


----------



## wblock@ (Sep 10, 2013)

Yes, edit make.conf and rebuild some ports: http://forums.freebsd.org/showthread.php?p=206841#post206841


----------



## neilms (Sep 11, 2013)

*Fatal error with mergemaster*

I carried out the steps of `make buildworld`,`make buildkernel`and`make installkernel` as set out in the handbook at section 24.7.

I just went onto the next step which is to boot into single user mode and run `mergemaster -p`. The first time I ran this it said that the file system was read only, so I looked online and found that I could mount it using `mount -urw /` and this is what I did, before running `mergemaster -p`.

I was presented with some options and was not even sure what to do but it went through after 3 or 4 questions and I exited the mergemaster program.

This is where the problems started.


 `make installworld`
When I entered this command the error message was 'don't know how to make installworld'. So I just experimented and moved into /usr/src and tried it again. This is the error I get when I enter this command from the src directory:

```
"Error: Required auditdistd user is missing, see /usr/src/UPDATING.
*** [installcheck_UGID] Error Code 1
Stop in /usr/src."
```
This file says that auditistd user is added by `mergemaster -p` but it seems that this did not happen as I may possibly have made a mistake. Now I tried to run `mergemaster -p` again, but it does not work in the same way as before. I first got a error about /var/tmp/temproot already exists and cannot be written to. So I deleted it (thinking this would clear things up) and tried again. This is exactly what I get when I try the `mergemaster -p` command:


```
# mergemaster -p

*** Creating the temporary root environment in /var/tmp/temproot
*** /var/tmp/temproot ready for use
*** Creating and populating directory structure in /var/tmp/temproot

install: wheel: Invalid argument

*** FATAL ERROR: Cannot copy files to the temproot environment
#
```

 I cannot go on to the next steps, which require `make installworld`, then `mergemaster`(without arguments) and finally `make delete-old`
Can anyone tell me how to fix this? If not I will have to do a fresh install of FreeBSD 9.1-RELEASE and start right from the beginning with this.


----------



## jb_fvwm2 (Sep 11, 2013)

Two things: you may wish to run [cmd=]/usr/src/usr.sbin/mergemaster.sh [/cmd]. Maybe you can `make buildworld -DNO_CLEAN -DNOCLEAN` and the same parameter with installworld, it might create the directory again with the right permissions; and have you created the auditd user yet? See /usr/src/UPDATING. (Of course, it could be some other fix...)


----------



## SirDice (Sep 11, 2013)

It's better to reboot and perform the installworld in single user mode after booting the new kernel. However, for the past 10-15 years I've never done that and only once did it cause a problem (this was because of the UFS to UFS2 transition). Just follow the mantra, buildworld, buildkernel, `mergemaster -p`, installkernel, installworld, `mergemaster` and reboot afterwards. If the system boots properly you can do the delete-old{-libs}.


----------



## neilms (Sep 11, 2013)

jb_fvwm2 said:
			
		

> Two things: you may wish to run [cmd=]/usr/src/usr.sbin/mergemaster.sh [/cmd]; Maybe can make buildworld [cmd=] -DNO_CLEAN -DNOCLEAN[/cmd] and the same parameter with installworld, it might create the directory again with the right permissions; and have you created the auditd user yet? see /usr/src/UPDATING.  (Of course, it could be some other fix...)



 [cmd=]/usr/src/usr.sbin/mergemaster.sh [/cmd]
I tried this in single user mode and in regular mode and got the message 'Command not found'.

 `make buildworld` took over six hours to complete the first time, but I tried it with the arguments you suggested and get an error code 1: "mtree: line 6: unknown group wheel"
Unfortunately, the instructions for this procedure do not seem to clear at all - though obviously I understand that the handbook can't possibly detail every single step - such a crucial procedure really needs to be painstakingly set out. The UPDATING file even suggests audituserd is added by `mergemaster -p` - in my case that didn't happen. 

After building the system all day yesterday, it seems that I will have to start all over again with a new install as I cannot leave it 'as is'. Thanks for your help anyway.


----------



## wblock@ (Sep 11, 2013)

See http://forums.freebsd.org/showpost.php?p=201871&postcount=8 to add the auditdistd user.

mergemaster(8) is not particularly pleasant.  I skip the -p step as useless and unhelpful, and use -Ui.  The first time through, it requires careful watching.  It is much easier after that.


----------



## neilms (Sep 12, 2013)

Thanks for helping everyone. This was the first time I rebuilt the system and so was unclear about some of the steps set out in the handbook section 24.7 following `make installkernel`. So if anyone else tries to do this I have set out the steps here - after that command completes.

Shutdown and reboot into single user mode.
At the prompt type `mount -urw /`
`cd /usr/src`
`pw useradd -n auditdistd -g audit -c "Auditdistd unprivileged user" -d / var/empty -s /usr/sbin/nologin`.
`mergemaster -p`
In response to the mergemaster script's questions, I left all the default answers in place. That is [Leave till later]. There were around four questions. A message was displayed at the end that said there were two files that needed to be merged by hand. Namely, /var/tmp/temproot/etc/group and /var/tmp/temproot/etc/master.passwd. I am not entirely sure what, if anything, needs to be done about this though.
`make installworld`
`mergemaster` with no arguments. This time the mergemaster script asks a lot of questions (roughly 30 or so, perhaps more). Again, I just accepted the default answers [Leave till later] for everything, simply pressed Enter to continue.
`make delete-old` Again asks if you wish to delete certain files. Each is listed in turn and I entered 'y' to each question. Most questions related to the Clang compiler and there were around 20 files to delete. However, at the end you are told to input `make delete-old-libs`. At this stage you should *not* do this until your existing ports have been rebuilt.
Reboot the system into normal mode.
`cd /usr/ports/ports-mgmt/portmaster` and build it, if it's not already installed.
`cd /usr/src` and then `portmaster -a -f` which rebuilds all ports.
Finally `make delete-old-libs`

That completed the steps that I was not sure about, though my next task is to install the X11 Intel driver and X.Org. Hopefully I should not have any difficulty getting that done. However, the only outstanding issues now are really what I need to do about all of the files that were "left till later" by my mergemaster options. I would appreciate if anyone could advise on this.


----------



## jb_fvwm2 (Sep 13, 2013)

I usually leave the 'left til later' as-is, I have 2004-2005-etc. files still around. Once in a long while I'll review the older files for deletion.  Some, however, may present immediate problems if not brought up to the latest revision, but you would know that probably sooner than later due to some system message or other happenstance. (Others may do it differently.)


----------



## kpa (Sep 16, 2013)

neilms said:
			
		

> 8. `mergemaster` with no arguments. This time the mergemaster script asks a lot of questions (roughly 30 or so, perhaps more). Again, I just accepted the default answers [Leave till later] for everything, simply pressed Enter to continue.



If you use the "Leave till later" options you're supposed to update the files you skipped manually after you've finished the update run. This involves going trough all of the files under /var/tmp/temproot and deciding if you want to copy the files from there over the existing files or merging them by manual editing. If you don't update those files you'll end up missing important updates to the configuration files.


----------



## wblock@ (Sep 16, 2013)

This is why I use `mergemaster -Ui`.  It automatically upgrades files that have not been modified.  And again: `mergemaster -p` has never, ever been helpful to me, even the one time it could have been (the addition of the auditdistd user).


----------



## kpa (Sep 16, 2013)

You can set -Ui as the default options if you create a /etc/mergemaster.rc with these lines in it:


```
AUTO_INSTALL=yes
AUTO_UPGRADE=yes
```

Use of -Ui avoids having to inspect files that differ only at the lines with revision control tags but are otherwise the same as the installed files.


----------



## wblock@ (Sep 16, 2013)

It can be set that way, but I prefer to add the options.  That makes certain that it will do the same thing on a new machine that does not yet have a mergemaster.rc file.

Adding IGNORE_FILES='/etc/master.passwd' to /etc/mergemaster.rc can also act as a safety.


----------

