The officially official Devuan Forum!

You are not logged in.

#1 2021-12-24 04:23:55

erdos
Member
Registered: 2018-06-04
Posts: 88  

how to clone a partition with os installed?

hey guys

I've an existing SSD with devuan 4 installed.  and i just purchased another SSD and would like to clone my existing devuan 4 os and /home partition.  is there an easy way to achieve this?

# 1 SSD
/root  partition has 20G, /home partition is 35G

erdos@htpc-devuan:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            2.0G     0  2.0G   0% /dev
tmpfs           394M  2.6M  391M   1% /run
/dev/sda1        19G  8.5G  8.8G  50% /
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           1.2G  258M  914M  23% /dev/shm
/dev/sda5        35G   19G   15G  57% /home
tmpfs           394M   16K  394M   1% /run/user/1000

new SSD is 256G,  and I plan to use 64G for root partition, and rest for /home partition.

Offline

#2 2021-12-24 05:22:04

hevidevi
Member
Registered: 2021-09-17
Posts: 230  

Re: how to clone a partition with os installed?

You could use refractasnapshot and refractainstaller for this.

refractasnapshot-base/stable 10.2.12 all
  tool to create a live-CD from the running system

refractasnapshot-gui/stable 10.2.12 all
  tool to create a live-CD from the running system

refractainstaller-base/stable 9.6.0 all
  tool to install a running live-CD to hard drive.

refractainstaller-gui/stable 9.6.0 all
  tool to install a running live-CD to hard drive.

Install either cli tool and or gui and read the documentation.

Offline

#3 2021-12-24 15:12:06

pcalvert
Member
Registered: 2017-05-15
Posts: 192  

Re: how to clone a partition with os installed?

I would boot from a live CD/DVD/USB system and use partclone to clone the partitions. I would use Refracta or the Devuan live DVD and install partclone using apt. Alternatively, you could use the GParted live CD, which comes with partclone. However, the GParted live CD seems a little rough around the edges, and is based on Debian Sid, so I'd recommend that you not use it.

Download links for Devuan:
https://www.devuan.org/get-devuan

Download links for Refracta:
https://get.refracta.org/

Info about the GParted live CD:
https://gparted.org/livecd.php

Download links for the GParted live CD:
https://sourceforge.net/projects/gparte … ve-stable/


Freespoke is a new search engine that respects user privacy and does not engage in censorship.

Offline

#4 2021-12-24 18:24:50

felixed
Member
Registered: 2021-10-28
Posts: 42  

Re: how to clone a partition with os installed?

I'm using fsarchiver for years. It's not installed by default, but included in standard sources. Never had any problem.

Some tips to use it (you need tune2fs and a super grub disk too):

# ***  save partition sdb1 to /media/XXX/partition12345.fsa ***
#
# clear trash + apt-get clean
# run maintenance system, unmount sdb1 (safer, but I never had any trouble when saving the running system itself)
#
# save:
# -o (overwrite without question)
# -j2 (use 2 CPU cores)
# -A -a (save mounted partition)
# -v (show process information)
# -z3 (compression strength between 1 and 9, replaced by -Z[x])
#
# as root

fsarchiver savefs -o -j2 -A -a -v -z3 /media/XXX/partition12345.fsa /dev/sdb1

#
# *** restore to /dev/nvme1n1p6 ***
#
# run any Linux with fsarchiver installed or remain within running system
#
# mkfs - partition type, usually unnecessary
#
# as root

fsarchiver restfs -o -j2 -v /media/XXX/partition12345.fsa id=0,dest=/dev/nvme1n1p6

# ,mkfs=ext2
#
# when installing onto the same computer it needs a new UUID before mounting!

tune2fs -U random /dev/nvme1n1p6

# mount
# get UUIDs

blkid

# change UUIDs in /etc/fstab of restored system
# reboot into restored system by super grub disk / Rescatux (did I mention before that you need it?)
# install bootloader from within new system, it's important *****!!!!!

grub-install /dev/nvme1n1
update-grub

# change boot device in BIOS

Last edited by felixed (2021-12-25 19:54:26)

Offline

#5 2021-12-24 18:50:15

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: how to clone a partition with os installed?

felixed wrote:

# install bootloader from within new system, it's important *****!!!!!

grub-install /dev/nvme1n1p6
update-grub

For non-UEFI systems it is strongly recommended to install GRUB's core.img to the block device rather than the partition. If it is installed to the partition it can be "lost" during fsck operations and is generally more fragile. GRUB itself will give a warning about this if it is attempted.

And it's also best to update the debconf database with the new location rather than running grub-install manually:

dpkg-reconfigure grub-pc
update-grub

EDIT: I did post a manual method earlier but changed my mind and deleted it. Here it is again but without the manual partitioning bit because I decided that was too likely to wreck the system if the wrong device was given...

So this presumes you have already partitioned and formatted the new drive, which is identified hereafter as /dev/sdX — replace X with the correct letter and use lsblk -f to check (it will show which partitions are already mounted).

First mount the two partitions (this presumes the first partition is for / and the second is for /home, correct as needed):

mount /dev/sdX1 /mnt
mkdir /mnt/home
mount /dev/sdX2 /mnt/home

Then copy the system over:

apt install rsync
rsync -aAXHv --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / /mnt
sync

Wait for the sync command to return the prompt to ensure the copy buffers are all flushed to the drive.

Now generate a new fstab and chroot into the system to install & configure the bootloader:

apt install arch-install-scripts
genfstab -U /mnt > /mnt/etc/fstab
arch-chroot /mnt
dpkg-reconfigure grub-pc
update-grub

Finally exit the chroot and un-mount  the drive:

exit
umount /mnt/home
umount /mnt

That's it.

Last edited by Head_on_a_Stick (2021-12-24 20:25:28)


Brianna Ghey — Rest In Power

Offline

#6 2021-12-24 21:02:28

xinomilo
Unknown
Registered: 2017-07-02
Posts: 315  

Re: how to clone a partition with os installed?

clonezilla is another package/livecd for cloning drives/partitions.

Offline

#7 2021-12-25 19:57:37

felixed
Member
Registered: 2021-10-28
Posts: 42  

Re: how to clone a partition with os installed?

Head_on_a_Stick wrote:
felixed wrote:

# install bootloader from within new system, it's important *****!!!!!

grub-install /dev/nvme1n1p6
update-grub

For non-UEFI systems it is strongly recommended to install GRUB's core.img to the block device rather than the partition.

Thanks, my mistake. I changed the command and of course I do not install it to a partition.

Offline

Board footer