1

I have specific Linux installed on SSD drive. What I want to do is to copy all ext4 partition files to other drive (also ext4) and make it bootable. Copy should be as similar as possible differentiating only in partition size and physical location of the files.

I understand that I need to make /boot/ folder the same, but what about GRUB? How can I make the target drive bootable?

Copy of whole partition/disk is not applicable here - I need instruction how to make bootable a copy of ext4 filesystem.

pbies
  • 169
  • 13
  • 2
    A starting point might be "man grub-install" - or https://www.gnu.org/software/grub/manual/grub/html_node/Installing-GRUB-using-grub_002dinstall.html – davidgo Dec 25 '19 at 05:56

3 Answers3

0

Based on @davidgo comment I successfully made a bootable copy of Linux. The commands are:

# mount target partition at /mnt
mount /dev/target1 /mnt
# make copy of all files excluding on-line folders
rsync -aAXv --delete --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / /mnt
# mount on-line folders inside /mnt
mount -t proc proc /mnt/proc
mount -t sysfs sys /mnt/sys
mount -o bind /dev /mnt/dev
# chroot to target
chroot /mnt
# install and update grub on target MBR
grub-install /dev/target
update-grub2 /dev/target
# leave chroot
exit
# unmount on-line folders and the target partition
umount /mnt/proc
umount /mnt/sys
umount /mnt/dev
umount /mnt

You may want to use lsblk to see which is your target drive and its partition. You may want to partition it first and make ext4 filesystem:

fdisk /dev/target
mkfs.ext4 /dev/target1

Update to /etc/fstab on the target partition could be needed (else system won't boot).

pbies
  • 169
  • 13
-1

You could use Clonezilla, and clone the partition (including the boot sector). Later on, you could expand the partition into a bigger one.

https://clonezilla.org/downloads.php

Another option could be to run a FOG Server on the network (a PXE backup server). This one would allow you to backup the disk to another system (a 3rd computer, or even a VM if you want to), then restore the backup from the 1st computer to the 2nd computer. When you create the image, make it re-sizable, this way you could restore it to a smaller disk.

https://fogproject.org/

  • Not the way I want to do that. Need to learn how to make bootable the copy, not making exact copy of whole partition. – pbies Dec 24 '19 at 23:56
  • Ok, so ... I get a negative vote, for giving you a perfectly good answer (I didn't know that you wanted to learn or what your intentions were)to a question that you edited after my answer. Great. Good to know. Like another answer said (with no negative votes) check the manual! – DIYTony Dec 31 '19 at 19:47
  • Please read the questions carefully before answering. This is exact question even without this edition. – pbies Dec 31 '19 at 23:07
-1

Step1: Create Bootable USB Drive for Linux. Start PowerISO (v6.5 or newer version, down load here). ... Step 2: Configuring the BIOS. You have to now reboot and go into the BIOS configuration to boot from USB. ... Step 3: Booting and setup or run Linux from USB drive.

Carm
  • 1