How to install Applications on a separate drive

Asked by rbivings

I have a seperate disk drive (Maxtor 120 GB) which i would like to use to install certain applications for ubuntu instead of the File system (C:). The reason being there is only about 6.0 GBs of free space left on the file system and since i would like my computer to run relatively quickly i want to know how to install things onto the maxtor (D:) instead of the file system.

Basically, when i go to the terminal and say (sudo install (blank)) it automatically installs it onto the file system. Is there any way to tell it to install on to the D: drive instead? If not, is there anyway to move the application once installed from the file system to the D: drive??

All help and suggestions appreciated, thanks.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
rbivings
Solved:
Last query:
Last reply:
Revision history for this message
Cesare Tirabassi (norsetto) said :
#1

There is no possibility of choosing your installation destination, as this is dictated by the Unified File Structure to which Ubuntu complies.
Since most of the user's applications will be installed in the /usr directory, you can simply mount your /usr directory on your second drive.
In any case, before deciding if you want to do this for /usr, /home or /var you should check which of these directories is taking up most of the space; in Gnome you can use a tool like Menu->Accessories->Disk Usage Analyser to do this.

--- Note: you must know what you are doing before attempting the instructions here below ---
--- They are meant for an intermediate/advanced user, not for a novice ---
--- If you don't know what you are doing you risk damaging permanently your Ubuntu installation ---

Once decided, in this link you will find explanations on how to add your second drive:

https://help.ubuntu.com/community/InstallingANewHardDrive

Mainly you must use fdisk to partition it and mke2fs to format it and mount to mount it.
Once it is prepared and mounted, you can move your /usr directory with this command:

cd /usr && sudo find . -depth -print0 | sudo cpio --null --sparse -pvd /mnt/

Where you must change /mnt/ with the name of the mount point for the new hard disk.
After which just change your /etc/fstab adding your new /usr mount point. For instance:

/dev/hdb /usr ext3 defaults 0 2

Where /dev/hdb is the device node for your second hard disk (change it as appropriate).

After rebooting you should be set.

Revision history for this message
rbivings (renny) said :
#2

Okay, thank you very much, unfortunately i am a novice to ubuntu, but i did find out that the directory with the most disk usage was /usr.

I have a few more questions if you dont mind:

How do i find out the name of my seperate drive, for instance i hear alot of people referring to it as "hd3" or "hd5" but i cant find the number of mine?

Would you mind giving me a step by step of how to move the /usr file into the seperate drive? if not i understand, it may take a lot of time to explain...

Finally, once i move the /usr directory, will all applications that would have normally installed into the /usr in the file system now install into the seperate drive and run properly without any other adjustments?

Revision history for this message
Cesare Tirabassi (norsetto) said :
#3

>How do i find out the name of my seperate drive

Its in the link I gave you. The command is:

sudo lshw -C disk

>Would you mind giving me a step by step

All the steps are above, you only need to adapt it to your hardware.
Use man to know more about the commands, search with google for examples and especially try to understand them.
If you are afraid to loose your /usr directory make a back-up, like (assuming you have enough space):

sudo mkdir /usr_old
sudo cp -r /usr /usr_old

>Finally, once i move the /usr directory, will all applications that would
>have normally installed into the /usr in the file system now install into
>the seperate drive and run properly without any other adjustments?

If all went well, yes. To all effect THAT is your /usr directory (that is mounted on a different hard disk than the file system root is totally irrelevant to Linux, could also be on an NFS drive somewhere in Antarctica).

Revision history for this message
Cesare Tirabassi (norsetto) said :
#4

There is also another option, if you don't mind reinstalling from scratch.
Once you reinstall, at the partition creation screen, create manually all the partitions. For instance, you can allocate one partition of your new HD to /usr and another to /home (I think its always good to have /home on a different partition anyway) and the old HD for / and the swap.

Revision history for this message
Best rbivings (renny) said :
#5

thank you very much i appreciate all your help