Re: move data to larger drive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Timothy Payne writes:
> I have a machine running RH 7.3 but the disk is about full.  I would
> like to move the data to a larger drive then upgrade that drive with FC2
> keeping the original drive intact so I can just plug it back in if
> things go wrong.

The first thing to do is to document the partitions you are using now,
on your current drive, with (as root):

sfdisk -d /dev/hdX > sfdisk.hdX

Where hdX is your drive, probably hda .  Then look at the ascii file
sfdisk.hdX .  Note, you can edit this file and pipe it into the sfdisk
command to build your new disk.  I recommend this, as it makes tweaking
sizes a lot easier.

Also do a "df" and a "df -i".  Get all that information on paper.

This is your opportunity to resize things, both larger and smaller.  
If you have lots of little partitions, you might decide to merge some
of the partitions on the new disk. 


If you build the new disk with identically-sized partitions to the old
disk, you can use dd to copy the partitions over, for example:

sync ; dd if=/dev/hda2 of=/dev/hdb2 bs=1M 

You can later resize them with parted .  So you could build the new
disk with identically sized partitions with large gaps in between, 
and use parted to expand the partitions into the gaps.  When you
use dd this way, you don't even need to do a mkfs for the target
partition.  However, you should do this in single user mode
[run level 1] on unmounted partitions, and do a fsck afterwards. 
This is as fast as a disk copy gets.

However, it is better to build the new partition with mkfs, and
then copy the files.  This is slower but gives you more control. 
You can also change file systems, for example ext2 to reiserfs3.6
( 4 is in dispute ) .   While some don't trust reiserfs, it does make
more efficient use of the disk, and is usually faster than ext2/3 .

You can copy files with:

   mkdir /newdisk/newdir
   cd    /olddisk/olddir
   sync ; cp -a * .* /newdisk/newdir

This will transfer all the directories, files, and special files,
though symbolic links will get their dates changed.  If you don't
have much RAM, and the directories are big, you may want to do the
copy in smaller chunks.  cp builds tables of copied file info in
RAM, and when the tables get large it starts thrashing swap, slowing
the copy down a lot.

You should do copying in single user mode, after a sync to write out
buffers to the disk.  You probably can get by without the sync, but
I am a superstitious old Unix geezer and believe this is a good habit.

Rather than typing all these commands in from the command line, you
should put them in shell scripts.  That makes mistakes easier to
catch, and if a mistake still slips by, you can correct and replay
the entire session automagically.  You can also post the script in
your next boo-hoo message to this list, making it more likely that
we can spot your mistakes. 

MAKE ABSOLUTELY SURE that the target drive is your new drive, not
your old one.  Read the man pages until they are burned into your
brain; you can easily wipe out a lot of good data if you get drive
or file order wrong in some of the above commands.

I hope that helps.  More experienced folk, please post errors in
the above, and I will repost a corrected version in a few days. 
No sense letting the archive fill with uncorrected nonsense.

Keith



-- 
Keith Lofstrom          keithl@xxxxxxxxxx         Voice (503)-520-1993
KLIC --- Keith Lofstrom Integrated Circuits --- "Your Ideas in Silicon"
Design Contracting in Bipolar and CMOS - Analog, Digital, and Scan ICs



[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux