Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Disk Clone Options?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo Chat
View previous topic :: View next topic  
Author Message
dataking
Apprentice
Apprentice


Joined: 20 Apr 2005
Posts: 251

PostPosted: Wed Jan 08, 2014 8:38 am    Post subject: Disk Clone Options? Reply with quote

This is probably a general linux question, as much as it is a gentoo question, so hopethis is the right place to post it.

I have an older laptop that I've loaded with gentoo and am so far, fairly happy with the installation itself and all of the packages I have installed. Everything seems to work great (for the most part) and I don't want to change what I have going on, and I don't want to have to reinstall gentoo and all the packages I currently have installed.

My issue if that the harddrive that came with the laptop is only 40GB. And while that's enough to "work with", I'd prefer a little more "elbow room" on the disk. I only have 1 disk port available, so that means that I need to "clone" the existing 40GB disk to whatever new disk I buy.

So, what's the best way to "clone" the existing disk onto a new disk, including grub data, etc., and be able to use the entire space of the new disk (say 250-500GB SATA/IDE)?
_________________
-= the D@7@k|n& =-
Back to top
View user's profile Send private message
i92guboj
Bodhisattva
Bodhisattva


Joined: 30 Nov 2004
Posts: 10306
Location: Córdoba (Spain)

PostPosted: Wed Jan 08, 2014 8:53 am    Post subject: Re: Disk Clone Options? Reply with quote

dataking wrote:
This is probably a general linux question, as much as it is a gentoo question, so hopethis is the right place to post it.

I have an older laptop that I've loaded with gentoo and am so far, fairly happy with the installation itself and all of the packages I have installed. Everything seems to work great (for the most part) and I don't want to change what I have going on, and I don't want to have to reinstall gentoo and all the packages I currently have installed.

My issue if that the harddrive that came with the laptop is only 40GB. And while that's enough to "work with", I'd prefer a little more "elbow room" on the disk. I only have 1 disk port available, so that means that I need to "clone" the existing 40GB disk to whatever new disk I buy.

So, what's the best way to "clone" the existing disk onto a new disk, including grub data, etc., and be able to use the entire space of the new disk (say 250-500GB SATA/IDE)?


You'll need either a way to connect the new disk to your laptop, or a temporary space to clone the disk image, and then dump it to the new disk in another computer.

To clone a block device in Linux you use 'dd'. For example, to clone a whole disk as is 1:1 you do this:

Code:
dd if=/dev/sda of=/mnt/whatever_media/sda.img


To clone just a partition you'd use if=/dev/sda1 instead. You probably want to clone the disk, so that the boot record is also copied. Then, you can dump it back in place using

Code:
dd if=/mnt/whatever_media/sda.img of=/dev/sdX


Being sdX the device node that points to the new drive.

Of course, this will leave empty space after the existing partitions in the new drive. You can use a gparted livecd or something similar to expand the partitions or create new ones that you can later mount at /home or wherever you want.

Another way would be to just backup the existing data, which will produce a probably much smaller result. After that, all you would need to restore would be a livecd, from where you can recreate the partition layout as you wish, then un-tar the backup, and finally adjust fstab and re-install grub or whatever bootloader you use. You need to be careful when copying, and make sure that you preserve permissions and ownership of the files.

Either way will work just as well.
_________________
Gentoo Handbook | My website
Back to top
View user's profile Send private message
hadrons123
Tux's lil' helper
Tux's lil' helper


Joined: 08 Mar 2012
Posts: 90
Location: chennai

PostPosted: Wed Jan 08, 2014 1:14 pm    Post subject: Reply with quote

@OP.
please use clonezilla live CD image. Its easy with a GUI menu available to backup the disk which ever way you would want.
I use it on a daily basis multiple times. Never fails.
http://downloads.sourceforge.net/clonezilla/clonezilla-live-2.2.1-22-amd64.iso
_________________
LENOVO Y580 FHD Intel® Core™ i7-3630QM CPU @ 2.40GHz × 8 |660M GTX NVIDIA | 16GB SanDisk SSD
Back to top
View user's profile Send private message
djdunn
l33t
l33t


Joined: 26 Dec 2004
Posts: 780
Location: Arrakis

PostPosted: Fri Jan 17, 2014 6:24 pm    Post subject: Reply with quote

can always get a usb 3.0 to SATA adapter,

just plug the drive into one end plug into usb and go
_________________
A process cannot be understood by stopping it. Understanding must move with the flow of the process, must join it and flow with it.

-The First Law of Mentat
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 44050
Location: 56N 3W

PostPosted: Fri Jan 17, 2014 10:10 pm    Post subject: Reply with quote

dataking,

You don't want to clone the disk, you want to clone the filesysems it contains, which is not the same thing.
dd will make a disc image, which will include all the empty file system space too, so your clone will be 40G.

You can use tar to make a copy of the file systems, so empty space is not saved.
tar has the advantage of not imposing the low level device layout on your new drive.
Before you untar the files in their new home you need to partition and format the new drive.
It need not be identical to the old drive.

You will need to reinstall grub to the MBR of the new drive as grub uses space outside of any filesystem, so this is not saved by tar.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
wjb
Guru
Guru


Joined: 10 Jul 2005
Posts: 406
Location: Fife, Scotland

PostPosted: Sat Jan 18, 2014 12:53 pm    Post subject: Reply with quote

What hadrons123 said.

This is a listing of an image created by clonezilla:
Code:

disk                       sda2.ext4-ptcl-img.gz.aa  sda8.ntfs-ptcl-img.gz.af
Info-dmi.txt               sda2.ext4-ptcl-img.gz.ab  sda8.ntfs-ptcl-img.gz.ag
Info-lshw.txt              sda4.ext4-ptcl-img.gz.aa  sda8.ntfs-ptcl-img.gz.ah
Info-lspci.txt             sda4.ext4-ptcl-img.gz.ab  sda8.ntfs-ptcl-img.gz.ai
Info-packages.txt          sda4.ext4-ptcl-img.gz.ac  sda9.ext4-ptcl-img.gz.aa
parts                      sda4.ext4-ptcl-img.gz.ad  sda9.ext4-ptcl-img.gz.ab
sda10.ext3-ptcl-img.gz.aa  sda4.ext4-ptcl-img.gz.ae  sda9.ext4-ptcl-img.gz.ac
sda1.ntfs-ptcl-img.gz.aa   sda4.ext4-ptcl-img.gz.af  sda9.ext4-ptcl-img.gz.ad
sda1.ntfs-ptcl-img.gz.ab   sda5.ext4-ptcl-img.gz.aa  sda9.ext4-ptcl-img.gz.ae
sda1.ntfs-ptcl-img.gz.ac   sda5.ext4-ptcl-img.gz.ab  sda-chs.sf
sda1.ntfs-ptcl-img.gz.ad   sda5.ext4-ptcl-img.gz.ac  sda-hidden-data-after-mbr
sda1.ntfs-ptcl-img.gz.ae   sda7.ext2-ptcl-img.gz.aa  sda-mbr
sda1.ntfs-ptcl-img.gz.af   sda8.ntfs-ptcl-img.gz.aa  sda-pt.parted
sda1.ntfs-ptcl-img.gz.ag   sda8.ntfs-ptcl-img.gz.ab  sda-pt.sf
sda1.ntfs-ptcl-img.gz.ah   sda8.ntfs-ptcl-img.gz.ac  swappt-sda6.info
sda1.ntfs-ptcl-img.gz.ai   sda8.ntfs-ptcl-img.gz.ad
sda1.ntfs-ptcl-img.gz.aj   sda8.ntfs-ptcl-img.gz.ae

i.e. It has enough information to be very flexible for the restore - with a bigger disk you can create the new partitions before you start, let it scale the partions in proportion, or just leave the extra space unallocated (and deal with it manually).
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo Chat All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum