[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Change directory assignment

Posted on 2000-04-03
6
Medium Priority
?
247 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 300 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
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
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…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Suggested Courses

656 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