Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
/usr on a separate partition
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
petermiller
n00b
n00b


Joined: 24 Jul 2004
Posts: 10
Location: Germany

PostPosted: Sat Jul 24, 2004 9:37 am    Post subject: /usr on a separate partition Reply with quote

Hello!

I moved my /usr directory to a separate partition and experience
annoying problems since then.

> cat /etc/fstab:

...
/dev/hda7 / ext3 noatime 0 1
/dev/hda1 /mnt/a1 ext3 defaults,noatime 0 2
...

lrwxrwxrwx 1 root root 11 Jun 18 15:53 /usr -> /mnt/a1/usr

The content of usr directory is not directly in the root directory of
the /dev/hda1 partition but instead in a /usr directory on it. I
didn't want to have thousands of files in the root directory and
wanted to use the partition for other directories than usr later as
well.

Now the problems I encounter are:

1) Whenever a shell opens I get this error messages:

-/bin/bash: /usr/bin/whoami: not file or directory
-/bin/bash: [: =: unary operator expected

and when logged in as root I don't have /sbin and /usr/sbin in my
$PATH. I think some script in /etc ('profile' reading 'login.defs'?)
tries to find out if it is root who is logging in to set up the right
$PATH but can't access /usr/bin/whoami as this is a broken link:

lrwxrwxrwx 1 root root 16 Jun 18 15:33 /usr/bin/whoami -> ../../bin/whoami

2) Myriads of broken links in /usr, in fact all relative symbolic
links are broken

So my question is: how can I restore these broken links systematically
and are there other issues to consider when moving /usr on a different
partition?

Thanks for any help :)
_________________
-- peter
Back to top
View user's profile Send private message
pmjdebruijn
Guru
Guru


Joined: 24 Jul 2003
Posts: 506
Location: Sittard, The Netherlands

PostPosted: Sat Jul 24, 2004 10:20 am    Post subject: Reply with quote

Well first of all, what you're doing is a very dirty trick! It's also very queer to have a /usr (+data) directory on hda1? Generally that's used a /boot or the likes...

I suggest you get a new improved partitioning scheme :s

But if you insist:
Are you using a hardlink or a softlink? Anyway try them both!
Back to top
View user's profile Send private message
petermiller
n00b
n00b


Joined: 24 Jul 2004
Posts: 10
Location: Germany

PostPosted: Sat Jul 24, 2004 10:34 am    Post subject: Reply with quote

Hello doctor Zoidberg,

It's a symlink. Do you have a good reason to think that switching to a hardlink might solve the problem? I can't repartition the disc, there's also Windows on it and I'm not in the mood to install Gentoo again.

The system seems to work quite OK except for the issues relating to the broken symlinks. Isn't there a tool to correct them?
_________________
-- peter
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54325
Location: 56N 3W

PostPosted: Sat Jul 24, 2004 12:09 pm    Post subject: Reply with quote

petermiller,

You are breaking the filesystem standard. You are on your own if you do that.

Mount you new /usr in same place as the old one, then everything will just work(tm).

Heres my filesystem
Code:
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/hda5              7882560   2608104   4874040  35% /
/dev/hda6             15757248  10147016   4809796  68% /usr
/dev/hda7              1976492    969820    906268  52% /usr/local
/dev/hda8               988212     75708    862304   9% /tmp
/dev/hda9             31506596   6879912  23026212  24% /var
/dev/hda10            97403640  29495476  62960148  32% /home
none                    518752         0    518752   0% /dev/shm
and a snippet from /etc/fstab
Code:
/dev/hda1               /boot           ext2            noauto,noatime          1 1
/dev/hda5               /               ext3            auto,noatime            0 0
/dev/hda6               /usr            ext3            auto                    0 0
/dev/hda7               /usr/local      ext3            auto                    0 0
/dev/hda8               /tmp            ext3            auto                    0 0
/dev/hda9               /var            ext3            auto                    0 0
/dev/hda10              /home           ext3            auto                    0 0
/dev/hda2               none            swap            sw                      0 0

_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
petermiller
n00b
n00b


Joined: 24 Jul 2004
Posts: 10
Location: Germany

PostPosted: Sat Jul 24, 2004 12:30 pm    Post subject: Reply with quote

Hi NeddySeagoon

Very nice advice... but useless for me.

This Gentoo installation in question is a clone of a Gentoo installation from my notebook. I tar-ed everything (except /dev and directories like this) on my notebook and untar-ed it on my PC. Since there wasn't enough space on my / partition I had to move /usr to a different partition.

I'm probably looking for a shell script that is at least able to go through /usr tree and list all broken links.

> You are breaking the filesystem standard.

In what exactly am I breaking the standard? You have /usr on a different partition too.
_________________
-- peter
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54325
Location: 56N 3W

PostPosted: Sat Jul 24, 2004 12:43 pm    Post subject: Reply with quote

petermiller,

You have /usr on /mnt/a1 with a symbolic link from /usr to /mnt/a1. That breaks the standard.

I could have /usr on a sperate drive, say /dev/hdd someplace or even as an NFS mount to somewhere on the other side of the world. It would still just work.

*NIX stye filesyesms navigate their way around one huge tree, the underlying physical structure doesn't matter. When you move things around (and tar is fine provided you preserved permissions and so on) it all works in its new home providing you put the bits back together on the right filesystems. The finishing touch is /etc/fstab, which sticks it all together at power up.

I don't understand why you can't
Code:
mount /dev/hda1 /usr
which is what your symbolic link is trying to do.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
petermiller
n00b
n00b


Joined: 24 Jul 2004
Posts: 10
Location: Germany

PostPosted: Sat Jul 24, 2004 1:04 pm    Post subject: Reply with quote

>I don't understand why you can't
> Code:
> mount /dev/hda1 /usr
>which is what your symbolic link is trying to do.

Because I think this way I would end up with /usr/usr/* unless I can
'mount /dev/hda1/usr /usr'

I didn't want to copy /usr into the directory tree root on /dev/hda1 - I'd like to use /dev/hda1 for other directories than usr later too.

If nothing helps I'll follow your advice and move the contents of usr on /dev/hda1 one directory up (to the /dev/hda1 directory tree root) and 'mount /dev/hda1/ /usr' without the symlink.

Thanks!
_________________
-- peter
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54325
Location: 56N 3W

PostPosted: Sat Jul 24, 2004 1:42 pm    Post subject: Reply with quote

petermiller,

I understand a little better. When you tarred up /usr, you included the /usr in all the path names so that now /mnt/a1 contains the single directory /usr.
As you say, that would give you /usr/usr if you did my mount suggestion. You cannot do /mnt/dev/hda1/usr /usr which is what you rightly say you need, at least not directly.
However, you can mount things several times. I'll refer you to man mount for the detail. Heres what to do.
Keep your mount /dev/hda1 /mnt/a1, which gets you /mnt/a1/usr, now issue a
Code:
mount --bind /mnt/a1/usr /usr
(that --bind may need to be --rbind, I'm not sure)
This should get you your /usr in the right place by mounting it twice. Once so you can see it to mount it again where you want it.

to automate this isn't easy, since you need to mount /usr at the same time as everything else. Putting it into /etc/conf.d/local.start is too late. I don't know how you could add it to /etc/fstab but it may be posible. (man mount)
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Anime_Fan
Guru
Guru


Joined: 01 Jul 2003
Posts: 366
Location: Linköping, Sweden

PostPosted: Sat Jul 24, 2004 2:15 pm    Post subject: Reply with quote

Hmmm

Couldn't he also do this?

Code:
cd /mnt/a1/usr
mv * ..
cd ..
rmdir usr


And yes, mount --bind is possible to have in your fstab...

I use it to make managing the FTP somewhat better for users with "special needs".

Code:
/mnt/files_disk_4_part_5 /home/noob/files none bind


So that would be:
Code:
/mnt/a1/usr /usr none bind


Be sure to have it after you mount /mnt/a1 ;)

Edit: To be on the safe side, you'd better not have /usr as a symlink if you mount --bind.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54325
Location: 56N 3W

PostPosted: Sat Jul 24, 2004 2:27 pm    Post subject: Reply with quote

Anime_Fan,

That would make life a hell of a lot easier but one of the posts suggeted that it was not desired.

When mount --bind is run /usr is still going to be a symlink, (if its mounted at all) otherwise you wouldn't need to run mount --bind in the first place. Whats the problem?
The mount command is in /bin
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
petermiller
n00b
n00b


Joined: 24 Jul 2004
Posts: 10
Location: Germany

PostPosted: Sat Jul 24, 2004 2:28 pm    Post subject: Solved! Reply with quote

NeddySeagoon & Anime_Fan, your suggestions were just what I needed! :) Thanks folks! :D

>Couldn't he also do this?
>
>Code:
>cd /mnt/a1/usr
>mv * ..
>cd ..
>rmdir usr

Yes, I was considering doing this in my previous post but I didn't want to have hundreds of files directly in /mnt/a1/. Mount --rebind is much better for me (hope it can be put into fstab as you say, Anime_Fan).
_________________
-- peter
Back to top
View user's profile Send private message
Anime_Fan
Guru
Guru


Joined: 01 Jul 2003
Posts: 366
Location: Linköping, Sweden

PostPosted: Sat Jul 24, 2004 2:53 pm    Post subject: Reply with quote

NeddySeagoon wrote:
When mount --bind is run /usr is still going to be a symlink, (if its mounted at all) otherwise you wouldn't need to run mount --bind in the first place. Whats the problem?
The mount command is in /bin


mount --bind won't produce a hardlink, nor will it produce a softlink.
It will provide a normal mount in two separate locations.

However, it is not desired to do this, as it has some drawbacks (one of them being df reporting free space double, etc). It is better than not being able to use your /usr, however.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54325
Location: 56N 3W

PostPosted: Sat Jul 24, 2004 2:58 pm    Post subject: Reply with quote

Anime_Fan,

Mmm, I had at the back of my mind that /mnt/a1 would just be forgotten about. df will report the same free space in two different places in the filesystem, rather than twice the free space.
As Douglas Adams said, its mostly harmless.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum