LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Low Harddisk space. Can I just transfer the entire Linux to a bigger harddisk? (https://www.linuxquestions.org/questions/linux-newbie-8/low-harddisk-space-can-i-just-transfer-the-entire-linux-to-a-bigger-harddisk-166722/)

davidas 04-06-2004 02:25 AM

Low Harddisk space. Can I just transfer the entire Linux to a bigger harddisk?
 
Filesystem Size Used Avail Use% Mounted on
/dev/hda3 1.1G 948M 75M 93% /
tmpfs 251M 0 251M 0% /dev/shm
/dev/hda2 462M 51M 387M 12% /home

I'm going to install a bigger harddisk as slave, and then partitioned it :-
/dev/hdb1 /
/dev/hdb2 /home

mount /dev/hdb1 /mnt/hdb1
mount /dev/hdb2 /mnt/hdb2
(Are these the right commands to copy the entire content on the original harddisk to the new harddisk?)

cp -pR /*.* /mnt/hdb1
cp -pR /home/*.* /mnt/hdb2

Afterwhich, physically swap both harddisk, so that the bigger harddisk is now the master and the original harddisk the slave. Will the drive letter be automatically updated? ie. the new harddisk when plug in as master will automatically be hda and the original harddisk ,which is plug in as slave, be hdb?


Is this the correct method?

Thanks !

iluvatar 04-06-2004 03:08 AM

never tried it, but anyway you have to install you're favorite bootloader on the new drive too...

davidas 04-06-2004 03:44 AM

mount /dev/hdb1 /mnt/hdb1
mount /dev/hdb2 /mnt/hdb2
(Are these the right commands to copy the entire content on the original harddisk to the new harddisk?)

cp -pR /*.* /mnt/hdb1
cp -pR /home/*.* /mnt/hdb2
/sbin/grub-install /dev/hdb1 <------ would this suffice?

Afterwhich, physically swap both harddisk, so that the bigger harddisk is now the master and the original harddisk the slave. Will the drive letter be automatically updated? ie. the new harddisk when plug in as master will automatically be hda and the original harddisk ,which is plug in as slave, be hdb?

Quote:

Originally posted by iluvatar
never tried it, but anyway you have to install you're favorite bootloader on the new drive too...

spurious 04-06-2004 03:49 AM

Just to continue with Iluvatar's answer, do the following to install the bootloader on hdb:

chroot /mnt/hdb1
/sbin/lilo
exit

The 'chroot' command changes root to /mnt/hdb1, your "new root". When you run lilo, it will execute from the "new root" on /mnt/hdb1, and install your bootloader to the MBR on hdb1.

Hopefully, when you reboot with your new hard-disk, everything should work.

iluvatar 04-06-2004 03:50 AM

well, I don't know if it's going to work. it looks ok to me, and at least you always have your old harddisk as backup ;) I would say: try it :) I don't know about grub, I'm used to lilo, got grub running now for 3 days or so...

good luck with this :)
-= iluvatar =-

spurious 04-06-2004 03:54 AM

If you're using grub, then substitute 'lilo' with 'grub' in my post.

davidas 04-06-2004 04:43 AM

Thanks for all the help!

After doing a chroot /mnt/hdb1, and installing the grub into the MBR of hdb1, I'll take out the orginal harddisk (hda) and swap it with the new harddisk (hdb), so that the new harddisk is now the master drive. Will the new harddisk become hda automatically (instead of hdb previously) since it is now connected as master? If so, will the bootloader try to boot up from hdb1 (since it was chroot /mnt/hdb1 and grub-install) ?

PS. Could you elaborate on chroot please? Also, how do you get out of chroot? exit?

Thanks !


Quote:

Originally posted by spurious
Just to continue with Iluvatar's answer, do the following to install the bootloader on hdb:

chroot /mnt/hdb1
/sbin/lilo
exit

The 'chroot' command changes root to /mnt/hdb1, your "new root". When you run lilo, it will execute from the "new root" on /mnt/hdb1, and install your bootloader to the MBR on hdb1.

Hopefully, when you reboot with your new hard-disk, everything should work.


iluvatar 04-06-2004 04:49 AM

hi there!

do not mixup primary / secondary ide connector and master / slave thing... master / slave is just a jumper setting wich doesn't affect the devicelist in linux /dev/ the hda / hdb ( /hdc & hdd) are the different ide channels in your pc. physically swapping the drives is correct for changing their presence in the devicelist. master / slave settings don't do anything in this. after doing the chroot command, grub will install it's config to the master boot record of hdb, the config will be that of hda, so after swapping the drives it would be correct.

greetinz
-= iluvatar =-

whansard 04-06-2004 04:59 AM

when you run chroot with one command after it, you go back to the original root when the command finishes.
if you just did chroot /mnt/hdb1, then you would have to exit

using the cp command isn't as good for tar with such things.
tar clfvp - .|(cd /mnt/hdb1; tar xpf - --same-owner)
copies everything starting in current directory and below to /mnt/hdb1

davidas 04-06-2004 08:08 PM

How does the system differentiate between two harddisks on the same ide channel in the devicelist, of which one is the master and the other is the slave?

Thanks !

Quote:

Originally posted by iluvatar
hi there!

do not mixup primary / secondary ide connector and master / slave thing... master / slave is just a jumper setting wich doesn't affect the devicelist in linux /dev/ the hda / hdb ( /hdc & hdd) are the different ide channels in your pc. physically swapping the drives is correct for changing their presence in the devicelist. master / slave settings don't do anything in this. after doing the chroot command, grub will install it's config to the master boot record of hdb, the config will be that of hda, so after swapping the drives it would be correct.

greetinz
-= iluvatar =-


whansard 04-06-2004 10:00 PM

hda- primary master
hdb-primary slave
hdc- secondary master
hdd-secondary slave

davidas 04-12-2004 01:00 PM

Do I need to tar /proc, /dev, /mnt, lost+found directores and transfer them to the new harddisk? Tar seems to have difficulty archiving /proc and /dev directories. If that is the case, when I boot up on the new harddisk (without transferring /proc and /dev from the old harddisk), will /dev and /proc directories be automatically re-created on the new harddisk?
Or will it won't even boot up? :)

Thanks !

Quote:

Originally posted by whansard
when you run chroot with one command after it, you go back to the original root when the command finishes.
if you just did chroot /mnt/hdb1, then you would have to exit

using the cp command isn't as good for tar with such things.
tar clfvp - .|(cd /mnt/hdb1; tar xpf - --same-owner)
copies everything starting in current directory and below to /mnt/hdb1


whansard 04-13-2004 03:03 AM

do the whole partition in one shot from a rescue cdrom.
you'll still have to set up the boot loader.


All times are GMT -5. The time now is 10:16 PM.