[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: "cloning" a debian installation



On 2014-01-31, Fabrice Vaillant <fa.vaillant@gmail.com> wrote:
> Hi
> I'm using debian 7.3 on my laptop (Dell E5530) and it runs perfectly 
> fine. I'm considering remplacing the hdd by a ssd.
> The thing is I'd rather not go through the hassle of setting up debian 
> to suit my computer. The question I'm asking is, what would be the 
> simplest way(if it is possible) to "clone" my existing installation onto 
> the new ssd.
> Knowing that the root and the home are on two different partition of my 
> hdd which are the only partition on my disk beside the swap.
> Howewer the ssd is smaller than the disk and the home partition will 
> need to be resized. I also consider slightly increasing the root 
> partition size as it is quitte full (77%) after running "apt-get clean".
>
> Since I am at it, I would also like to know if it is possible to remove 
> the swap as it is bad for ssd life to write and rewrite, and I have 
> plenty (8 giga) of ram.
>
> Cheers
> Fabrice
>
>

Yes you can clone it easily with rsync.
Create the partitions and filesystems on the new SSD,
via gparted or fdisk, mke2fs or whatever.
Then use rsync to clone the filesystems onto
the new SDD partitions/filesystems.

Lets say the original HDD is layed out like below
as an example, and partitions, filesystems have been created,

Boot up a LiveCD such as SystemRescueCD on a comp with
both drives connected.
Make mount points for partitions to
be cloned and mount them all. 

HDD
sda1 swap
sda2 /
sda3 /home

SSD
sdb2 swap
sdb2 /
sda3 /home

>From Root Terminal run:
rsync -av --delete /mnt/sda2/ /mnt/sdb2;rsync -av --delete /mnt/sda2/ /mnt/sdb2
This clones the two filesytems on the HDD to new SSD 
(since there is nothing on the new filesystem 
the --delete option is redundant so could be ignored)

Then you would want to install Grub.
Chroot into the / filesystem on SSD 
(sdb2 in this example)

mount --bind /proc /mnt/sdb2/proc
mount --bind /sys /mnt/sdb2/sys
mount --bind /run /mnt/sdb2/run
mount --bind /dev /mnt/sdb2/dev
mount --bind /dev/pts /mnt/sdb2/dev/pts
chroot /mnt/sdb2 /bin/bash

grub-install --root-directory=/mnt/sdb2 /dev/sdb
grub-mkconfig -o /boot/grub/grub.cfg
update-initramfs -uk $(uname -r)

exit chroot

 Then you will need to edit your fstab file,
 to reflect changes if any, especially if using
 UUID's. (Run blkid -c /dev/null, the output will
 show the UUID's, then edit fstab to reflect new UUID's)
 


Reply to: