LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   can I mount directory? (https://www.linuxquestions.org/questions/linux-newbie-8/can-i-mount-directory-702976/)

m_kane 02-07-2009 12:13 PM

can I mount directory?
 
Hi,

I have 30gb ssd disk and 500gb hard disk.
I want to use ssd disk as my system disk, and hard disk as all other.
I want to keep ssd disk use as little as possible

I want to mount:
- swap partition to hard disk
- /home directory to hard disk
- /var directory to hard disk
- /tmp directory to hard disk
- /data directory to hard disk

Do I really have to make partition for each mount to my hard disk eg:

/dev/sdb1 - swap
/dev/sdb2 - /home
/dev/sdb3 - /var
and so on...
Or is there a way to mount those directories to matching directories on hd?
So that I could make one partition and mount all those directories to corresponding directories on hd partition? This would be much better choice for disk space usage, as I should not need to define space for home directory, var directory and tmp directory separately.

tokico 02-07-2009 12:25 PM

No, you cannot mount a directory.

But you can do the following:

Imagine SSD disk is /dev/hda
and hard disk is /dev/hdb

You can mount SSD disk like this:

/dev/hda - /

And the 500gb hd like this:

/dev/sdb1 - swap
/dev/sdb2 - /home
/dev/sdb3 - /var
/dev/sdb4 (extended)
/dev/sdb5 - /tmp
/dev/sdb6 - /data

About the hard drive space, you can use tools like Gparted to resize the partitions, so that's not really a problem.

Hope it helped

m_kane 02-07-2009 12:40 PM

Yes, this is what I imagined.

Only problem is, that I must split hd to partitions, and i don't know how much space eg /var will take as time goes by..

If I could only make one partition, I could use all space as effective as possible, because all mounts would stay on same partition / space.

Now I must decide (for example) that I assing 100gt to /home partition, and 50gt to /var partition, and changing that afterwards is difficult.

digerati1338 02-07-2009 12:47 PM

You do not have to use separate partitions.

First install everything to the ssd disk. Also format the hdd as ext3 (or your preferred filesystem), but leave it empty for now.

I think you will have to do this from a live distro to avoid moving files that are in use.

Create a directory on the empty hdd called home. Now copy everything from the original home to the home directory on the new hard disk. Now delete your original home directory and then create a softlink to the new home directory (as root). Something like this if hdb1 is your hard disk:
Code:

ln -s /media/hdb1/home /home
I'm not sure if you'll run into problems here because this is on a live distro, but I think that softlink should work on the actual installed linux. Somebody correct me if I'm wrong.

That creates a pointer that will keep everything working the way it is supposed to because you didn't change any file paths, just moved things around on the disks. You should be able to repeat this procedure for other directories such as /var and /tmp etc.

m_kane 02-07-2009 01:21 PM

This sounds great, I will try it when my ssd arrives!

BCarey 02-07-2009 03:41 PM

You also might want to look into lvm. This allows for quick resizing of partitions.

Brian

AceofSpades19 02-07-2009 03:44 PM

Quote:

Originally Posted by digerati1338 (Post 3435387)
You do not have to use separate partitions.

First install everything to the ssd disk. Also format the hdd as ext3 (or your preferred filesystem), but leave it empty for now.

I think you will have to do this from a live distro to avoid moving files that are in use.

Create a directory on the empty hdd called [b]home[b]. Now copy everything from the original home to the home directory on the new hard disk. Now delete your original home directory and then create a softlink to the new home directory (as root). Something like this if hdb1 is your hard disk:
Code:

ln -s /media/hdb1/home /home
I'm not sure if you'll run into problems here because this is on a live distro, but I think that softlink should work on the actual installed linux. Somebody correct me if I'm wrong.

That creates a pointer that will keep everything working the way it is supposed to because you didn't change any file paths, just moved things around on the disks. You should be able to repeat this procedure for other directories such as /var and /tmp etc.

You would probably want ext2 for a ssd

palisetty_suman 03-08-2009 09:53 PM

hi
 
yes u can for sure. but i don't know how

edong23 09-27-2009 09:20 PM

i dont know if you got the answer you needed, just stumbled across this post. i think the --bind, --rbind, or --move options will allow you to mount a directory, the problem is i dont know if it will pull the writes from one to the other. seperate partitions are the only way to keep your solid state drive with few writes. use the above commands with caution.


All times are GMT -5. The time now is 06:13 PM.