Swapping partitions around

Swapping partitions around

Post by Ryan Mallo » Wed, 03 Jul 2002 23:56:29



Im a bit of a newbie with the whole Linux partitions thing, but Im
trying to change the partitions in my powerstack. I have 3 drives in it,
one has / and /boot partitions, one has /home and another I called
/shared because I originally intended to just store files and nothing
else on it.

Now I want to install a fair amount of software onto the machine and
want to rename /shared to /usr. Can I just move everything from the
existing /usr to /shared, rename it in /etc/fstab or do I need to
carefully unmount each filesystem and then remount them? I will be
really happy if I can do this without rebooting :-)

Thanks for your time.
Ryan

--
Help! Windows has fallen and it can't get up!

 
 
 

Swapping partitions around

Post by cybea » Thu, 04 Jul 2002 00:40:58



> Im a bit of a newbie with the whole Linux partitions thing, but Im
> trying to change the partitions in my powerstack. I have 3 drives in it,
> one has / and /boot partitions, one has /home and another I called
> /shared because I originally intended to just store files and nothing
> else on it.

> Now I want to install a fair amount of software onto the machine and
> want to rename /shared to /usr. Can I just move everything from the
> existing /usr to /shared, rename it in /etc/fstab or do I need to
> carefully unmount each filesystem and then remount them? I will be
> really happy if I can do this without rebooting :-)

> Thanks for your time.
> Ryan

The times I moved /usr I always rebooted... Here is a way it may work (do
NOT make changes to /etc/fstab until you know this will work). First, MAKE
A OF ANY DATA AND CONFIGS YOU DO NOT WANT TO LOOSE. *copy* the /usr to
/shared (I use tar to save file ownerships...). Type the command mount with
no options. Look though the mounts to find the drive and partition share is
mounted to (the partition mounted should look something like /dev/hdc7).
Unmount /shared. mount /usr to the old shared partition.  At this time you
have the old /usr still where it was but "hidden" behind the new /usr on
the new device. If it does not work and the system locks up, you can reboot
and you're back to using the old /usr. If nothing * shows up over net
next several working days, make the changes to the /etc/fstab. I'll leave
it to you to try to figure out how to get rid of the *old* /usr.

A warning, some applications might compile and install into /usr/local
meaning that the log output is sent /usr/local. You will need to restart
any applications that are doing this if you use my method.

 
 
 

Swapping partitions around

Post by Jan » Fri, 05 Jul 2002 01:15:15




>> Im a bit of a newbie with the whole Linux partitions thing, but Im
>> trying to change the partitions in my powerstack. I have 3 drives in it,
>> one has / and /boot partitions, one has /home and another I called
>> /shared because I originally intended to just store files and nothing
>> else on it.

>> Now I want to install a fair amount of software onto the machine and
>> want to rename /shared to /usr. Can I just move everything from the
>> existing /usr to /shared, rename it in /etc/fstab or do I need to
>> carefully unmount each filesystem and then remount them? I will be
>> really happy if I can do this without rebooting :-)

>> Thanks for your time.
>> Ryan

> The times I moved /usr I always rebooted... Here is a way it may work (do
> NOT make changes to /etc/fstab until you know this will work). First, MAKE
> A OF ANY DATA AND CONFIGS YOU DO NOT WANT TO LOOSE. *copy* the /usr to
> /shared (I use tar to save file ownerships...). Type the command mount with
> no options. Look though the mounts to find the drive and partition share is
> mounted to (the partition mounted should look something like /dev/hdc7).
> Unmount /shared. mount /usr to the old shared partition.  At this time you
> have the old /usr still where it was but "hidden" behind the new /usr on
> the new device. If it does not work and the system locks up, you can reboot
> and you're back to using the old /usr. If nothing * shows up over net
> next several working days, make the changes to the /etc/fstab. I'll leave
> it to you to try to figure out how to get rid of the *old* /usr.

> A warning, some applications might compile and install into /usr/local
> meaning that the log output is sent /usr/local. You will need to restart
> any applications that are doing this if you use my method.

As an alternative:
mv /usr/* /shared
mount -o bind /shared /usr
echo "/shared /usr auto bind 0 0" >> /etc/fstab

No rebooting necessary. I haven't tested it though! It may make you into a
disco dancing machine, or an alien might abduct you! (say hello to
green-belly from me)

 
 
 

Swapping partitions around

Post by Ryan Mallo » Thu, 04 Jul 2002 02:03:40


Quote:> No rebooting necessary. I haven't tested it though! It may make you into a
> disco dancing machine, or an alien might abduct you! (say hello to
> green-belly from me)

Thanks guys, Ive got it all shifted over, remounted /shared as /usr and
everything seems to be going fine so far and no rebooting :-).

I guess I will eventually have to do a reboot just to make sure the
adjustments to fstab have worked properly, but because I still have my
old /usr partition, if it turns into a disco-dancing machine and I get a
belly full of lead I can always login as root remount the old /usr
partition and be back where I started.

I love Linux.

--
Help! Windows has fallen and it can't get up!

 
 
 

Swapping partitions around

Post by cybea » Thu, 04 Jul 2002 02:39:47



>> No rebooting necessary. I haven't tested it though! It may make you into
>> a disco dancing machine, or an alien might abduct you! (say hello to
>> green-belly from me)

> Thanks guys, Ive got it all shifted over, remounted /shared as /usr and
> everything seems to be going fine so far and no rebooting :-).

> I guess I will eventually have to do a reboot just to make sure the
> adjustments to fstab have worked properly, but because I still have my
> old /usr partition, if it turns into a disco-dancing machine and I get a
> belly full of lead I can always login as root remount the old /usr
> partition and be back where I started.

> I love Linux.

Actualy it might work if you `umount /usr` then `mount /usr` mount will look
in fstab to see were to mount /usr....
 
 
 

Swapping partitions around

Post by cybea » Thu, 04 Jul 2002 03:36:58



> As an alternative:
> mv /usr/* /shared
> mount -o bind /shared /usr
> echo "/shared /usr auto bind 0 0" >> /etc/fstab

True, but would this mean that you would need to worry about the mount
order? I think the way you example is it would work. But what would happen
if a person, without thinking or understanding the bind option, changed the
mount order? Hang with me, I just learned about the bind option so I'm
trying to understand.

If the order is:

/
/shared
/usr

everything would work fine.... But what would happen if things were changed
to:

/
/usr
/shared?

It would seem to me that since shared is a existing directory on the "/
(root) directory, /usr would (using to the mount -o bind /shared /usr
method) mount the /shared that is on the "/ (root)" partition and not to
the /shared partition. Sorry if this sounds crazy but it is the first time
I tried to think it trough... Could someone let me know if I'm on the right
track?

 
 
 

Swapping partitions around

Post by Ian Pege » Thu, 04 Jul 2002 10:01:33


For it was written by cybear:

Quote:> *copy* the /usr to
> /shared (I use tar to save file ownerships...).

cp -a does a grand job too.

--

Ian - looking through a glass onion

 
 
 

Swapping partitions around

Post by Jan » Fri, 05 Jul 2002 11:16:14




>> As an alternative:
>> mv /usr/* /shared
>> mount -o bind /shared /usr
>> echo "/shared /usr auto bind 0 0" >> /etc/fstab

> If the order is:

> /
> /shared
> /usr

> everything would work fine.... But what would happen if things were changed
> to:

> /
> /usr
> /shared?

This shouldn't happen(TM), as I appended the line at the end of fstab. So
it shouldn't ever happen. (just like /usr never gets mounted before /)
 
 
 

Swapping partitions around

Post by cybea » Thu, 04 Jul 2002 19:40:15





>>> As an alternative:
>>> mv /usr/* /shared
>>> mount -o bind /shared /usr
>>> echo "/shared /usr auto bind 0 0" >> /etc/fstab

>> If the order is:

>> /
>> /shared
>> /usr

>> everything would work fine.... But what would happen if things were
>> changed to:

>> /
>> /usr
>> /shared?

> This shouldn't happen(TM), as I appended the line at the end of fstab. So
> it shouldn't ever happen. (just like /usr never gets mounted before /)

I was not asking if the should or should not happen. I was asking if the
order was important. Any admin that has been around for a couple of weeks
learns what "shouldn't happen(TM)" often does.

But what if some new admin got things out of order? After all, new admins
don't always don't know all the "shouldn't happen(TM)". /usr can not be
mounted before / because the system can't find the /usr mount point without
/ being mounted. There is a good reason that / is mounted before /usr.

What I am asking is in your example:

Would mounting in this order:

/
/shared
/usr

give the same result as mounting in this order?

/
/usr
/shared

I know you think it shouldn't happen but I think it is important to discuss
WHY it should not happen. Unless a newbee understands WHY things sould and
should not happen, "should not happens" WILL happen. I have seen a new
admin try to mount /usr first! He had a habit of making changes by
commenting out a line then adding the new line at the bottom of the *file*
with comments like:

#
# added option <x> <date> <admin>
#

< new mount point line >

 
 
 

Swapping partitions around

Post by cybea » Thu, 04 Jul 2002 19:48:42



> For it was written by cybear:

>> *copy* the /usr to
>> /shared (I use tar to save file ownerships...).

> cp -a does a grand job too.

Cool. Guess the tar thing is an old hang over from the person that first
taught me Unix. Here's the way he tried to teach me to do a grep `cat
<file> | grep <string>` He did the same with printing.... It all worked but
none of it was the way I think is best.
 
 
 

Swapping partitions around

Post by Jan » Fri, 05 Jul 2002 19:54:22



> I know you think it shouldn't happen but I think it is important to discuss
> WHY it should not happen.

Ah, okay :-) It shouldn't happen because of the reasons you gave in your
post.
/
/shared
/usr
isn't the same as
/
/usr
/shared

In the*case:
/usr has the same stuff in it as the /shared partition
In the second case:
/usr has the same stuff in it as the directory /shared on the / partition

You don't have to bind-mount different partitions, you can bind-mount
different directories. (which can be quite usefull when setting up a
chrooted ftp server)

 
 
 

Swapping partitions around

Post by cybea » Thu, 04 Jul 2002 21:08:39




>> I know you think it shouldn't happen but I think it is important to
>> discuss WHY it should not happen.

> Ah, okay :-) It shouldn't happen because of the reasons you gave in your
> post.
> /
> /shared
> /usr
> isn't the same as
> /
> /usr
> /shared

> In the*case:
> /usr has the same stuff in it as the /shared partition
> In the second case:
> /usr has the same stuff in it as the directory /shared on the / partition

Thank you. The simple a answer to the question I asked, "but would this mean
that you would need to worry about the mount order?", is yes, you do need
to worry about mount order.
 
 
 

Swapping partitions around

Post by Lee Sau Da » Fri, 05 Jul 2002 09:51:21


    Ryan> Thanks guys, Ive got it all shifted over, remounted /shared
    Ryan> as /usr and everything seems to be going fine so far and no
    Ryan> rebooting :-).

Wow!  I'm too late to reply.

But in case you'd be doing simlar things again:

1) Rebooting is not really necessary.
2) You SHOULD go into single use mode first: telinit s
   Why?  Because many background processes may be accessing /usr.  If
   you move the files away, those process may get confused.  More
   severely, if some processes are modifying /usr, then you cannot
   be sure that you've got a clean an consistent _snapshot_ of the
   whole /usr into the new partition!
3) After entering single user mode, type "ps" to check if any
   unncessary daemons are still running.  Kill them if necessary.
   (Some programs may still be accessing /usr, making it impossible to
    "umount /usr".)
4) Unmount BOTH partitions from their default mount points, just
   as a last resort to make sure no programs are still accessing them.
5) mount both partitions to temporary mount points (e.g. something
   as impossible to clash as "/tmp/blah1", "/tmp/blah2"  :P).
6) transfer the files.  Use 'tar', 'cp -aiR' or 'mv'.  Check what
   options you need to do a recursive copying  that still
   preserves all file attributes (permission, owner/group setting).
8) umount the file systems.
9) mount the file systems at their new mount points.  Use ls, find or
   whatever to check if you've got the correct files in the correct
   places.
10) modify /etc/fstab to make the change permanent.
11) Go back to multi-user mode: telinit 5 (or 3 if you're not booting
    into X directly).

Note that moving the root partition  is another story.  If you want to
do that,  you'd better boot  up a floppy-only  Linux system and  do it
under it.  There is no _simple_ way  to do (4), (5) and (9) above on a
running system.   Without these  steps, you can't  be sure you  have a
consistent  snapshot.   There  is  a mechanism  like  'initrd'  called
pivoting for doing it.  But it doesn't worth the trouble.

Exercise: why  is there a /bin  and also a  /usr/bin?  Which utilities
should be in /bin and which should be in /usr/bin?

    Ryan> I guess I will eventually have to do a reboot just to make
    Ryan> sure the adjustments to fstab have worked properly,

Not necessary.  Just  unmount those 2 partitions, and  the do a "mount
/mountpoint".  Then, check if they have been mounted correctly.

    Ryan> but because I still have my old /usr partition, if it turns
    Ryan> into a disco-dancing machine and I get a belly full of lead
    Ryan> I can always login as root remount the old /usr partition
    Ryan> and be back where I started.

Yeah!  That's the safest way to try things out: make sure you can roll
back easily.

--


Home page: http://www.informatik.uni-freiburg.de/~danlee

 
 
 

1. MS-DOS Swap File vs. Swap Partition

Hello, All;

What performance difference, if any, should I expect to see between a
native Linux swap partition and a swap file residing on an MS-DOS
partition?

I'm currently using my Microsoft Windows swap file as a Linux swap
file, and I'm considering adding a dedicated Linux swap partition as
well.  If there's no performance benefit, I may as well just use a
larger Windows swap file.

Bruce

2. ide addressing...

3. Swap file VS Swap partition

4. Help! Bring background process to foreground

5. 20+ meg Swap partition setup, but top only reports 860k of swap available...

6. Tcpdump sees "echo reply" but ping does not

7. Installing Win/Linux shared swap on old swap partition

8. SunOS 4.1.3 kernel panic

9. Linux Swap Partition and Win3.1 Swap File

10. Swap File vs. Swap Partition - which is better?

11. swap file instead of swap partition

12. swap file vs swap partition

13. Why swap partition not swap file?