LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-14-2006, 10:49 PM   #1
greengrocer
Member
 
Registered: Aug 2005
Distribution: Ubuntu Intrepid and Meerkat, formerly used Debian 3.1 (Sarge) with Gnome Desktop
Posts: 353

Rep: Reputation: 37
sudo help required


Hello all,

I am still building this Ubuntu 5.10 (Breezy) computer for a friend.

When I open Xine from the Applications menu in Gnome desktop and play a DVD, the DVD playback is jittery and tends to jump a little.

If I open a Terminal and type in "hdparm -d1 -dma -c1 /dev/dvd", this fixes the problem.

I dont want the end user to have to type this command for two reasons:

1) They shouldnt need to.
2) They need the SU password to do it.

So, I was thinking of doing the following (but it doesnt seem to work)

1) I made the following shell script and placed it in /usr/bin:

sudo -u <username> hdparm -d1 -dma -c1 /dev/dvd
xine

2) I added the following to /etc/sudoers file:

user ALL=(ALL) NOPASSWD: /etc/default/hdparm -d1 -dma -c1 /dev/dvd

3) I edited the menu item in Gnome so that it ran my shell script.


What happens is that xine launches, but the hdparm command does not get executed properly.

If I type "sudo -u <username> hdparm -d1 -dma -c1 /dev/dvd" in the command line I get the following:

setting 32-bit IO_support flag to 1
HDIO_SET_32BIT failed: Permission denied
setting using_dma to 1 (on)
HDIO_SET_DMA failed: Permission denied
HDIO_GET_MULTCOUNT failed: Invalid argument
IO_support = 0 (32-bit)
using_dma = 0 (off)
readahead = 256 (on)


It appears that hdparm is being run with user priviledges but it needs SU priviledges.

I must be doing something wrong, but I cannot work it out ..... I tried

Can somebody point out where I am getting this wrong?

Thanx
Greenie

Last edited by greengrocer; 07-15-2006 at 12:14 AM.
 
Old 07-14-2006, 10:54 PM   #2
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 60
do you need to run this command after every time you open the player to watch a dvd? ie, you run the command to fix the hdparam's, open the player and it works fine. later on you open another player--do you have to run the command again?

if you only have to run the command once, then you could just put 'hdparm -d1 -dma -c1 /dev/dvd' in one of your startup scripts (i think debian-based systems have them in /etc/init.d/ though i may be wrong). check out that folder and add the command. in slackware there is a 'local' script that is used for stuff like this (misc extra commands to run at boot).

hope this helps.
 
Old 07-14-2006, 11:05 PM   #3
rickh
Senior Member
 
Registered: May 2004
Location: Albuquerque, NM USA
Distribution: Debian-Lenny/Sid 32/64 Desktop: Generic AMD64-EVGA 680i Laptop: Generic Intel SIS-AC97
Posts: 4,250

Rep: Reputation: 62
Maybe, put the hdparm command at the end of /etc/hdparm.conf
 
Old 07-14-2006, 11:06 PM   #4
greengrocer
Member
 
Registered: Aug 2005
Distribution: Ubuntu Intrepid and Meerkat, formerly used Debian 3.1 (Sarge) with Gnome Desktop
Posts: 353

Original Poster
Rep: Reputation: 37
Hi nadroj (Jordan???),

Thank you so much for the quick reply,
and you have a good point.

The command need only be run once. Once it is run, Xine will always playback DVD's fine.

So I could put use command "hdparm -d1 -dma -c1 /dev/dvd" at system startup.

I have /etc/init.d/ (init.d is a directory)

Inside /etc/init.d/ are a bunch of files that I dont want to touch with my noobness. So should I just make a shell script with the command inside that directory? And will it run as SU?
 
Old 07-14-2006, 11:10 PM   #5
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 60
yes!

im not sure if those kind of scripts are like the slackware (bsd)-based ones. ie, for slackware, any executable file in the folder is executed at boot.

check out what rickh said as it seems alot more logical and would be the more appropriate place

your welcome
 
Old 07-14-2006, 11:23 PM   #6
greengrocer
Member
 
Registered: Aug 2005
Distribution: Ubuntu Intrepid and Meerkat, formerly used Debian 3.1 (Sarge) with Gnome Desktop
Posts: 353

Original Poster
Rep: Reputation: 37
Hi Rickh,

putting the line: "hpdparm -d1 -dma -c1 /dev/dvd" in /etc/hdparm.conf doesn't solve this issue

I noticed that in my hdparm.conf file, everything exitsing in that file is #'d out.

I added the command to the end of the file and rebooted the system, but output of hdparm /dev/dvd is like this:

IO_support = 0 (default 16-bit)
unmaskirq = 0 (off)
using_dma = 0 (off)
keepsettings = 0 (off)
readonly = 0 (off)
readahead = 256 (on)
HDIO_GETGEO failed: Invalid argument


Regards,
Greenie
 
Old 07-14-2006, 11:27 PM   #7
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 60
running this command with sudo doesnt produce this output, correct?
can you post this file?
 
Old 07-14-2006, 11:28 PM   #8
rickh
Senior Member
 
Registered: May 2004
Location: Albuquerque, NM USA
Distribution: Debian-Lenny/Sid 32/64 Desktop: Generic AMD64-EVGA 680i Laptop: Generic Intel SIS-AC97
Posts: 4,250

Rep: Reputation: 62
That should work. I use it to turn dma off on mine ... a hardware quirk. Maybe hdparm is running before your hardware aliases are fixed ... Try identifying it as /dev/hdc (or whatever the right hd? would be.)

Also, I wonder what "keepsettings=1" would do.

Quote:
putting the line: "hpdparm -d1 -dma -c1 /dev/dvd" in /etc/hdparm.conf doesn't solve this issue
Did you do it per the example:
Code:
command_line {
       hpdparm -d1 -dma -c1 /dev/dvd
}

Last edited by rickh; 07-14-2006 at 11:35 PM.
 
Old 07-14-2006, 11:37 PM   #9
HappyTux
Senior Member
 
Registered: Mar 2003
Location: Nova Scotia, Canada
Distribution: Debian AMD64
Posts: 4,170

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by greengrocer
Hi Rickh,

putting the line: "hpdparm -d1 -dma -c1 /dev/dvd" in /etc/hdparm.conf doesn't solve this issue

I noticed that in my hdparm.conf file, everything exitsing in that file is #'d out.

I added the command to the end of the file and rebooted the system, but output of hdparm /dev/dvd is like this:

IO_support = 0 (default 16-bit)
unmaskirq = 0 (off)
using_dma = 0 (off)
keepsettings = 0 (off)
readonly = 0 (off)
readahead = 256 (on)
HDIO_GETGEO failed: Invalid argument


Regards,
Greenie

Why not try using the actual device that /dev/dvd is linked to like /dev/hdc in the command. BTW where are you getting the idea that -dma is to be used in the line the -d1 you are using turns on the dma it is not even a parameter to be used AFAIK. You may want to try putting it in the file /etc/init.d/bootmisc.sh near the bottom I had to use this once upon a time when the hdparm.conf did not want to work for me.
 
Old 07-14-2006, 11:47 PM   #10
greengrocer
Member
 
Registered: Aug 2005
Distribution: Ubuntu Intrepid and Meerkat, formerly used Debian 3.1 (Sarge) with Gnome Desktop
Posts: 353

Original Poster
Rep: Reputation: 37
I added:

command_line {
hpdparm -d1 -dma -c1 /dev/dvd
}


to the end of /etc/hdparm.conf


Rebooted but no joy


@ HappyTux,

If I type "sudo hdparm -d1 -dma -c1 /dev/dvd" in a terminal and then enter the su password then Xine will playback a DVD flawlessly.

If I don't issue the above command, DVD playback will be all jumpy and jittery.

Thats why I am using that command, it seems to solve the problem. All I need now is for the end user to not have to type that command in each time they want to play a DVD.

I wondered about the -dma switch, I also think that it probably doesnt do anything, and that it is the -d and -c switches that are doing the work here.

Last edited by greengrocer; 07-14-2006 at 11:50 PM.
 
Old 07-14-2006, 11:51 PM   #11
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 60
did you try adding the command to a startup script?
 
Old 07-14-2006, 11:54 PM   #12
rickh
Senior Member
 
Registered: May 2004
Location: Albuquerque, NM USA
Distribution: Debian-Lenny/Sid 32/64 Desktop: Generic AMD64-EVGA 680i Laptop: Generic Intel SIS-AC97
Posts: 4,250

Rep: Reputation: 62
Appears to me that all you need to do is turn on DMA. Mysterious to me why it's turned off by default. Humor me once, and change that coding to:

command_line {
hpdparm -d1 /dev/hdc
}
 
Old 07-15-2006, 12:04 AM   #13
greengrocer
Member
 
Registered: Aug 2005
Distribution: Ubuntu Intrepid and Meerkat, formerly used Debian 3.1 (Sarge) with Gnome Desktop
Posts: 353

Original Poster
Rep: Reputation: 37
HappyTux's suggestion worked.

If I add the line "hdparm -d1 -dma -c1 /dev/dvd" to the file /etc/init.d/bootmisc.sh, above the line ": exit 0" the dma problem is then solved.


@ rickh,

I read somewhere that dma is switched off by default in Ubuntu Breezy. I cannot recall the reason why (if there was a reason at all).


So my immediate DMA problem is solved. I still dont know why my sudoers method did not work. Does anyone know why my sudoers method did not work (theoretically the sudo method should work if it is implemented correctly).
 
Old 07-15-2006, 02:16 AM   #14
Electro
LQ Guru
 
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
The option -dma is incorrect for hdparm. You just need -d1. Depending on the drive, including -k1 and -K1 forces the keep setting optin. It will not hurt anything. You may need to include -X66 to activate DMA-2.

Depending on your boot loader. Add hdX=dma on the kernel or append line of your boot loader config file. X designates the letter of the drive. If your DVD drive is on Secondary Master, it will be hdc. You should recompile the kernel to always enable DMA.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Restricting Editing in Sudo (Advanced Sudo Question) LinuxGeek Linux - Software 4 11-04-2006 03:20 PM
sudo XaViaR Linux - General 6 06-21-2005 06:12 PM
About sudo alnreddy Linux - Security 3 06-13-2005 12:53 PM
need help with sudo mla Linux - Software 4 10-02-2003 11:05 AM
Help with Sudo... verbal Linux - Newbie 3 08-19-2002 11:02 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration