Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Can i Move /usr and /opt to an other hd partion?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Duplicate Threads
View previous topic :: View next topic  
Author Message
jonfr
Veteran
Veteran


Joined: 20 Jul 2003
Posts: 1008
Location: Denmark

PostPosted: Mon Jan 05, 2004 7:10 am    Post subject: Can i Move /usr and /opt to an other hd partion? Reply with quote

I'm wondering if i can move my /usr and /opt to an diffrent hard disk partions, since i only have 5.9GB space for / and it getting almost all used. then i mean by edit fstab and just add the partions there. Can that be done in save way?
Back to top
View user's profile Send private message
OneOfOne
Guru
Guru


Joined: 28 May 2003
Posts: 368

PostPosted: Mon Jan 05, 2004 7:15 am    Post subject: Reply with quote

yeah it'll work (different partition for each).

peace
Back to top
View user's profile Send private message
Cosmin
Guru
Guru


Joined: 18 Dec 2003
Posts: 447
Location: Bucharest, Romania

PostPosted: Mon Jan 05, 2004 9:37 am    Post subject: Yes, you can! Reply with quote

Yes, you can do it! I did it and worked. This was pretty amazing in the beginning (because I came from a Windows environment, where this would be hard to achieve).
:arrow: 1st you should prepare you new partition. Perhaps formatting a fat/ntfs one. Changing to ext3/reiser is recommended. I converted an ntfs one. mk2fs should do fine;
:arrow: 2nd, mount your newly created partition in /mnt/whatever;
:arrow: 3rd, copy the content of your /usr into this partition (be careful, the content, not /usr);
:arrow: 4th, unmount /mnt/whatever;
:arrow: 5th, mount it as /usr;
:arrow: 6th, edit /etc/fstab to add your partition at the point /usr. If you are using Gentoo (and you probably are), follow the instructions found there. This will be read on your next boot and the new partition will be mounted at /usr as expected.
Now you can check that /usr is on a different partition. I use mc for that. It will show you the amount of space used. For / and /usr they should be different.
Now, a little clean-up:
:arrow: mount your / partition (the one that used to contain /usr) in /mnt/whatever;
:arrow: delete the content of your /mnt/whatever/usr;
:arrow: unmount /mnt/whatever.
If this is enough, you can stop reading here.
And a little addition to what OnoOfOne said. /usr and /opt can be on the same partition! BUT! They should be mounted in / instead of /usr (as stated above) and the new partition should contain the directories /usr and /opt (instead of their content). The file /etc/fstab should be modified accordingly, to add the new partition to / instead of /usr.
This might be scarry, but it's not. I tried it and worked wonderfully from the first shot. Just to be sure, you could skip the clean-up in order to have a point to roll-back to. Your /usr would remain on your old partition but it won't be accessed. When you are satisfied, you can do the clean-up.[/code]
Back to top
View user's profile Send private message
charlieg
Advocate
Advocate


Joined: 30 Jul 2002
Posts: 2149
Location: Manchester UK

PostPosted: Mon Jan 05, 2004 9:40 am    Post subject: Reply with quote

Yup, it should work fine.

[EDIT] I see that somebody has produced a superior method above. Use that one not the following one.

Just mount your destination dirs somewhere else first (eg /mnt/opt and /mnt/usr), copy all your files over and edit your fstab file. Then reboot using your livecd to get rid of the contents of the old /usr and /opt and another reboot should have you in your new setup.
_________________
Want Free games?
Free Gamer - open source games list & commentary

Open source web-enabled rich UI platform: Vexi
Back to top
View user's profile Send private message
vdboor
Guru
Guru


Joined: 03 Dec 2003
Posts: 592
Location: The Netherlands

PostPosted: Mon Jan 05, 2004 10:26 am    Post subject: Reply with quote

I have a few partitions, but I've replaced my /opt folder with a symlink to /usr/opt/ (because my usr is on a different partition too, and my / is quite small now) I think this is a nice solution, but if anyone knows a better way, I'd like to hear it.

Also, I can't umount my /usr in single-user mode before /bin/login is killed first.. :? I hope these 2 things are not related somehow.

...if you'd like to resize your / partition, change the portage temp folder too!
_________________
The best way to accelerate a windows server is by 9.81M/S²
Linux user #311670 and Yet Another Perl Programmer

[ screenies | Coding on KMess ]
Back to top
View user's profile Send private message
shash
Apprentice
Apprentice


Joined: 18 Apr 2003
Posts: 220
Location: India

PostPosted: Mon Jan 05, 2004 10:33 am    Post subject: Reply with quote

Yup, it'll work beautifully!

Just remember, preserve the file permissions (cp -p). Or your files might have b0rked permissions and ownerships.
Back to top
View user's profile Send private message
Cosmin
Guru
Guru


Joined: 18 Dec 2003
Posts: 447
Location: Bucharest, Romania

PostPosted: Mon Jan 05, 2004 10:40 am    Post subject: Don't unmount /usr Reply with quote

Quote:
Also, I can't umount my /usr in single-user mode before /bin/login is killed first.. I hope these 2 things are not related somehow


Do not unmount /usr! It is not necessary... When you mount the new partition to /usr, it will silently switch from your / partition to your new partition. Be carefully not to have the directories in use. I think you could do a shutdown (this will take you in maintenance mode) and work from there.
Because I am the only user on my PC (not part of a network) this was quite safe for me ;) I believe you could even do this from X, but I never tried. I wouldn't recommend this during emerge though :)
Back to top
View user's profile Send private message
jonfr
Veteran
Veteran


Joined: 20 Jul 2003
Posts: 1008
Location: Denmark

PostPosted: Mon Jan 05, 2004 3:31 pm    Post subject: Re: Yes, you can! Reply with quote

Cosmin wrote:
Yes, you can do it! I did it and worked. This was pretty amazing in the beginning (because I came from a Windows environment, where this would be hard to achieve).
:arrow: 1st you should prepare you new partition. Perhaps formatting a fat/ntfs one. Changing to ext3/reiser is recommended. I converted an ntfs one. mk2fs should do fine;
:arrow: 2nd, mount your newly created partition in /mnt/whatever;
:arrow: 3rd, copy the content of your /usr into this partition (be careful, the content, not /usr);
:arrow: 4th, unmount /mnt/whatever;
:arrow: 5th, mount it as /usr;
:arrow: 6th, edit /etc/fstab to add your partition at the point /usr. If you are using Gentoo (and you probably are), follow the instructions found there. This will be read on your next boot and the new partition will be mounted at /usr as expected.
Now you can check that /usr is on a different partition. I use mc for that. It will show you the amount of space used. For / and /usr they should be different.
Now, a little clean-up:
:arrow: mount your / partition (the one that used to contain /usr) in /mnt/whatever;
:arrow: delete the content of your /mnt/whatever/usr;
:arrow: unmount /mnt/whatever.
If this is enough, you can stop reading here.
And a little addition to what OnoOfOne said. /usr and /opt can be on the same partition! BUT! They should be mounted in / instead of /usr (as stated above) and the new partition should contain the directories /usr and /opt (instead of their content). The file /etc/fstab should be modified accordingly, to add the new partition to / instead of /usr.
This might be scarry, but it's not. I tried it and worked wonderfully from the first shot. Just to be sure, you could skip the clean-up in order to have a point to roll-back to. Your /usr would remain on your old partition but it won't be accessed. When you are satisfied, you can do the clean-up.[/code]


Thx, i've going to use that way, but can't have /usr and /opt on the same hd partion, since that is just going to be an fstab setting. I hope that is ok... :?
Back to top
View user's profile Send private message
vdboor
Guru
Guru


Joined: 03 Dec 2003
Posts: 592
Location: The Netherlands

PostPosted: Wed Jan 07, 2004 9:33 am    Post subject: Re: Don't unmount /usr Reply with quote

Cosmin wrote:
Quote:
Also, I can't umount my /usr in single-user mode before /bin/login is killed first.. I hope these 2 things are not related somehow


Do not unmount /usr! It is not necessary... When you mount the new partition to /usr, it will silently switch from your / partition to your new partition. Be carefully not to have the directories in use. I think you could do a shutdown (this will take you in maintenance mode) and work from there.
Because I am the only user on my PC (not part of a network) this was quite safe for me ;) I believe you could even do this from X, but I never tried. I wouldn't recommend this during emerge though :)


I wanted to resize the /usr partition, and you need to unmount it before you can ;) somehow /bin/login didn't kept the partition in use... :? ..even in single-user mode (runlevel 1).

I'm not familliar with the shutdown/maintaince mode. Single-user is supposed to be used for this. All processes will be terminated before you enter runlevel 1.
_________________
The best way to accelerate a windows server is by 9.81M/S²
Linux user #311670 and Yet Another Perl Programmer

[ screenies | Coding on KMess ]
Back to top
View user's profile Send private message
Cosmin
Guru
Guru


Joined: 18 Dec 2003
Posts: 447
Location: Bucharest, Romania

PostPosted: Wed Jan 07, 2004 9:45 am    Post subject: Reply with quote

If you want to resize the /usr partition, yes, you have to unmount it first. But I was talking about moving it to another partition. And yes, single-user mode and maintenance mode is the same thing...
Back to top
View user's profile Send private message
vdboor
Guru
Guru


Joined: 03 Dec 2003
Posts: 592
Location: The Netherlands

PostPosted: Wed Jan 07, 2004 10:36 am    Post subject: Reply with quote

Cosmin wrote:
If you want to resize the /usr partition, yes, you have to unmount it first. But I was talking about moving it to another partition. And yes, single-user mode and maintenance mode is the same thing...


ok. thanks a lot. sorry for bothing you.


Quote:
Be carefully not to have the directories in use.


I can ensure that it's safe to move the files while they are in use... or delete them. Windows has this nasty thing where you can't remove files being used. Names are directly linked to the file contents. Linux doesn't. Filenames are just a way to query for the internal inode number. Once the kernel has the inode number, it forgets the filename, and you can safely rename it, or remove the filename. The datablocks will be deleted+freed later when the inode it no longer used.

If you move (=copy) a file to another partition, it's orginal data will be deleted when the program exists. Unless your file is a huge database, you could move all files safely to another partition without stopping programs first.



If you were planning to move your entire /usr folder, I would do this with the command line, because you might move a program that your DE tries to start, and /bin/mv won't be affected by moving the /usr/ tree.
_________________
The best way to accelerate a windows server is by 9.81M/S²
Linux user #311670 and Yet Another Perl Programmer

[ screenies | Coding on KMess ]
Back to top
View user's profile Send private message
Cosmin
Guru
Guru


Joined: 18 Dec 2003
Posts: 447
Location: Bucharest, Romania

PostPosted: Wed Jan 07, 2004 11:19 am    Post subject: Reply with quote

vdboor wrote:
Quote:
Be carefully not to have the directories in use.


I can ensure that it's safe to move the files while they are in use... or delete them.
I was thinking about a scenario like this:
1) you copy the /usr into the new partition
2) you create/copy some files in the /usr
3) you mount the new partition into /usr
That way, the new created/copied files would be lost. Of course, you could sychronize them, but that's not the point. There is a time gap between copying everything in /usr and mounting the new partition and this is where you have to be careful...
Back to top
View user's profile Send private message
jonfr
Veteran
Veteran


Joined: 20 Jul 2003
Posts: 1008
Location: Denmark

PostPosted: Tue Jan 13, 2004 5:37 pm    Post subject: Reply with quote

Cosmin wrote:
vdboor wrote:
Quote:
Be carefully not to have the directories in use.


I can ensure that it's safe to move the files while they are in use... or delete them.
I was thinking about a scenario like this:
1) you copy the /usr into the new partition
2) you create/copy some files in the /usr
3) you mount the new partition into /usr
That way, the new created/copied files would be lost. Of course, you could sychronize them, but that's not the point. There is a time gap between copying everything in /usr and mounting the new partition and this is where you have to be careful...


I did just copy my /usr to an other hard disk partion whitout an problem. i did just copy the folder to an empty partion, edit the fstab, rebooted and it was all good :)
Back to top
View user's profile Send private message
Cosmin
Guru
Guru


Joined: 18 Dec 2003
Posts: 447
Location: Bucharest, Romania

PostPosted: Wed Jan 14, 2004 10:05 am    Post subject: Reply with quote

No need to reboot... But if you just wanted to verify your settings, it's OK. Rebooting is necessary ONLY for installing a new kernel. Shutdown is necessary ONLY for saving power and adding/removing hardware. I have a friend that adds/removes his hard-drive with the computer (an ordinary PC) running. I don't know about PCI hot add/remove, but I think this can be done too.
So, leave behind the idea that everytime you change your system you have to reboot. It isn't necessary. But, as I said, if you just wanted to check your settings, it's OK.
Back to top
View user's profile Send private message
GentooNub
n00b
n00b


Joined: 25 Jan 2004
Posts: 42

PostPosted: Sun Feb 15, 2004 10:21 pm    Post subject: Reply with quote

Thinking of moving my /usr and /hom directory to a new partition that I just made with mkfs -t ext3. This procedure as everyone suggest would work but I'm confused about the part where was said content only. Is that only if I'm moving everything in /usr to the partition? Because then obviously I'd just mount the parittion with fstab to /usr. But since I'm putting 2 folders onto the one partition how would I get fstab to recognize theres two there and link them appropriately? Just make a /usr and /home directory copy everything over and in fstab what do I put as a mount point?
Back to top
View user's profile Send private message
vdboor
Guru
Guru


Joined: 03 Dec 2003
Posts: 592
Location: The Netherlands

PostPosted: Sun Feb 15, 2004 11:14 pm    Post subject: Reply with quote

GentooNub wrote:
This procedure as everyone suggest would work but I'm confused about the part where was said content only. Is that only if I'm moving everything in /usr to the partition?


Yes, you should run a "mv /usr/* /mnt/tmp-new-usr", and not a "mv /usr /mnt/..." command ;) The first one moves all files (except hidden files starting with a dot) to the new folder. The second command moves the /usr folder itself.
_________________
The best way to accelerate a windows server is by 9.81M/S²
Linux user #311670 and Yet Another Perl Programmer

[ screenies | Coding on KMess ]
Back to top
View user's profile Send private message
GentooNub
n00b
n00b


Joined: 25 Jan 2004
Posts: 42

PostPosted: Sun Feb 15, 2004 11:26 pm    Post subject: Reply with quote

How do I use fstab to mount both points since they're on 1 partition and are two different root folders? And in the above example I'd want to use the first example? If that's true then I have to move hidden folders/files seperately?
Back to top
View user's profile Send private message
GentooNub
n00b
n00b


Joined: 25 Jan 2004
Posts: 42

PostPosted: Mon Feb 16, 2004 3:19 am    Post subject: Reply with quote

Anybody? I'd really like to get this setup. Yes I AM impatient. Can't help it. ;)
Back to top
View user's profile Send private message
Regor
Guru
Guru


Joined: 06 Aug 2002
Posts: 545
Location: 39° 2' 48" N, 120° 59' 2" W

PostPosted: Mon Feb 16, 2004 9:56 am    Post subject: Reply with quote

If I understand you correctly, you want to move both /usr and /home to the same newly created partition? There's a couple of ways this can be accomplished. What I'd do is as follows:

1) mount the new filesystem somewhere out of the way. e.g. "mount /dev/hdXX /mnt/new"
2) copy over the contents of /usr there: "cp -a /usr/* /mnt/new"
3) create a directory under that filesystem for home to live in. e.g. "mkdir -pv /mnt/new/usr/local/home" (The example puts it in /usr/local so the system won't be tempted to mess with it)
4) copy contents of /home to the new directory: "cp -a /home/* /mnt/new/usr/local/home"
5) create new fstab entries for both filesystems. e.g.:
Code:
/dev/hdXX         /usr   ext3   defaults  0 1
/usr/local/home   /home  none   bind      0 0

6) reboot.
7) once it's determined that it all works right, boot some other media and delete the contents of the old /usr and /home to free up that space.
8) Have fun!
_________________
Sometimes the appropriate response to reality is to go insane.
-Philip K. Dick, Valis
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20624

PostPosted: Wed Aug 04, 2004 11:31 pm    Post subject: Reply with quote

https://forums.gentoo.org/viewtopic.php?t=75699
_________________
Quis separabit? Quo animo?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Duplicate Threads All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum