# How to mount a SATA Optical drive



## cpcnw (May 28, 2010)

[MARK SOLVED]


Hi All,

I have a SATA HDD on the first SATA port which shows up as ad4

I have a SATA DVD-RW on the 2nd SATA port

How would I mount this device?

Thanks


----------



## wblock@ (May 28, 2010)

Depends on the device that shows up for the DVD...
Which, in turn, depends on your drivers (ad versus ada) and possibly BIOS settings like SATA devices emulating IDE.

Look for /dev/cd0 or /dev/acd0 for a start.

As for mounting the drive when there's a data CD or DVD loaded:

`# mount -t cd9660 /dev/cd0 /mnt`

Audio CDs aren't mounted: http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/creating-cds.html


----------



## cpcnw (May 28, 2010)

Mmm, as I thought - every single mount device command I have tried doesn't work with 'no such file or directory'

Seem like theres no entry at all in dmesg for the drive and nothing in /dev either


----------



## wblock@ (May 28, 2010)

Well, yes, mount commands aren't going to work unless the device is detected and there's an entry in /dev.

Does the DVD drive have a power connection?
Is the DVD drive detected by the BIOS?
Maybe it's connected to a RAID SATA connector that isn't supported by the current driver.


----------



## cpcnw (May 29, 2010)

Yes, bios sees drive, works in that other os. Its on the SATA port right next to the one that connects to the HDD fbsd boots from [chipset not set as raid inbios]. 

I suspect theres no entry in /dev and 


```
sh MAKEDEV ad
```
 results in 'cant open MAKEDEV: no such file / dir'


----------



## wblock@ (May 29, 2010)

MAKEDEV is obsolete since about FreeBSD 5.0.  Now /dev is populated when the driver detects the hardware.

What brand and model of drive is this?


----------



## cpcnw (May 29, 2010)

Sony AD7240S


----------



## wblock@ (May 29, 2010)

This is mystifying.  There are a few reports on the web of a 7240S drive not being detected, but they sound unrelated.  In case it helps, here's what my SATA DVD with the ahci driver shows in dmesg:


```
cd0 at ahcich7 bus 0 scbus7 target 0 lun 0
cd0: <ATAPI iHAS424   A ZL1B> Removable CD-ROM SCSI-0 device 
cd0: 150.000MB/s transfers (SATA 1.x, UDMA5, ATAPI 12bytes, PIO 8192bytes)
cd0: Attempt to query device size failed: NOT READY, Medium not present - tray closed
```

The only thing I can think of is that like on my motherboard, there may be two SATA controllers, the Intel one, an off-brand extra (mine is JMicron).  The "other" OS may have built-in drivers for the off-brand where FreeBSD does not.  But also, those SATA sockets are a different color.


----------



## cpcnw (May 30, 2010)

Mobo: M2N68-AM
4 Sata: 0=HDD, 1=Sony DVD-RW

[all same colour]

In dmesg theres no entry at all for cd0


----------



## phoenix (May 30, 2010)

Which SATA controller chipset is on that mobo?

Are there any options in the BIOS for AHCI mode?  If there is, set it, and load the ahci(4) driver.  See if it gets detected then.

What's the output of `# pciconf -vl`?  Does it list the Sony device in there?  Is there a driver attached to it, or does it show up as *noneX* (where X is a number)?


----------



## cpcnw (May 30, 2010)

In the BIOS in MAIN > IDE CONFIG > SATA MODE SELECT there are 3 choices SATA/RAID/AHCI

Unfortunately setting this AHCI crashes the boot sequence of 3bsd and BSOD's Win boot up too 

I can however see that in 3bsd the drive is being recognised.

Edit: just thought - if I hardwire ahci into the kernel instead of loader.conf would that help?


----------



## cpcnw (May 30, 2010)

Output of pciconf -vl


```
atapci1@pci0:0:9:0:     class=0x010185 card=0x83081043 chip=0x055010de rev=0xa2 hdr=0x00
vendor     = 'Nvidia Corp'
device     = 'MCP67 SATA Controller(IDE mode) (MCP67)'
class      = mass storage
subclass   = ATA
```


----------



## wblock@ (May 30, 2010)

cpcnw said:
			
		

> In the BIOS in MAIN > IDE CONFIG > SATA MODE SELECT there are 3 choices SATA/RAID/AHCI
> 
> Unfortunately setting this AHCI crashes the boot sequence of 3bsd



Please be more specific about what you mean by that.  Crashes how, and at what point in startup?



> I can however see that in 3bsd the drive is being recognised.



How?  cd0 appears in kernel messages?



> Edit: just thought - if I hardwire ahci into the kernel instead of loader.conf would that help?



Maybe; hard to say without knowing where it's crashing.  I went through this a couple of days ago switching from ata to ada/ahci.  What finally got things moving was a BIOS update.

Of course you also have to edit fstab to reflect the new devices.


----------



## cpcnw (May 30, 2010)

> Please be more specific about what you mean by that. Crashes how, and at what point in startup?

I end up at an unfamiliar prompt. I would have to repeat the exercise and write down where I end up at.

> How? cd0 appears in kernel messages?

Yes

> Of course you also have to edit fstab to reflect the new devices.

Not sure what you mean. HDD is still on same device isn't it?


----------



## wblock@ (May 30, 2010)

cpcnw said:
			
		

> > Of course you also have to edit fstab to reflect the new devices.
> 
> Not sure what you mean. HDD is still on same device isn't it?



No, with ahci, SATA hard drives are ada devices.  So instead of ad0, it's now ada0.


----------



## cpcnw (May 30, 2010)

OK, starting to see the light. After changing to AHCI mode I get most of the way through a kernel load and can see that ahci.ko is being loaded. I end up at ;


```
Trying to mount root from ufs:/dev/ad4s3a
ROOT MOUNT ERROR
```

This is followed by some advice on how to ammend the loader prompt and to edit the fstab

Pressing ? I can list all the valid devices and tried this


```
mountroot> ufs:/dev/ada0s3a
```
This got me a bit further but obvs other devices are misnamed in fstab.

So, I reckon I'm now pretty close [can actually see cd0 listed in device list]

This is my current fstab ;


```
/dev/ad4s3b		none		swap	sw		0	0
/dev/ad4s3a		/		ufs	rw		1	1
/dev/ad4s3e		/tmp		ufs	rw		2	2
/dev/ad4s3f		/usr		ufs	rw		2	2
/dev/ad4s3d		/var		ufs	rw		2	2
/dev/acd0		/cdrom		cd9660	ro,noauto	0	0
/dev/acd1		/cdrom1		cd9660	ro,noauto	0	0
/dev/ad4s1		/mnt/dosc	ntfs	ro
/dev/ad4s5		/mnt/dosd	ntfs	ro
```

Do I jsut replace every 'ad4' with 'ada0' ?


----------



## wblock@ (May 30, 2010)

cpcnw said:
			
		

> mountroot> ufs:/dev/ada0s3a
> 
> This got me a bit further but obvs other devices are misnamed in fstab.
> 
> ...



Yes.  Or go the tunefs -L/glabel method, so the device name and number don't matter.


----------



## cpcnw (May 30, 2010)

> Or go the tunefs -L/glabel method, so the device name and number don't matter.

Sounds like best option [still need to sort xp ahci driver]

Can you give me some pointers on tunefs -L/glabel?


----------



## zeiz (May 30, 2010)

http://ivoras.sharanet.org/blog/tree/2009-11-17.trying-ahci-in-8.0.html
For ZFS only 
	
	



```
# echo 'ahci_load="YES"' >> /boot/loader.conf
```
 was enough.
With Windows installed moving to AHCI requires reinstalling of Windows


----------



## cpcnw (May 30, 2010)

That url is broken. On xp ahci, I have info says otherwise... @worse I need a re-prep in any case.


----------



## wblock@ (May 30, 2010)

cpcnw said:
			
		

> > Or go the tunefs -L/glabel method, so the device name and number don't matter.
> 
> Sounds like best option [still need to sort xp ahci driver]
> 
> Can you give me some pointers on tunefs -L/glabel?



Given that motivation, I got around to writing up my notes on switching to AHCI: http://www.wonkity.com/~wblock/docs/html/ahci.html

Be aware that this doc is not well-tested yet.  Feedback welcome.


----------



## zeiz (May 30, 2010)

My apologies for typo. It works now.
I didn't try with XP but I do reinstalled W7.


----------



## cpcnw (Jun 1, 2010)

Renamed device in fstab and rebooted after changing BIOS setting to AHCI. All now working perfectly!

In XP did a 'Windows Repair' using a USB FDD and the SATA Chipset driver [press F6 at start]


----------



## cpcnw (Jun 10, 2010)

Warren, spoke too soon.... Ive noticed that some things I hadn't tested aren't working for example ;

`cdcontrol -f /dev/cd0 play`

No complaints or errors messages, just no audio or even disc spinning?

Worked perfectly before under SATA mode and acd0 ???

Edit :-

In console get the following ;


```
cdcontrol -f /dev/cdrom play
(cd0:ahcich1:0:0:0): MODE SENSE(10). CDB: 5a 0 e 0 0 0 0 0 20 0 
(cd0:ahcich1:0:0:0): CAM Status: SCSI Status Error
(cd0:ahcich1:0:0:0): SCSI Status: Check Condition
(cd0:ahcich1:0:0:0): ILLEGAL REQUEST asc:24,0
(cd0:ahcich1:0:0:0): Invalid field in CDB: Command byte 2 is invalid
(cd0:ahcich1:0:0:0): Unretryable error
```


----------



## wblock@ (Jun 10, 2010)

cpcnw said:
			
		

> Warren, spoke too soon.... Ive noticed that some things I hadn't tested aren't working for example ;
> 
> cdcontrol -f /dev/cd0 play
> 
> No complaints or errors messages, just no audio or even disc spinning?



Me too.  That's the first time I've tried playing an audio CD with ahci.  There are a few threads that make it look like it's a known problem, although apparently not fixed yet.

Using cdda2wav from sysutils/cdrtools as the example from the man page works:
`# cdda2wav -q -e -t2 -d0 -N`



> ```
> cdcontrol -f /dev/cdrom play
> (cd0:ahcich1:0:0:0): MODE SENSE(10). CDB: 5a 0 e 0 0 0 0 0 20 0
> (cd0:ahcich1:0:0:0): CAM Status: SCSI Status Error
> ...



Can probably be ignored.


----------



## cpcnw (Jun 13, 2010)

Also my audio cd copy script http://forums.freebsd.org/showthread.php?t=1195 is now broken too. Took me ages to get that to work 

Nor cdplay nor mplayer ....


```
cdplay -d /dev/cd0
```
 results in "Invalid argument"


```
$ mplayer -cdrom-device /dev/cd0 cdda://
```
 nothing happens at all ...

Seems nothing likes my ahci attached dvd-drive


----------



## wblock@ (Jul 3, 2010)

wblock said:
			
		

> Me too.  That's the first time I've tried playing an audio CD with ahci.  There are a few threads that make it look like it's a known problem, although apparently not fixed yet.



Err... yeah.  Apparently, the last time I replaced my DVD drive, the new SATA version didn't even have an audio connector.  This would explain most of my problems.  I think there are some compatibility kernel modules that may help with the rest.  For example, atapicam is still needed for cdrecord with the SATA DVD drive.


----------

