# Help!! cannot boot in system after adding ahci



## benpptung (Dec 29, 2010)

Sorry for my poor English, and I am a newbie in FreeBSD.

Today, I've followed the ahci(4) web page to load the driver as a module at boot time in /boot/loader.conf, and I am sure the ahci is enabled in BIOS.

However, after reboot, I got an ERROR!! The system prompt:


```
uhub2: 6 ports with 6 removable, self powered
uhub6: 6 ports with 6 removable, self powered
Trying to mount root form ufs:/dev/ad4s1a

ROOT MOUNT ERROR:
If you have invalid mount options, reboot, and first try the following from the loader prompt:

set vfs.root.mountfrom.options=rw
and the remove invalid mount options from /etc/fstab.

Loader variables:
vfs.root.mountfrom=ufs:/dev/da0s3a
vfs.root.mountform.options=rw

....
mountroot>
```
I cannot key-in any letter after mountroot>, 

I cannot boot system, and have tried the safe mode, single user mode and disabled with ACPI. Mostly, the system failed to boot, and just reboot, or stuck in booting.

How can I boot in the system to edit /boot/loader.conf to remove the following line?


```
ahci_load="YES"
```

Please help! Thank you for any help!


----------



## tingo (Dec 29, 2010)

You should look at your dmesg output and figure out what your disk(s) are detected as under ahci. The part you have shown us shows that the disk probably was ad4s1a before, but the loader variables says da0s3a. When you have figured out what your disk is named when you are using ahci, you can mount it manually at the mountroot> prompt. This will let you boot in single mode, and from there you can fix things.


----------



## lme@ (Dec 29, 2010)

In the beastie menu select "Escape to loader prompt". Then enter

```
unload ahci
disable-module ahci
boot
```

Then your system is booted without the ahci module. If I made an error in the above commands, you can use "help" to display the valid commands of the boot prompt.


----------



## benpptung (Dec 29, 2010)

lme@ said:
			
		

> In the beastie menu select "Escape to loader prompt". Then enter
> 
> ```
> unload ahci
> ...



Thanks, but while the booting messages coming to the following message


```
ACPI APIC Table ...
```
The screen show messages like a TV have no correct signals, and after around 10 seconds,
the screen stuck on the following messages.


```
trap 12: page fault while in kernel mode
cpuid=0; apic id=00
fault virtual address = 0x10
fault code            = supervisor read data,page not present
instruction pointer   = 0x20:0xffffffff00595e68
stack pointer         = ....
frame pointer         = ....
code segment          = ....
                      = DPL 0, pres....
processor eflags      = resume, ...
current process       = 0 ()
trap number           = 12
panic: page fault
...
```

I still cannot boot into the system, even access the shell...x(


----------



## benpptung (Dec 29, 2010)

tingo said:
			
		

> You should look at your dmesg output and figure out what your disk(s) are detected as under ahci. The part you have shown us shows that the disk probably was ad4s1a before, but the loader variables says da0s3a. When you have figured out what your disk is named when you are using ahci, you can mount it manually at the mountroot> prompt. This will let you boot in single mode, and from there you can fix things.



while the screen come to the mountroot> prompt, 
the keyboard doesn't work, the screen has no any response for keyboard.

I've organized the responses under different boot mode in the following:


> *default boot :* sometimes show the mount error I mentioned above,
> sometimes, the booting come the the message --- "ACPI APIC Table...", then
> the screen looks like a TV has unreliable signals....and then reboot again.
> 
> ...


----------



## tingo (Dec 29, 2010)

Check to see if your machine has the latest BIOS update, if not - update the BIOS.


----------



## benpptung (Dec 29, 2010)

tingo said:
			
		

> Check to see if your machine has the latest BIOS update, if not - update the BIOS.



Thank you, but is there any easier way to boot into the system to edit the /boot/loader.conf ? Because before that, the system going fine, and I have a lot of data on this system.

Should I download the 

```
FreeBSD-8.1-RELEASE-amd64-bootonly.iso
```
to make a usb drive, then boot into the system? Or any other way to boot into the system?


----------



## wblock@ (Dec 29, 2010)

benpptung said:
			
		

> Thank you, but is there any easier way to boot into the system to edit the /boot/loader.conf ? Because before that, the system going fine, and I have a lot of data on this system.
> 
> Should I download the
> 
> to make a usb drive, then boot into the system? Or any other way to boot into the system?



Download FreeBSD-8.2-RC1-i386-livefs.iso or FreeBSD-8.2-RC1-i386-memstick.img.  The second comes up in the installer, but you can run a shell, probably the same with the first.  This will let you mount your drive.

It sounds like you're having more than one problem, possibly hardware problems.


----------



## danbi (Dec 29, 2010)

This usually happens if you have USB-only keyboard. If you are lucky to have PS/2 port on the motherboard, you may try using non-USB keyboard. If not -- you need aomething that will boot past the mountroot prompt.


----------



## benpptung (Dec 29, 2010)

Thank you, I'll download the iso file, and try to boot into the system.
(I made a big mistake, I shouldn't use this system to try ahci module)

After repeated boot mode trials, I've noticed the following phenomenon:

Mostly, the system booting messages show up quickly as usual in the beginning, but always stuck on the message for a while


```
ACPI APIC Table: <INTEL S3200SHC>
```

, then the screen become like a TV which has no reliable signal for around 10-20 seconds. 

Then, it might auto-reboot or 
when I tried [Escape to loader prompt], and the following commands:

```
unload ahci or skip this
disable-module ahci
boot or boot -s
```

The system will play like above mentioned, and till the end stuck on the following messages:

```
Fatal trap 12: page fault while in kernel mode
cpuid=0; apic id=00

fault virtual address    = 0x10
fault code               = supervisor read data,page not present
instruction pointer      = 0x20:0xffffffff00595e68
stack pointer            = ....
frame pointer            = ....
code segment             = ....
                         = DPL 0, pres....
processor eflags = resume, ...
current process = 0 ()
trap number = 12
panic: page fault
```

It looks like something cause ACPI work unreliable.
Is there any variable I can set in loader prompt to disable ACPI?


----------



## benpptung (Dec 29, 2010)

wblock said:
			
		

> Download FreeBSD-8.2-RC1-i386-livefs.iso or FreeBSD-8.2-RC1-i386-memstick.img.  The second comes up in the installer, but you can run a shell, probably the same with the first.  This will let you mount your drive.
> 
> It sounds like you're having more than one problem, possibly hardware problems.



Hi..Thank you, can I use FreeBSD-8.1-RELEASE-amd64-memstick.img ? (Because I have one now)
Also, how can I access the shell when the installer comes up?
And how can I mount the drive back in the shell?

Thank you for your kindly advices.


----------



## wblock@ (Dec 29, 2010)

benpptung said:
			
		

> Hi..Thank you, can I use FreeBSD-8.1-RELEASE-amd64-memstick.img ? (Because I have one now)



Yes.



> Also, how can I access the shell when the installer comes up?



Boot the livefs CD, choose your country, choose Fixit, choose CDROM/DVD.  Memstick may be more of a hassle due to USB.



> And how can I mount the drive back in the shell?



Depends on the drive number, slice, and partitions.  To mount the *a* partition on the first slice of the *ad0* drive (that would be / on many systems):
`# mount /dev/ad0s1a /mnt`


----------



## benpptung (Dec 29, 2010)

It works!! 

Thank you for teaching me the Fixit mode. When I am in the Fixit mode shell, I remove the line in the /boot/loader.conf, the server get back to normal after reboot immediately.


```
ahci_load="YES"
```

I still don't know why I failed to add the 
	
	



```
ahci_load="YES"
```
 but I can use other server to try it now and keep my data back.

Thank you very much, you save my life.


----------



## danbi (Dec 30, 2010)

You would have avoided this mishap, if you used filesystem labels. Now that you have the memstick to boot and recover, you may try this:

boot off the memstick and label your file systems, like this:

`# tunefs -L root /dev/ad4s1a`
`# tunefs -L tmp /dev/ad4s1e`
`# tunefs -L usr /dev/ad4s1f`
`# tunefs -L var /dev/ad4s1d`

Then in your /etc/fstab instead of /dev/ad4s1a for /, specify /dev/ufs/root and do so for other filesystems. You may want to save a copy of your original /etc/fstab in case you confuse things and want to go back.

With file system labels, it will not matter if your controller/drives renames the device or if you plug it in another port on the motherboard etc.

An alternative is to use GEOM labels, and label the entire decice with glabel -- you may name ad4 like 'drive1' and refer to the root partition as /dev/label/drive1s1a -- glabel stores its data on the last sector of the original provider (the original device "name") so using it on existing filesystems may result in you losing the label, of you happen to fill up the disk. But for newly partitioned disks it's good idea. You may use glabel to label the individual partitions as well, such as labeling /dev/ad4s1a as 'root' to become /dev/label/root etc.

Another way to label partitions is with gpart.


----------



## benpptung (Dec 30, 2010)

danbi said:
			
		

> With file system labels, it will not matter if your controller/drives renames the device or if you plug it in another port on the motherboard etc.



Hi..Thank you for teaching me this. I also have found this article Moving A FreeBSD System To AHCI And Labeled Filesystems, so I have couple questions regarding AHCI:

1. How to proceed ? 
Since if I add ahci_load into /boot/loader.conf, I won't have opportunity to reboot into the system again to label the file system. So, should I do the file system label first, and edit the /boot/loader.conf before I reboot? Or edit the /boot/loader.conf first, reboot, then use memstick Fixit mode to label file system?

2. Another minor question. Does motherboard AHCI enabled without AHCI module get me some performance gain? and with AHCI module will get more on top of it? Because previously while I was using Redhat, I've noticed M/B AHCI enabled will increase Disk performance a lot even there is no AHCI driver...which made me thinking AHCI module will get me more.


----------



## wblock@ (Dec 30, 2010)

benpptung said:
			
		

> Hi..Thank you for teaching me this. I also have found this article Moving A FreeBSD System To AHCI And Labeled Filesystems, so I have couple questions regarding AHCI:
> 
> 1. How to proceed ?
> Since if I add ahci_load into /boot/loader.conf, I won't have opportunity to reboot into the system again to label the file system. So, should I do the file system label first, and edit the /boot/loader.conf before I reboot? Or edit the /boot/loader.conf first, reboot, then use memstick Fixit mode to label file system?



Boot into single-user mode as the article shows and label your filesystems.  That does not require AHCI.  Reboot and make sure the labels show up in /dev/ufs/, then modify your /etc/fstab to match.  Reboot again to test that.  Then you can try loading the AHCI module again.



> 2. Another minor question. Does motherboard AHCI enabled without AHCI module get me some performance gain? and with AHCI module will get more on top of it? Because previously while I was using Redhat, I've noticed M/B AHCI enabled will increase Disk performance a lot even there is no AHCI driver...which made me thinking AHCI module will get me more.



AHCI enabled in BIOS plus ahci drivers in FreeBSD gains some performance, but it's not huge, something like 5 to 15%.  I wouldn't expect any increase with just BIOS AHCI mode, but some benchmarking would tell for sure.


----------



## benpptung (Dec 31, 2010)

wblock said:
			
		

> Boot into single-user mode as the article shows and label your filesystems.



Hi!! It works!! Thank you guys for teaching the fs labeling skill!! I can now add ahci module into /boot/loader.conf now.

I've just tried the file system labeling in a single-user mode. After reboot, it is weired that there is no any label under /dev/ufs or /dev/label, they were exist in the single-user mode.

But, I still edit the /etc/fstab according to the customized labels I made in single-user mode, and then reboot to edit /boot/loader.conf, and now the server is added ahci module successful.

I guess I misunderstood your article, the labels won't appear under /dev/ufs after reboot, unless I edit the /etc/fstab and reboot again. Am I right?

Sorry, one last question, I have another box, which is running gmirror. Do I need to made the file system labeling like followings:

```
# tunefs -L rootfs /dev/mirror/gm0s1a
...
```

or just add ahci module into /boot/loader.conf, because gmirror is a kind of file system labeling, I don't need to add another label?

Anyway, I've tested ahci module in the another gmirroring box, which loads ahci module without changing fs label. I've got the following results for sharing.



> the original box (the one which has no gmirror 160G) : apparent some disk performance gain.
> 
> the another box (with gmirror for two 500G drives) : seems no disk performance gain.



Thanks for you all help in solving the ahci module load.


----------



## wblock@ (Dec 31, 2010)

benpptung said:
			
		

> I guess I misunderstood your article, the labels won't appear under /dev/ufs after reboot, unless I edit the /etc/fstab and reboot again. Am I right?



The labels should appear in /dev/ufs/ or /dev/label/ whenever a labeled disk is attached.  At least they do here, on 8-stable.



> Sorry, one last question, I have another box, which is running gmirror.  Do I need to made the file system labeling like followings:
> 
> ```
> # tunefs -L rootfs /dev/mirror/gm0s1a
> ...



I have not used gmirror, but think the filesystem label could still be useful.


----------



## danbi (Jan 3, 2011)

You may still use file system labels with gmirror. In any case, the gmirror itself is a label (simplified). This means that, if you use gmirror, your 'device name' gm0 (or rather, the GEOM provider name) will not change, even if you use AHCI, connect drives to other ports etc.

One particular trouble with using labels of any kind is that, without labels, if you have say ad4 in your system and connect another drive, that may show up as ad6. If you have an glabel of 'drive1' and connect another drive, labeled 'drive1' strange things may/will happen. Same for filesystem labels etc. Even weirder things might happen if you have an gmirror gm0 and connect a drive that used to be part of an gmirror named gm0 

GEOM labels are very powerful thing but sort of break the traditional way of addressing devices. Of course, devices will be visible via their original device names as well.


----------



## benpptung (Jan 4, 2011)

danbi said:
			
		

> You may still use file system labels with gmirror. In any case, the gmirror itself is a label (simplified). This means that, if you use gmirror, your 'device name' gm0 (or rather, the GEOM provider name) will not change, even if you use AHCI, connect drives to other ports etc.



Hi..Danbi, thank you for your sharing. In fact, I would also thank the thread: Creating RAID1 on Intel S5520HCR(S5520HC), because your suggestions, they save me a lot of time and trouble to fight with the M/B embeded RAID, and therefore, I choose gmirror(load algorithm).

The question here is, while I added ahci module, the gmirror box seems not get any better disk performance as I mentioned in my previous post, so I am wondering if I should add ahci module in the gmirror-ed box, or what I can do else.( or my test is not practical enough, I only read/write a 3.5G file between two boxes to compare their speed. It's not a real world enough.)


----------



## mav@ (Jan 4, 2011)

gmirror with load algorithm spreads read requests between all available drives. On parallel load it proportionally increases performance. But it also means that each disk receives twice less requests then without it. Respectively effect of NCQ indeed may become slightly less noticeable, unless you have reasonable I/O parallelism. Your test is probably too simple to use all scalability of this configuration.


----------



## benpptung (Jan 5, 2011)

mav@ said:
			
		

> gmirror with load algorithm spreads read requests between all available drives. On parallel load it proportionally increases performance. But it also means that each disk receives twice less requests then without it. Respectively effect of NCQ indeed may become slightly less noticeable, unless you have reasonable I/O parallelism. Your test is probably too simple to use all scalability of this configuration.



YA..  I know my test is too simple. Thank you for your explanation.:e


----------

