Moving partition to new hard drive
David Maier
dave at bardacious.com
Thu Jun 10 01:27:49 UTC 2004
Christopher K. Johnson wrote:
> Terry Polzin wrote:
>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> On Tuesday June 8 2004 21:39, David Maier wrote:
>>
>>
>>> I'm running FC2 on a 20 Gb hard drive, on which I have a separate
>>> partition for my /home directory. I just installed a 120 Gb hard
>>> drive,
>>> and would like to migrate the /home directory to that drive. How can I
>>> do this without completely repartitioning my installation?
>>>
>>> Thanks,
>>>
>>> Dave Maier
>>>
>>
>>
>> My general recipe, RTFM as always. You did not state if you were
>> adding SCSI or IDE disks so I made the commands generic
>>
>> 1) fdisk (make the partition(s) 2) e2fsck format the partition(s)
>> 3) mount (new home partition) on /mnt
>> 4) cd /home; tar cf - . | (cd /mnt|tar xvf- )
>> 5) edit /etc/fstab for new partition(s)
>> 6) umount /mnt
>> 7) umount old /home
>> 8) mount new /home
>> 9) ls -l /home -- check to see all data is there
>>
>> Good Luck,
>>
>> Terry
>>
>>
> Are there any remote users of this machine? If so you should probably
> do 'init 1' or boot adding 'single' to boot parameters before doing
> any of this.
>
> Also you need to ensure none of the files you are copying are open and
> in use (thus possibly corrupt copy). A good way to do this is to
> umount /home before you copy because it cannot be unmounted while in
> use. To make this work you need to not be logged in as anyone but
> root. In other words you cannot login as normal user and 'su -' to do
> this. You need to login as root directly (which hopefully is only
> permitted at the console on your machine for security reasons ;).
>
> I like to use cpio or rsync for such copies.
>
> My variation of the procedure would be this if /home is currently a
> partition (using second ide disk, if scsi substitute sdb for hdb) :
>
> 1) Login as root
> 2) fdisk /dev/hdb #make new /home partition and set it to type linux
> ext2 - call it /dev/hdb1 for this example
> 3) mke2fs -j /dev/hdb1 -L /home
> 4) init 1
> 5) mkdir /oldhome
> 6) umount /home
> 7) e2label [whatever your old /home device is] /oldhome
> 8) mount -o ro [whatever device old /home is] /oldhome
> 9) mount /dev/hdb1 /home
> 10) cd /oldhome; find . | cpio -dumpv /home
> 11) umount /oldhome
> 12) rmdir /oldhome
> 13) Edit your /etc/fstab if necessary. Using the label "/home" set
> above this will probably not be necessary.
>
> My variation of the procedure would be this if /home is currently a
> directory in the / filesystem (using second ide disk, if scsi
> substitute sdb for hdb) :
>
> 1) Login as root
> 2) fdisk /dev/hdb #make new /home partition and set it to type linux
> ext2 - call it /dev/hdb1 for this example
> 3) mke2fs -j /dev/hdb1 -L /home
> 4) init 1
> 5) edit /etc/fstab adding following line:
> LABEL=/home /home ext3
> defaults 1 2
> 6) mv /home /oldhome
> 7) mkdir /home
> 8) mount /home
> 9) cd /oldhome; find . | cpio -dumpv /home
> 10) Later after you are confident everything is copied under new /home
> ok do an rm -rf /oldhome
>
>
Thanks for all of your suggestions. It's an IDE drive, and the server
supports a small LAN; no problem making sure everyone is off and files
are secure. I'll do it over a weekend, with plenty of time to really
mess things up.
Dave
More information about the fedora-list
mailing list