LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
LinkBack Search this Thread
Old 09-02-2005, 07:12 AM   #1
pwaring
Member
 
Registered: Nov 2003
Location: Manchester, England
Posts: 57

Rep: Reputation: 15
Permission denied on /dev/hda1 after chrooting


I've got a copy of uVex installed on a Compact Flash card which is connected to an IDE interface so it appears as the first disk to Linux. At the moment I'm booting off a Damn Small Linux USB key pen but I want to use it to get the uVex installation setup properly so that I can run the machine off that. So far I've managed to mount the flash card and chroot into it without any problems using the following commands:

Code:
mount /mnt/hda1
chroot /mnt/hda1 /usr/bin/env HOME=/root /bin/bash
However, when I try to run lilo -v I get the following error echoed to the console:

Code:
Reading boot sector from /dev/hda1
Fatal: open /dev/hda1: Permission denied
I'm running this as root though, so how on earth can I get a permission denied error? Just to make doubly sure I ran ls -l /dev/ | grep hda and the permissions showed up as:

Code:
brw-r---- root root /dev/hda1
(same for all the other hda partitions). The permissions on /dev/ are set to allow root read/write access as well, and the compact flash partition is mounted as rw so I don't think that's the problem either.

Can anyone think of a reason why I might be getting this error? My best guess is that it has something to do with me being in a chroot but I don't know for sure.
 
Old 09-02-2005, 08:17 AM   #2
Emerson
Senior Member
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~
Posts: 3,023

Rep: Reputation: Disabled
Re: Permission denied on /dev/hda1 after chrooting

Quote:
Originally posted by pwaring
Can anyone think of a reason why I might be getting this error? My best guess is that it has something to do with me being in a chroot but I don't know for sure.
I'm not familiar with the H/W used to connect a flashcard to IDE. Maybe the OS is just unable to write the boot sector using your current hardware? (Also, I remember a friend of mine had a virus in his W95 box which marked entire partition table read-only - don't know about HDD access in depth but things like that seem to be possible.)
 
Old 09-02-2005, 08:20 AM   #3
pwaring
Member
 
Registered: Nov 2003
Location: Manchester, England
Posts: 57

Original Poster
Rep: Reputation: 15
I can't see any reason why it wouldn't be able to write to the boot sector - the flash card is on a normal IDE interface so it should just be treated like a hard disk from the kernel's point of view (at least that's how it came up when I copied the initial data onto it).

It's definitely not a virus - this is a brand new CF card, only bought two days ago and it's only been used on Linux machines for specific purposes.
 
Old 09-02-2005, 08:46 AM   #4
Emerson
Senior Member
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~
Posts: 3,023

Rep: Reputation: Disabled
Well, in situation like that best I can recommend is to try if some other utility can write the sector in question. Could you try reading the boot sector to a file and writing it back with dd?
 
Old 09-02-2005, 08:49 AM   #5
pwaring
Member
 
Registered: Nov 2003
Location: Manchester, England
Posts: 57

Original Poster
Rep: Reputation: 15
How would I actually do that? Things like 'cat /dev/hda' also fail with a permission denied error.
 
Old 09-02-2005, 09:16 AM   #6
Emerson
Senior Member
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~
Posts: 3,023

Rep: Reputation: Disabled
Do not chroot or mount it.

read it:

# dd if=/dev/hda of=/path/mbr-backup bs=512 count=1

and write back with:

# dd if=/path/mbr-backup of=/dev/hda bs=512 count=1
 
Old 09-02-2005, 09:29 AM   #7
pwaring
Member
 
Registered: Nov 2003
Location: Manchester, England
Posts: 57

Original Poster
Rep: Reputation: 15
That worked without any errors, but when I mounted and chrooted again I still couldn't access /dev/hda.
 
Old 09-02-2005, 09:36 AM   #8
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 112Reputation: 112
I do have quite a few distros in the box and have to chroot to replicate their boot loaders when moving them around between hard disks.

My guess is the distro from which you chroot to or the one after you chroot to may not have been put together to do such things. Small distributions are made small by dropping out a lot of functionality.

Try a larger distro like the current Knoppix, Mepis or Slax.
 
Old 09-02-2005, 09:41 AM   #9
Emerson
Senior Member
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~
Posts: 3,023

Rep: Reputation: Disabled
It shows there is no H/W restriction. Good. Are you sure you mounted it in rw mode? How it responds to 'mount | grep hda' ?
 
Old 09-02-2005, 10:36 AM   #10
pwaring
Member
 
Registered: Nov 2003
Location: Manchester, England
Posts: 57

Original Poster
Rep: Reputation: 15
Quote:
My guess is the distro from which you chroot to or the one after you chroot to may not have been put together to do such things. Small distributions are made small by dropping out a lot of functionality.
The distro is specifically for compact flash readers, that's the whole point. I don't want to use a big distro because the card only has 1Gb of space (and most of that is going to be used for data - I'm unlikely to have more than 128Mb for the O/S).

Quote:
Originally posted by Emerson
It shows there is no H/W restriction. Good. Are you sure you mounted it in rw mode? How it responds to 'mount | grep hda' ?
Code:
/dev/hda1 on /mnt/hda1 type ext2 (rw,nosuid,nodev)
I'm guessing that nodev part might have something to do with it?
 
Old 09-02-2005, 10:49 AM   #11
Emerson
Senior Member
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~
Posts: 3,023

Rep: Reputation: Disabled
Yes, I believe it restricts the usage of dev files. Too lazy to look it up.

Edit: Looked it up. Definitely this is the problem. Dev files from a nodev mounted partition cannot be used, and this is what you wanted (had to) to do after chroot. I wonder where it (nodev) comes from. Is it in your fstab?

Last edited by Emerson; 09-02-2005 at 11:13 AM.
 
Old 09-05-2005, 03:53 AM   #12
pwaring
Member
 
Registered: Nov 2003
Location: Manchester, England
Posts: 57

Original Poster
Rep: Reputation: 15
nodev isn't anywhere to be found in /etc/fstab on the Damn Small Linux USB key, the relevant lines that I can find are:

Code:
# Added by KNOPPIX
/dev/hda1 /mnt/hda1 ext2 noauto,users,exec 0 0
# Added by KNOPPIX
/dev/hda2 /mnt/hda2 ext2 noauto,users,exec 0 0
So I don't know where the nodev stuff is coming from, unless you can somehow say "nodev is the default unless I say otherwise" (but I wouldn't have thought so, because you'd at least need it for the root partition).

Edit: Ah, apparently the users option implies nodev (and noexec/nosuid).

Last edited by pwaring; 09-05-2005 at 04:38 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
/dev/null: Permission denied phoenix7 Linux - Distributions 1 10-01-2005 06:31 PM
ln: creating symbolic link `/dev/dvd' to `/dev/hdc': Permission denied qazwsx27 Fedora 3 06-14-2005 02:09 PM
/dev/null: Permission denied LavaDevil94 Linux - Software 2 09-14-2004 11:44 PM
/dev/hda1 write permission....? chunlee Linux - Newbie 13 07-08-2004 10:37 PM
/dev/dsp: Permission denied jtX Slackware 1 02-06-2004 05:39 PM


All times are GMT -5. The time now is 02:45 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration