Solved

Change directory assignment

Posted on 2000-04-03
6
237 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

This is the error message I got (CODE) Error caused by incompatible libmp3lame 3.98-2 with ffmpeg I've googled this error message and found out sometimes it attaches this note "can be treated with downgrade libmp3lame to version 3.97 or 3.98" …
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
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.

808 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