-1

I have a computer with a Linux distribution installed on partitions in drive /dev/sda. I also have another physical drive, /dev/sdb.

I want to install Linux to the second physical drive - to later run either on the same computer or another one. I know the planned hardware configuration of the target machine, and I have an installer for my new Linux distribution (say on a third drive, /dev/sdc, or in an ISO I can mount etc.)

Can I perform the installation without rebooting? That is, other than in the usual way of booting from an installation medium?

If this question is too general, then - can I do so with Debian Buster/Devuan Beowulf?

Note: You may make any reasonable assumption about the system, but please state it explicitly.

2
  • it's simple to clone a disk, but the actual work would be in how you setup grub to boot from the other disk (good luck on finding a useful grub tutorial) Commented May 29, 2021 at 21:50
  • @ThomasDickey: Why would I want to clone a disk?
    – einpoklum
    Commented May 29, 2021 at 22:43

3 Answers 3

2

Use dd command and copy /dev/sda to /dev/sdc if you want the same Linux installation.

1
  • 1
    sdc has the installation media, not the installed system.
    – einpoklum
    Commented May 29, 2021 at 22:43
1

You can use some kind of virtualization solution, such as virtualbox, and set /dev/sdb as the VM drive, instead of just creating a virtual HDD image. You can then proceed to install the OS on the VM and, if you are careful with your GRUB configuration, it will work.

2
  • Are you speculating, or is this a common way to do it? Also, won't I have problems booting outside of the VM, seeing how the boot loader will be looking for the virtual rather than the real disk?
    – einpoklum
    Commented Jun 2, 2021 at 9:50
  • 1
    This really isn't a common way. Yes, it should (mostly) work, but especially for debian, debootstrap is been the tool that every debian installer uses under the hood for decades now. You don't need to boot into another debian in a VM to use debootstrap. You can just do that on your current debian (or other distro, debootstrap doesn't care) Commented Jun 13, 2021 at 11:40
1

Can I perform the installation without rebooting? That is, other than in the usual way of booting from an installation medium?

Yes. That's basically what all bootable installers do under the hood. Also, it's the only way for many distros, basically. The fact that you might have a nice graphical installer running from a bootable medium is more of a nice-to-have addon.

Under debian, debootstrap is the tool for that.

See the debian wiki page for a full example. Here, partitions were already made, and the root partition was mounted as /sid-root; don't forget to also bind-mount /proc and /sys and /dev to /sid-root/proc, /sid-root/sys, /sid-root/dev respectively.

main # export MY_CHROOT=/sid-root
main # cd / 
main # mkdir $MY_CHROOT
main # debootstrap --arch i386 sid $MY_CHROOT http://deb.debian.org/debian/
[ ... watch it download the whole system ]
main # echo "proc $MY_CHROOT/proc proc defaults 0 0" >> /etc/fstab
main # mount proc $MY_CHROOT/proc -t proc
main # echo "sysfs $MY_CHROOT/sys sysfs defaults 0 0" >> /etc/fstab
main # mount sysfs $MY_CHROOT/sys -t sysfs
main # cp /etc/hosts $MY_CHROOT/etc/hosts
main # cp /proc/mounts $MY_CHROOT/etc/mtab
main # chroot $MY_CHROOT /bin/bash
...

Now you'd only need to install grub etc. I found this to be readable instructions.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .