LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Moving Ubuntu installation to another drive (https://www.linuxquestions.org/questions/linux-general-1/moving-ubuntu-installation-to-another-drive-386680/)

qjimbo 11-26-2005 09:50 AM

Moving Ubuntu installation to another drive
 
Hi,
I was wondering if someone could tell me step by step, how to move an ubuntu install to another harddisc? Is it possible to have it inside a folder on the other drive as well? I have no idea what the easiest way of doing this is and how to reconfigure grub for it.

The current drive it's on is /dev/hdb/ and I want to move it to /dev/hda prefereably inside a folder on that drive.

Thanks!

EDIT: I can still have a swap partition on /dev/hdb/ so thats not a problem

jailbait 11-26-2005 11:47 AM

"The current drive it's on is /dev/hdb/ and I want to move it to /dev/hda prefereably inside a folder on that drive."

You are moving from one partition to another. So let's assume that you are moving from /dev/hdb1 to /dev/hda1.

"I was wondering if someone could tell me step by step, how to move an ubuntu install to another harddisc?"

Log in as root.
Format /dev/hda1. If /dev/hda1 is mounted then you first umount the partition. Then use mkfs to create a new file system on /dev/hda1. Assuming that you want an ext3 filesystem:

umount /dev/hda1
mkfs -t ext3 /dev/hda1

Now copy everything in Ubuntu to /dev/hda1:
mkdir /newubuntu
mount -t ext3 /dev/hda1 /newubuntu
cp -R -p /* /newubuntu

Now change to run on the /dev/hda1 system:
chroot /newubuntu

Now you are working with the files on /dev/hda1
Edit /etc/fstab to change the location of / to /dev/hda1. If there is an entry for the old /dev/hda1 then remove it. You may want to add an entry to /etc/fstab for /dev/hdb1.

Edit grub by editing /boot/grub/menu.lst. Change the root line to hd0,0. Change the kernel line to root=/dev/hda1.

Then install grub on the MBR with:
grub-install /dev/hda
(note that you are installing the MBR to /dev/hda not to /dev/hda1.)

shutdown and reboot

------------------------------------
Steve Stites

qjimbo 11-26-2005 11:55 AM

Thanks for the reply! However dev/hda1 has lots of files on it in the root folder, so ideally I'd like to be able to move ubuntu into a folder on that drive, rather than onto the root. Is this possible? I want to sort of fool it into using a folder called 'ubuntu' on /dev/hda1 as if that's / or Am I asking for the impossible? I just don't really want to clutter up the root of the drive with bin, usr, var and all those folders as I'll be accessing this drive from another distro. It'd just be nice to keep it organized without having to partition.

jailbait 11-26-2005 12:04 PM

"Thanks for the reply! However dev/hda1 has lots of files on it in the root folder, so ideally I'd like to be able to move ubuntu into a folder on that drive, rather than onto the root. Is this possible? I want to sort of fool it into using a folder called 'ubuntu' on /dev/hda1 as if that's / or Am I asking for the impossible?"

You are asking the impossible. You can copy ubuntu into a directory called /ubuntu but it would not be a runnable operating system.

What you can do is divide /dev/hda1 into two partitions, /dev/hda1 and /dev/hda2. Put your current files in one partition and copy ubuntu to the other.

I am going jogging so somebody else will have to continue this.

-----------------------------
Steve Stites

qjimbo 11-26-2005 12:11 PM

Okey dokey :( I didn't want to have to resort to doing that though, I thought this might be a nice solution to avoid partitioning.

AncientIslander 04-04-2011 11:50 AM

---


All times are GMT -5. The time now is 04:27 PM.