Move directory from one petition/device to another

Les Mikesell lesmikesell at gmail.com
Sat Sep 17 01:47:51 UTC 2005


On Fri, 2005-09-16 at 18:25, Cameron Beattie wrote:
> > Had you picked almost any other directory, there'd have probably been no 
> > problem in doing so...
> >
> > However, /etc is necessary very early in the boot process. (i.e. before 
> > all the mounts are done.) Things like /etc, /bin, /sbin, /var need to be 
> > in the root so that they can be used during the boot. Other things, like 
> > /usr, /tmp, /opt can be moved into other partitions or devices / 
> > filesystems, and can be set up in /etc/fstab to be mounted during the boot 
> > process, without any harm to the system.
> >
> > Doing so is just a matter of mounting the new filesystem at a convenient 
> > mount point, cloning the directory structure over to it (tar is useful for 
> > this), getting into single user mode, deleting the original files and then 
> > mounting the new filesystem over the old directory as a mountpoint.
> >
> This is where I'm a bit lost. I have replicated the directory /etc as 
> follows:
> mkdir /newetc
> mount -t ext3 /dev/sda2 /newetc
> cd /
> tar cf - ./etc | (cd /newetc; tar xf -)
> 
> How do I now convince the system to look in /dev/sda2/newetc/etc rather than 
> /dev/sdb1/etc when I do a cd /etc?

Errr....  You did read the part above that you quoted above noting
that /etc was a special case that needs to be on the / partition
didn't you?    The way you make your new partition appear at a
certain directory is to mount it there.  You might unmount it
from it's /newetc mount point and remount on /etc _but_ the
way the system determines what to mount at bootup is to
read /etc/fstab.  Notice the problem yet?  What you are
doing would work with /home, /var or about anything else.
Your next step would be to set up the /etc/fstab entry,
rename the old directory (so you can delete the contents
later), make a new empty one for the mount point, and
reboot.

The contents of /etc are typically not all that big.  Why
do you want it on a separate partition anyway?

-- 
  Les Mikesell
     lesmikesell at gmail.com





More information about the users mailing list