Moving OS to another hard disk

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
fluxalex

Moving OS to another hard disk

Post by fluxalex »

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?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
ArcherSeven

Re: Moving OS to another hard disk

Post by ArcherSeven »

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
shane
Level 5
Level 5
Posts: 940
Joined: Sun Feb 25, 2007 11:15 pm
Contact:

Re: Moving OS to another hard disk

Post by shane »

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
fluxalex

Re: Moving OS to another hard disk

Post by fluxalex »

I'm back, now from the other disk :roll:
Here is a link referring to almost the same problem:
http://forums.linuxmint.com/viewtopic.p ... 89&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:
rogue_ronin

Re: Moving OS to another hard disk

Post by rogue_ronin »

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

m a r
fluxalex

Re: Moving OS to another hard disk

Post by fluxalex »

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:
fbsduser

Re: Moving OS to another hard disk

Post by fbsduser »

You could also use clonezilla. It's good for cloning partitions.
Locked

Return to “Software & Applications”