LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Need to replace full harddrive with new, larger harddrive (https://www.linuxquestions.org/questions/linux-newbie-8/need-to-replace-full-harddrive-with-new-larger-harddrive-130844/)

pearlr 01-02-2004 10:17 AM

Need to replace full harddrive with new, larger harddrive
 
Hi there! I am a relative newbie to Linux and have what I hope is a basic question. I have a server running Redhat 9.x with two harddrives, hda and hdb, partitioned as seen below:


Filesystem 1K-blocks Used Available Use% Mounted on
/dev/hda1 295564 277892 2412 100% /
/dev/hda7 72919708 129252 69086272 1% /home
/dev/hdb1 59106972 56025800 78628 100% /home2
none 127644 0 127644 0% /dev/shm
/dev/hda6 497829 8859 463268 2% /tmp
/dev/hda2 2522076 2284252 109708 96% /usr
/dev/hda3 2016044 395748 1517884 21% /var


As you can see, /dev/hdb1 is very close to full. I want to replace this drive with a bigger one, but I am unsure of what might be the best way to migrate the data to this new drive.

What I have done under Windows environments is to add this new, bigger drive as an additional drive and then copy data from the old drive to the new drive, then remove the old drive and place the new drive in the physical location of the old. This allows me to keep the existing drive letter after the migration is complete and the data migration was done via a simple file copy.

Is there a way for me to do the same thing under Linux or is there another way that I need to do this?

Thanks in advance for your help.

:newbie:

fancypiper 01-02-2004 12:59 PM

I would tar it over, then edit /etc/fstab to reflect changes, then umnount partitions, then mount /home2 and you are done.

# Clone a distro to another drive or move directories around
Install drive in box (assuming IDE1 slave for examples) and ensure BIOS can detect it. Boot into Linux and login to your user's account. Open an x terminal and partition and format the new drive as you wish
Code:

[fancy@tinwhistle fancy]$ su -
Password:
[root@tinwhistle root]# fdisk /dev/hdb

Exit with w to write the partition table.

Format the partitions with the chosen filesystems:
mke2fs /dev/hdbX -> ext2
mke2fs -j /dev/hdbX -> ext3
mkswap -> swap
mkreiserfs -> reiserfs
mkfs.xfs -> xfs

Make directories for source and destination mount points. You need these to keep out of an endless loop of copying itsself over and over.
Code:

[root@tinwhistle root]# mkdir /mnt/source
[root@tinwhistle root]# mkdir /mnt/destination

Mount your os partitions that you want to clone on /mnt/source
Mount your partitions on the new drive, making directory entries for your separate partitions (/boot, /home, /var etc.). If you are just copying a directory such as var, just cd to the directory you wish to copy instead of mounting partitions on /mnt/source.

Now, cd to /mnt/source and pipe it over with tar
Code:

[root@tinwhistle root]# cd /mnt/source
[root@tinwhistle source]# tar cf - . | (cd /mnt/destination && tar xBfp -)

Edit /etc/fstab as needed, install the boot loader if you moved a whole distro, and it should work when it is installed in it's final position.


All times are GMT -5. The time now is 05:19 AM.