[CLUE-Tech] Moving data between partitions?

Keith Hellman kehellman at yahoo.com
Sat Aug 24 14:21:31 MDT 2002


--- "Jeffery C. Cann" <fabian at jefferycann.com> wrote:
> Is there a simple way to move space from my /var partition to my /
> partition?

This has been a good thread - I simply wanted to throw my two cents in.

I should also add that this is quite the long post, and may sound a bit
like soapbox-ing, my apologies in advance.

Jed:  Thanks for the plug.  Your right, if a system is setup with LVM,
this type of 'problem' simply isn't a problem.  This is (by my count) the
second time this type of question has been posted to the list.  I'd like
to volunteer to bring an LVM'd machine to the next install fest, so that
anyone interested in playing around with LVM can do so easily without
risking one of their own machines first.  People interested in this should
let me know, cause it will take me some prep-time...

I believe it was David A. that pointed out that only certain directories
can be safely moved.  People new to Linux should read his post again,
because this is an easy to make mistake...  years ago I remember learning
it the hard way :^)  If Jeff doesn't need to move one of those critical
directories, then Lynn's symlink solution will work.

Someone posted positive results using resize2fs to ENLARGE filesystems;
I've used it (and reiser_resize) successfully for BOTH enlarging as well
as shrinking filesystems (SuSE distro).

Someone else posted that the problem with using LVM is that the setup and
maintainence is too much work, when symlinking solves the problem.  I
(believe it or not) partially agree:
* LVM isn't helpful to Jeff (and others in his situation) because LVM is a
pain (not impossible, just a big pain) to retrofit onto a working station.
* The biggest issue is that although a distro may SUPPORT LVM, that may
just mean they have the admin tools rpm/tgz/pkg file.  They don't support
LVM INSTALLATION, which is critical requirement to using LVM - building
your workstation with it.  SuSE provides LVM at install time, and this is
the biggest single reason I use SuSE.  I have heard tell that RH 7.3 now
supports LVM installs, but I dont' use RH, so I can't comment beyond that.
 As for Mandrake, Debian, or Gentoo; I dunno.
* However, the downside to symlinks is that too much of it leads to
spagetti filesystem structure which eventually turns into an admin
nightmare (IMHO).

Finally, here is what I'd do if I were Jeff (I believe someone else posted
 a similar recipe):
IF THE ROOT AND VAR PARTITIION ARE CUDDLED TOGETHER (the final cylinder of
 the root part is immediately before the first cyl of the var partition)
* goto single user mode
* tar var onto backup media (and determine how small you can make var!)
* umount var
* fdisk
>>> delete var partition
>>> recreate var with the appropriate start/end cylinder for the size
determined before, AND with the same ending cylinder as the partition had
before (requires a little math)
>>> save partition table
* recreate filesystem on new var partition
* remount /var
* untar from backup
* reboot - make sure all is ok
* reboot to rescue disk
* fdisk
>>> delete (believe it or not) the root partition
>>> recreate it immediately with the same starting cyl, and the ending
cylinder one less than the new var partitions starting cyl.
>>> save partition
* test mount root and make sure all is good
* umount the temporary root mount
* use resize to expand root to the appropriate size
* test mount root
* reboot & your done

IF THE ROOT AND VAR PARTITIONS ARE NOT CUDDLED (and you don't want, or
can't use a symlink)
* backup var (just in case, we won't be using it in this case...)
* umount var
* use resize to shrink var filesystem down to desired, smaller size
* remount var as a test
* umount var
* fdisk
>>> delete var partition
>>> recreate var partition with same start cyl, and an ending cylinder
providing enough space for the newly reduced var filesystem
>>> save partition table
* mount var - all should be ok
* fdisk
>>> add new partition consuming cylinders between the end of the new var
partition and the old var partitions ending cyclinder
>>> save partition
* make new filesystem of your choice on the new partition,
* mount new partition at /mnt/tmp
* copy disired (AND RELOCATABLE) directory contents from /DIR to /mnt/tmp
* delete the directory contents from /DIR
* umount /mnt/tmp
* mount new partition at /DIR
* add appropriate /DIR entry to /etc/fstab
* reboot to test

Finally, I simply can't leave this out:  how to grow (actually create &
move) a relocatable directory off of root using LVM:
* umount /var
* resize var LVM logical volume down
* lvreduce the /var LVM logical volume
* remount /var
* lvcreate an new LVM logical volume
* create filesystem on new lv
* mount new lv to /mnt/tmp
* copy relocatable dir contents to /mnt/tmp
* remove contents on /
* umount /mnt/tmp
* mount new lv to root mount point
* add fstab entry
The steps are essentially the same as the second recipe above!  You simply
use LVM commands instead of fdisk commands.

There really isn't a comparable LVM algorithm for the first recipe,
becuase (at least my approach) is too make my root partition (non-LVM'd)
as small and tight as possible.  Then ANY relocatable directories (the
ones David A. mentions can be moved) I create using LVM.  Because of this
I should never need a root bigger than maybe 256M, and the algorithm I
would use to enlarge another relocatable directory is this:
* umount /var
* resize var LVM logical volume down
* lvreduce the /var LVM logical volume
* remount /var
* umount /relocatable_dir
* lvextend relocatable_dir LVM logical volume
* resize relocatable_dir LVM logical volume up
* mount /relocatable_dir

Cheers!

=====
Keith E. Hellman
kehellman at yahoo.com

__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com



More information about the clue-tech mailing list