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

Re: "cloning" a debian installation



Hello again,

On 02/05/2014 05:16 PM, Roland Mueller wrote:
Hello,

2014-02-05 Kruppt <krupptus@fastmail.fm>:

On 2014-01-31, Kruppt <krupptus@fastmail.fm> wrote:
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

Above line should read:
rsync -av --delete /mnt/sda2/ /mnt/sdb2;rsync -av --delete /mnt/sda3/
/mnt/sdb3


to clone the whole system you should not forget hardlinks (-H), and may be
also ACL (-A) or extended attributes (-X) should be preserved.

     -a, --archive               archive mode; equals -rlptgoD (no -H,-A,-X)

When the cloned disk is updated several times, also option -u (=update only
if needed) can be used.

# rsync -avuHAX --delete /mnt/sda2/ /mnt/sdb2
there's another useful option of rsync: -x causes the synchronization to restrict the operation to a single filesystem. I.e. if there are other mounts under the source disk they will not be copied in case -x is added to the rsync command:

# rsync -avuHAXx --delete /mnt/sda2/ /mnt/sdb2

E.g. to clone the root of the currently running system, omitting /proc etc.:
# rsync -avuHAXx --delete /  /mnt/yet_another_root_disk


BR,
Roland

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)




--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact
listmaster@lists.debian.org
Archive: bletpaF5k1U1@mid.individual.net">http://lists.debian.org/bletpaF5k1U1@mid.individual.net




Reply to: