Move directory from one petition/device to another

Les Mikesell lesmikesell at gmail.com
Mon Sep 19 21:07:33 UTC 2005


On Mon, 2005-09-19 at 14:25, Cameron Beattie wrote:
> >>
> >> 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.
> I did read it and I understood it to be difficult but not impossible. So I'm
> now attempting to do the difficult and failing!

Try again, with the idea that it is impossible.  That is, you need
/bin, /sbin, and /etc to be in the root partition or you aren't
going to boot.  This division was done back in the early days of
unix where those directories were very small and they were intended
fit on very small disks.  After you are basically running, you
can mount up other partitions for /user, /home, /var, etc.

> If I follow what you say (and I'm not sure I do), I would do the following 
> (having copied the contents of /etc to /newetc):
> vi /etc/fstab
> /dev/sda2 /etc ext3 defaults 0 0
> 
> mv /etc /oldetc
> mv /newetc /etc
> reboot

Like I tried to say before, that will work with /home or /var but
not /etc (or /bin, or /sbin).

> > The contents of /etc are typically not all that big.  Why
> > do you want it on a separate partition anyway?
> I probably should have told the whole story. What I have is a bunch on
> directories on a RAID5 array and want to move all the system-type ones e.g.
> /etc /bin /sbin/ to a RAID1 array, leaving /home /usr etc where they are. I
> guess it would be easier the other way around but that's not an option.

It would be possible the other way around...   However, if /etc, /bin,
and /sbin all go to the same partition, you can copy all 3 directories
over, then make the new partition the root (/).  If /boot is already a
separate partition, this should not be too difficult - you just have
to edit the 'root=' entry in the 'kernel' line of your /etc/grub.conf
(and note that it is a symlink to /boot/grub/grub.conf so you don't have
the same problem at boot time as with /etc/fstab).  Then you need to
edit the new copy of /etc/fstab to mount your old partition somewhere
and add some symlinks so /usr, /home, /var, and /tmp show up in the
right places.  

> Any further advice would be appreciated.

I suspect it would be easier to back things up, reinstall with the
layout you want, then restore the parts you wanted to keep, being
careful not to put back the old grub.conf or /etc/fstab.

-- 
  Les Mikesell
    lesmikesell at gmail.com





More information about the fedora-list mailing list