Copy Your Linux Install to a Different Partition or Drive
If you need to move your Linux installation to a different hard drive or partition (and keep it working) and your distro uses grub this tech tip is what you need.
To start, get a live CD and boot into it. I prefer Ubuntu for things like this. It has Gparted. Now follow the steps outlined below.
- Mount both your source and destination partitions.
Run this command from a terminal:
$ sudo cp -afv /path/to/source/* /path/to/destinationDon’t forget the asterisk after the source path.
- After the command finishes copying, shut down, remove the source drive, and boot the live CD again.
- Mount your destination drive (or partition).
- Run the command “gksu gedit” (or use nano or vi).
Edit the file /etc/fstab. Change the UUID or device entry with
the mount point / (the root partition) to your new drive.
You can find your new drive’s (or partition’s) UUID with this
$ ls -l /dev/disk/by-uuid/
- Edit the file /boot/grub/menu.lst. Change the UUID of the appropriate entries at the bottom of the file to the new one.
- Run sudo grub.
At the Grub prompt, type:
find /boot/grub/menu.lstThis will tell you what your new drive and partition’s number is. (Something like hd(0,0))
root hd(0,0)but replace "hd(0,0)" with your partition’s number from above.
setup hd(0)but replace "hd(0)" with your drive's number from above. (Omit the comma and the number after it).
That’s it! You should now have a bootable working copy of your source drive on your destination drive! You can use this to move to a different drive, partition, or filesystem.
Webinar: 8 Signs You’re Beyond Cron
11am CDT, April 29th
Join Linux Journal and Pat Cameron, Director of Automation Technology at HelpSystems, as they discuss the eight primary advantages of moving beyond cron job scheduling. In this webinar, you’ll learn about integrating cron with an enterprise scheduler.Join us!
|Android Candy: Intercoms||Apr 23, 2015|
|"No Reboot" Kernel Patching - And Why You Should Care||Apr 22, 2015|
|Return of the Mac||Apr 20, 2015|
|DevOps: Better Than the Sum of Its Parts||Apr 20, 2015|
|Play for Me, Jarvis||Apr 16, 2015|
|Drupageddon: SQL Injection, Database Abstraction and Hundreds of Thousands of Web Sites||Apr 15, 2015|
- DevOps: Better Than the Sum of Its Parts
- "No Reboot" Kernel Patching - And Why You Should Care
- Return of the Mac
- Android Candy: Intercoms
- Drupageddon: SQL Injection, Database Abstraction and Hundreds of Thousands of Web Sites
- Designing Foils with XFLR5
- Non-Linux FOSS: .NET?
- Play for Me, Jarvis
- Consent That Goes Both Ways