Moving OS to another hard disk

Forums for the Fluxbox Edition
Forum rules
Before you post please read this

Moving OS to another hard disk

Postby fluxalex on Fri Mar 26, 2010 9:31 am

Hi again,

I've installed Linux Mint Fluxbox CE yet on another computer. But for testing I've put it on a secondary IDE hard disk (sdb). Now after two weeks of testing and no problems at all, I'd like to have it on the primary IDE (sda) and remove the "sdb" from the computer. Is there a way without having to install the system again, having to download the updates and additional software that I installed and configuring everything again?
Basically what I'd have to do is to create an ext4 and swap partition on "sda". Then copy the complete root file system from "sdb" to "sda". Then somehow I'd have to generate a new "fstab" and reinstall/reconfigure "grub" so that it points to "sda" instead of "sdb".
Has anyone done such a thing already?
fluxalex
Level 1
Level 1
 
Posts: 25
Joined: Fri Feb 26, 2010 3:56 pm
Location: Silves, Portugal

Linux Mint is funded by ads and donations.
 

Re: Moving OS to another hard disk

Postby ArcherSeven on Fri Mar 26, 2010 11:37 am

fluxalex wrote:Hi again,

... Is there a way without having to install the system again, having to download the updates and additional software that I installed and configuring everything again?...


Yes, kinda, but it's rather cumbersome and pretty much noone recommends it. The best way is to reinstall the system, but (if it exists on the fulxbox version) you can use apt-on-cd to store all of your updates so they don't have to be re-downloaded.

Almost all configuration is in your /home/<user>/ directory, and most of it can be copied directly onto a new system, when I update, I just keep all of my /home stuff (by putting it on a seperate partition) however you should be able to copy files w/o notable problems. The terminal command "ls -al" will list all files in a directory (so open a terminal, cd to ~/ which is home, and ls -al) however you'll have to use "show hidden files" in your file manager to do that using a graphic enviornment's tool. I hope that makes sense.


fluxalex wrote:Basically what I'd have to do is to create an ext4 and swap partition on "sda". Then copy the complete root file system from "sdb" to "sda". Then somehow I'd have to generate a new "fstab" and reinstall/reconfigure "grub" so that it points to "sda" instead of "sdb".
Has anyone done such a thing already?


Yes, that has been done, exactly as you say, but I felt the need to repeat that I, and most that I talk to, don't do that and call it a "bad idea".

If you don't understand something, ask, I'll be sure to check back.
User avatar
ArcherSeven
Level 3
Level 3
 
Posts: 190
Joined: Thu Mar 19, 2009 12:57 am
Location: St. Louis, MO, USA

Re: Moving OS to another hard disk

Postby shane on Fri Mar 26, 2010 12:14 pm

Whether you go for migrating your installation or reinstalling, IMO, depends on how confident you are in fixing a broken system. If something does go wrong, you will have probably saved a lot of time and stress by just reinstalling. Like ArcherSeven says, after reinstalling you can copy over your files to keep all your documents and settings, etc. [Self promotion ahead :P ] I wrote a small guide on how to migrate your data from one machine to another, but it will work just as well from one drive to another. You'd be interested in the rsync bit.

http://drsjlazar.blogspot.com/2009/12/t ... puter.html

To avoid downloading all those upgrade packages again, you could copy over the packages from the apt cache in /var/cache/apt/archives/ (unless you have cleaned the cache), add the PPAs if you need to and install using the package manager... They will not be downloaded again if they are in the apt cache.

But if you are feeling ambitious, this might be helpful: http://bbs.archlinux.org/viewtopic.php?pid=723648
User avatar
shane
Level 6
Level 6
 
Posts: 1300
Joined: Sun Feb 25, 2007 11:15 pm

Re: Moving OS to another hard disk

Postby fluxalex on Fri Mar 26, 2010 9:58 pm

I'm back, now from the other disk :roll:
Here is a link referring to almost the same problem:
viewtopic.php?f=90&t=43189&start=0
After creating the partitions on "sda", I rebooted from CD and used these commands:
Code: Select all
mkdir old
sudo mount /dev/sdb1 old
mkdir new
sudo mount /dev/sda1 new
sudo cp -rp old/* new
sudo grub-install --root-directory=new/ /dev/sda

Then, since I was not sure, I manually edited the "new/etc/fstab" file - don't know if that was necessary?

But "grub" is a pain, rebooting didn't work, so I went here...
http://grub.enbug.org/Grub2LiveCdInstallGuide
...and entered these...
Code: Select all
sudo fdisk -l
sudo mount /dev/sda1 /mnt
sudo mount --bind /dev /mnt/dev
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys
sudo chroot /mnt
(optional, only if you're on Ubuntu/Debian) apt-get install grub-pc
grub-mkconfig -o /boot/grub/grub.cfg
grub-install /dev/sda (try grub-install --recheck /dev/sda if it fails)
Ctrl+D (to exit out of chroot)
sudo umount /mnt/dev
sudo umount /mnt


Now I'm happy :wink:
fluxalex
Level 1
Level 1
 
Posts: 25
Joined: Fri Feb 26, 2010 3:56 pm
Location: Silves, Portugal

Re: Moving OS to another hard disk

Postby rogue_ronin on Sun Mar 28, 2010 8:17 pm

If you have to do this again, there's a live CD called Parted Magic that can clone partitions.

m a r
rogue_ronin
Level 2
Level 2
 
Posts: 56
Joined: Sun Feb 28, 2010 5:19 am

Re: Moving OS to another hard disk

Postby fluxalex on Mon Mar 29, 2010 11:58 am

I have that CD - Version 4.9. But since the partitions are not the same size in fact it is not exactly cloning, but migrating and I'd have to resize before or after and there is still the swap partition. I spent the most time dealing with "grub", otherwise it would've taken me not much more than half an hour. And going deeper into Partition Magic I would've spent more time. Has it the feature of adjusting "fstab" and "grub" automatically? If it has, then I'll use it next time :wink:
fluxalex
Level 1
Level 1
 
Posts: 25
Joined: Fri Feb 26, 2010 3:56 pm
Location: Silves, Portugal

Re: Moving OS to another hard disk

Postby fbsduser on Sun Apr 11, 2010 10:34 pm

You could also use clonezilla. It's good for cloning partitions.
fbsduser
Level 1
Level 1
 
Posts: 19
Joined: Thu Apr 01, 2010 12:11 am

Linux Mint is funded by ads and donations.
 

Return to Fluxbox

Who is online

Users browsing this forum: No registered users and 2 guests