Solved

Change directory assignment

Posted on 2000-04-03
6
238 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Fine Tune your automatic Updates for Ubuntu / Debian
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
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.

733 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