Solved

Change directory assignment

Posted on 2000-04-03
6
234 Views
Last Modified: 2013-12-16
I partition my hard disk into several parts. Three of them are for Linux. In the begining, I set up one partition for everythin, eg. /root,/usr,/var,/etc.... And I use another partition to try out new distributions. Now I am satisfied with one distribution, and putting more and more stuff in that partition. Recently, I almost run out of space in that partition. However, I have plentify of space left in another partition, as now I'm not trying out new distributions. How can I move some of the directories to the spare partition? For example, /usr, or /var. That way, I can make full use of all the disk space. It took me quite a while to setup the environment that I like now, so reinstalling the whole system is the last option. I use rpm to install most of the programs, and I don't know how to instruct it to put files in diffrent directories than the ones assigned, which are /usr and /etc  in most of the cases. If there is a way, I would like to know, too.

Thanks!

0
Comment
Question by:pai
  • 3
  • 2
6 Comments
 
LVL 2

Accepted Solution

by:
joe_h earned 100 total points
ID: 2682888
Basically, you copy the entire /usr or /var to the other partition, and tell linux to mount it as /usr or /var during startup. The only thing that will remain on your / partition will be empty directories /usr or /var.

You don't have to change the directories where your programs store files - you'll get exactly the same directory tree as you used to have; the only change is that now it will be physically stored on two separate partitions. Most of your programs won't even notice a change.

I'd recommend doing these changes in single-user mode (say "emergency" to the kernel before booting).

This is the general idea, I'll have to try it myself for detailed instructions.
BTW, there's almost never a need to reinstall Linux :))

HTH, Joe
0
 
LVL 2

Expert Comment

by:fremsley
ID: 2683651
exactly as joe_h described it. if you haven't done such things before, here are the steps (as root, and no hard words if something should go wrong):

  - mount your other partition somewhere (i'll assume /mnt)
  - delete anything on that partiontiom (rm -R /mnt)
  - copy e.g. /usr to the file system (cd /usr; cp -a * /mnt)
  - check if anything is on the new file system
  - rename the old directory (mv /usr /usr.old)
  - re-create /usr (mkdir /usr)
  - unmount partition (umount /mnt)
  - go to single user mode (init S)
  - mount the partition under /usr
  - switch to runlevel 2 or 3 (init 2 or init 3)
  - check whether everything is working
  - if yes, make mounting permanent in /etc/fstab (you may delete /usr.old)
  - if not, you can restore your old /usr by removing /usr and renaming /usr.old

hope this helps a bit

0
 

Author Comment

by:pai
ID: 2688351
The answer looks fine to me. But, I still have a problem. Can I move more than one directory to a partition. The method given can only mount one directory to one partition if I understand right. Besides, I have some data and programs in that partition that I don't want to destroy. How do I do that? I thought about another method myself. It is to copy /var to a directory the second partition. That's say, it is /2nd/var. Then make a symbolic link of /var to /2nd/var. This way, I can put more than one directory over. I tried that, and it worked so far. My question is that will there be any problem in some special situation? Is it a good solution?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 2

Expert Comment

by:joe_h
ID: 2689669
I can't think of a situation where this would be a problem. (Of course, I can't think of all possible situations :) You are right, this method lets you move more than one directory to the other partition, and it is actually used in some cases - e.g. many Linux distributions implement /bin as a link to /usr/bin.

AFAIK, the only thing to keep in mind would be not to move important tools (like mount, sh, vi, etc.), that are usually located in /sbin, to the other partition. You might run into trouble if you ever have a problem mounting the second partition.

Joe
0
 
LVL 2

Expert Comment

by:fremsley
ID: 2689898
joe_h: in which distribution is /bin linked to /usr/bin? that would mean that /usr has to reside on the root partition to avoid problems when booting.
0
 
LVL 2

Expert Comment

by:joe_h
ID: 2690483
Oops, wasn't quite right on this one. It is linked e.g. on Solaris (SunOS 5.7); however, I did not check a Linux box until now - and it's not linked there (at least not on my Mandrake 6.1).
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now