LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   Seperate Partitions for /usr & /home? (https://www.linuxquestions.org/questions/debian-26/seperate-partitions-for-usr-and-home-304385/)

Jukas 03-21-2005 01:51 PM

Seperate Partitions for /usr & /home?
 
I'm fairly new to linux and I've tried a couple different distro's and I think I've settled on Debian as my prefered one. I did a hdd install from Knoppix 3.7 and I have two hard drives in my system.

The first is a 4gb hdd partitioned to a 3.5b for the system and 500mb for the swap file. The second is a 20gb.

How can I have the /usr and /home directories go to the 20gb partition instead of the 4gb system partition? I think from my reading I would have to change the mount points in the /etc/fstab file but can you tell me if the below syntax would be correct?

/dev/hdb1 /mnt/home ext3 noauto,users,exec 0 0

If not, what would be the correct syntax?

mjuhannus 03-21-2005 02:43 PM

I don't really know if it will work not to mount those directories later on different partitions. Usually you should configure the partitions during the installation. I think fresh install would be best because your /usr/ won't have any files on it if you mount a different partition as /usr/, and you really have lots of important stuff on that directory.

But to be honest I don't really know if it would work to just copy everything from your current /usr/ to the new partition and then mount the new one as /usr/. In this case you'll may have to delete all the files in your current /usr/ because usually the mount dirs have to empty. (As I write this, it begins to sound more and more hazardous, so do a fresh install!)

But anyway your example of fstab line will mount it on /mnt/home/ not to /home/, and atleast in my fstab defaults instead of noauto,users,exec is just fine.

Jukas 03-21-2005 03:02 PM

Quote:

Originally posted by mjuhannus
I think fresh install would be best because your /usr/ won't have any files on it if you mount a different partition as /usr/, and you really have lots of important stuff on that directory.

That would be my first choice, but unfortunately I couldn't find anywhere during the knoppix hdd install to specify which partition to put /usr and /home to. Hence why I think I have to do it post install.

thegeekster 03-21-2005 03:24 PM

There shouldn't be any problems by splitting up the filesystem into separate partitions, I've done it many times in the past without problems................I agree it is a good idea to put the /home directory on its own partition, which is where all the personal data resides, keeping it separate from the system data but, personally, I feel it isn't really necessary to put /usr on a separate partition................I used to in the past 'cause I read it was a good idea, but for the typical home pc, it just isn't necessary.............

That being said, you will need to split up the 20 GB hard drive, one for the /usr and one for the /home partitions....................For the /usr, you shouldn't need a very large one, maybe 4-5 GB, while the /home partition should be as big as you can get.................The reason for a large /home partition is because the user's home directory is where the normal user has unrestricted access, and is the default for storing personal data, music files, etc..........In time, this can get quite large (especially when storing music, videos, pix, etc.).............. :)

For the n00b, cfdisk will work the best to partition the bigger drive.....Run this command:

cfdisk /dev/hdx

Substitute x for the correct letter for the drive (such as b, c, or d), depending on where the drive is installed at, and partition accordingly (you can make them both primary partitions here, and you can read "man cfdisk" for an explanation)..... :)

After partitioning the drive, you may or may not have to reboot..................At the bottom of the cfdisk screen, after using the "Write" option, it may tell you that it couldn't reread the new partition table, which means you have to reboot, and if there was no warning you won't need to reboot.........

Now you can format the partitions.................for ext3 use the command:

mke2fs -j /dev/hdx1

for the first partition and

mke2fs -j /dev/hdx2

for the second partition..........Note: The '-j' switch is important to make it an ext3 instead of ext2.....

Now it's time to mount these to a temporary mount point.............You can make one for each in the /mnt directory like so.....

mkdir /mnt/temp1 && mkdir /mnt/temp2

Then mount the partitions with these commands:

mount /dev/hdx1 /mnt/temp1 -t ext3
mount /dev/hdx2 /mnt/temp2 -t ext3

Now you can copy the files over to the directories, using the 'cp -a' command:

cd /usr && cp -a . /mnt/temp1
cd /home && cp -a . /mnt/temp2

The reason for changing to the directories before copying is to make sure hiddens files will be included.....

Now it's time to enter the appropriate entries into /etc/fstab so they will be mounted automatically at boot time:

/dev/hdx1 /usr ext3 defaults 0 1
/dev/hdx2 /home ext3 defaults 0 1

At this point you are ready to use them...................However you might want to clear the directories first and then mount them, like so

cd /home && rm -rf .
cd /usr && rm -rf .
mount -a

that last command will cause the 'mount' command to reread /etc/fstab and mount any directories that need mounting, if they're not already mounted (such as the two entries you added)........

Don't forget to unmount them from their temporary directories:

umount /mnt/temp*

HTH :)

Jukas 03-21-2005 06:02 PM

Geekster,

Thanks for the reply. The only part I'm not clear on is where you said

Quote:

that last command will cause the 'mount' command to reread /etc/fstab and mount any directories that need mounting, if they're not already mounted (such as the two entries you added)........

Don't forget to unmount them from their temporary directories:

umount /mnt/temp*
If I unmount the temp mount points I made, do I need to create a permanent mount point in fstab and if so what would the syntax look like? If I don't need to create the entry in fstab, how does linux then know where to look for the /home /usr directories after the temporary mount points are removed and it's flushed from system memory (i.e after a reboot)?

Thanks,

Jesse

thegeekster 03-22-2005 12:42 AM

Sorry I took so long to reply, but I had to take my mother to the hospital...

If you followed along, I already showed you the entries to make in /etc/fstab, before unmounting the temp mount points ;):
Quote:

Now it's time to enter the appropriate entries into /etc/fstab so they will be mounted automatically at boot time:

/dev/hdx1 /usr ext3 defaults 0 1
/dev/hdx2 /home ext3 defaults 0 1
(And don't forget to substitute the x in hdx for the correct letter to the drive being partitioned)......

And the "last" command I was talking about is 'mount -a', which will reread the /etc/fstab file and mount any entry that needs mounting, while ignoring those already mounted, thus automatically mounting those two entries I showed you to add in /etc/fstab........

HTH :)

Jukas 03-24-2005 10:50 AM

Quote:

Originally posted by thegeekster
[B]Sorry I took so long to reply, but I had to take my mother to the hospital...

If you followed along, I already showed you the entries to make in /etc/fstab, before unmounting the temp mount points ;): (And don't forget to substitute the x in hdx for the correct letter to the drive being partitioned)......
You're right, I don't know how I missed it. You're tutorial worked perfectly, thank you.

I hope your mother is doing better.


All times are GMT -5. The time now is 06:17 AM.