2

I have a built-in HDD (A) from which I'm running Ubuntu (currently 16.04) and a second, external HDD (B). My goal is to switch those HDDs, i.e. I want to turn HDD A into an external drive and build HDD B into my computer.

HDD B currently does not contain a bootable Ubuntu system, and my question is whether I can install Ubuntu on HDD B while HDD B is connected via USB to my current Ubuntu system running on HDD A.

I know that I can create a bootable USB drive (C), remove A, insert B, boot from C and then install Ubuntu on B. My question is whether I can skip the extra drive C and install Ubuntu directly onto B while running on A, then switch the drives and have the same result as when using the extra drive C.

That is, is the following possible (and reasonable):

  1. Run Ubuntu 16.04 on disk A, and within that system,

    1. Connect disk B via USB
    2. Install Ubuntu on disk B
  2. Shutdown the system running on disk A

  3. Remove disk A
  4. Insert disk B (i.e. connect it via SATA)
  5. Boot new system from disk B

If that is the case, how would I do it?

2
  • The following link may help, How do I install Ubuntu to a USB key? (without using Startup Disk Creator). In short: 1. Disconnect the internal drive; 2. Boot from a live USB drive (USB pendrive or DVD disk), I suggest with Ubuntu18.04.1 LTS; 3. Use the installer and install Ubuntu into the external hard disk drive. - This works in BIOS mode as well as in UEFI mode.
    – sudodus
    Commented Apr 4, 2019 at 15:41
  • 1
    Please accept the answer you think is correct by placing the green check mark (✅) on the left margin of the answer. This will help others.
    – user68186
    Commented Apr 8, 2019 at 16:35

4 Answers 4

3

The main difficulty of Installing Ubuntu to an external drive (or a second internal drive) is that the default and easy installation choices won't work. You have to manually select the correct disk and partition the disk manually. This may be a bit daunting. A small mistake may erase the wrong disk.

Yes you can! Using the ISO installation file

Ubuntu can only be installed from the installation USB/DVD or the ISO file. The ISO file is the file one downloads from the Ubuntu website. Normally one uses the ISO file and an utility to create the Live Installation USB.

In any case, you will need the ISO file. Download it from the Ubuntu Downloads site.

You will use it from within the Ubuntu in Disk A.

Alternately create an installation USB disk (C).

Steps for preparing Ubuntu in Disk A

  1. The simplest way to start the installation process from Disk A is to install an utility called grml-rescueboot.

    sudo apt install grml-rescueboot

  2. Create a folder where the ISO file will be:

    sudo mkdir /boot/grml

  3. Move the ISO file to the folder:

    sudo mv ~/Downloads/ /boot/grml/

  4. Update grub so that you get the option to boot from the installation ISO file.

    sudo update-grub

Steps to install Ubuntu in Disk B (USB)

Restart Computer. You will see the grub menu with the choices:

enter image description here

Yours may be a bit different. The top choice Ubuntu is Ubuntu in Disk A. Look for Grml Rescue System towards the bottom of the menu

  1. Select Grml Rescue System (name of the ISO file).

    1. Connect disk B via USB
    2. Install Ubuntu on disk B
      • Chose Something Else to manually select Disk B

enter image description here

You will see a list of disks and partitions like this:

enter image description here

  • Make a New Partition Table. to do this highlight the new disk, in my case /dev/vdb and click on the button New Partition Table.... You will see a warning:

enter image description here

Click Continue. Now you will see a new row below /dev/vdb called free space.

enter image description here

  • Create EFI System Partition (only if your computer has UEFI and boots in UEFI mode)

Highlight the Free Space under /dev/vdb and click on the + to create the first partition. The first partition will be a 200 MB EFI system partition. Change the size to 200 MB and the Use as:

enter image description here

(If you don't see the EFI System Partition option in the above, then you don't need it. Go to the next step.)

The Create Partition window should now look like:

enter image description here

Once you click OK, you will see partition /dev/vdb1 type efi in the window. Yours may be /dev/sdb1 or something else.

Highlight the free space below /dev/vdb1 and click on the + to create the next partition. This will be the main partition.

  • Create root system partition / in ext4 format

enter image description here

Once done, your disks and partitions will look like:

enter image description here

Similarly:

  • Create /home partition in ext4 format (only if you want to)
  • Create swap partition (needed for 16.04. 18.04 does not need it)
  • Make sure the boot loader is installed in disk B. See the above image.

    1. Shutdown the system running live from ISO on disk A
    2. Remove disk A
    3. Insert disk B (i.e. connect it via SATA)
    4. Boot new system from disk B

Alternately Use USB Disk (or Stick) C

Create an installation USB using the Startup Disk Creator in Ubuntu (booted from disk A).

enter image description here

Steps are almost the same. I am omitting the pictures:

  1. Run Ubuntu 16.04 on disk C, Live USB

    1. Connect disk B via USB
    2. Install Ubuntu on disk B
      • Chose Something Else to manually select Disk B
      • Create EFI System Partition (only if your computer has UEFI and boots in UEFI mode)
      • Create root system partition / in ext4 format
      • Create /home partition in ext4 format (only if you want to)
      • Create swap partition (needed for 16.04. 18.04 does not need it)
      • make sure the bootloader is installed in disk B
  2. Shutdown the system running live from USB on disk C

  3. Remove disk A
  4. Insert disk B (i.e. connect it via SATA)
  5. Boot new system from disk B

My answer to Dual Booting win 10 and Ubuntu 18.04 on two separate physical ssds has pictures of manual partitioning and other details.

Or you can clone Disk A to Disk B

If you want to keep your customization and data (make external backups to be safe.) you can clone all the partitions related to Ubuntu (there may be one or more) into your disk B.

However, to do this, you will still need the installation USB stick (disk C). This is because you should not clone a system partition while Ubuntu is running from that partition.

You will need to boot from the Installation USB disk C and choose the option Try Ubuntu without Installing. Then use Gparted to copy all the partitions you need from disk A to to the new disk B.

If your disk B is larger in size than disk A, you may want to expand the copied partition(s) to fill the whole disk B.

Note, the cloned partitions will have the same UUID in both the old disk A and the new disk B. This means Ubuntu may get confused at boot time if both the disks are connected. So, you must disconnect the old disk A before you boot from the new disk B.

Steps:

  1. Boot from disk C (the Installation USB)
    1. Connect disk B via USB. Make sure the disk B is detected.
    2. Use Gparted to clone the partitions from disk A to disk B.
      • Apply the changes after each copy partition operation.
    3. Expand the / partition if there is no separate /home partition. Otherwise expand the /home partition in disk B
      • Apply the changes after each expanding partition operation.
  2. Shutdown the system running on disk C (the Installation USB)
    1. Remove disk A
    2. Insert disk B (connect it via SATA)
  3. Boot new system from disk B

Hope this helps

2
  • You can install to another drive from a working drive with grub2's loopmount commands to mount an ISO directly. I have multiple ISO in a folder in my install. On reboot I can choose to boot any ISO directly. I install from sda to sdb, sdb to sda ISO folders and from ISO folder on SSD to flash drives. help.ubuntu.com/community/Grub2/ISOBoot examples help.ubuntu.com/community/Grub2/ISOBoot/Examples
    – oldfred
    Commented Apr 4, 2019 at 19:20
  • @oldfred Thanks again for reminding me the grub2 loopmount of ISO. I have now rewritten the answer.
    – user68186
    Commented Apr 4, 2019 at 21:47
2

Install Temporary Live System to External Drive

  • You can install a temporary Live system to the external drive using mkusb.

  • Then disconnect internal drive.

  • Boot the external Live system using toram.

  • Then make a Full install of Ubuntu to the external drive.

For more details see: Can Ubuntu be installed to the pendrive it was booted from?

0

Your explanation is convoluted, installing Ubuntu on external drive has been straightforward for years (unless UEFI system which require little more tweaking).

No need to remove drive during the installation to external hdd, Ubuntu will asks you which drive you want Ubuntu installed to, so theres no such thing as whether I can skip the extra drive C and install Ubuntu directly onto B while running on A.

The installation process ran on your bootable USB drive, this is what people refer to live system—it doesn't ran on your main drive.

  1. Connect External drive onto your machine
  2. Connect bootable USB onto your machine
  3. Enter BIOS, choose boot from bootable USB
  4. In Ubuntu Installation type, choose Something else
  5. Find your external drive on the list, look for drive other than /dev/sda. (Assuming you already had Ubuntu before)
  6. Once you found it—you can partition it, the basic Ubuntu installation contain:

    • Root partition /

    • Swap partition swap

  7. Click next --> continue.
  8. The rest steps is related to username, timezone etc.

Whether you can turn the external drive to internal is completely hardware related, you have to configure your external drive so it can be detected by SATA.

But at this point, your external drive should be able to boot Ubuntu.

0

It's possible via debootstrap .

I have been running Ubuntu 16.04 from such an expansion usb HDD, only caveat is that I tried it in legacy bios not in uefi, you can pick up legacy bios option from bios menu.

First you need to format your HDD with Linux compatible filesystem such as ext2, ext3, ext4

locate your HDD on /dev

 sudo parted -l

Mount your HDD, for example if it's on /dev/sdb2

make sure that /mnt is empty and not mounted

sudo mount /dev/sdb2 /mnt

change directory to /mnt

sudo debootstrap --arch=amd64 xenial /mnt  http://archive.ubuntu.com/ubuntu/

after it has been completed you need to install grub for your new HDD

 sudo grub-install –root-directory=/mnt /dev/sdb2

chroot into /mnt

but at first you need to mount some system directories in /mnt

I suppose your terminal in /mnt

sudo mount -o bind /dev dev
sudo mount -t sysfs /sys sys
sudo mount -t proc /proc proc

then

sudo chroot .

apt update 

apt install ubuntu-desktop

create a new user and install a kernel and linux modules

adduser myusername
addgroup --system admin
adduser myusername admin

install linux kernel

apt-cache search linux-image

for the current kernel :

apt install linux-image-4.4.0-145-generic linux-modules-extra-4.4.0-145-generic linux-tools-4.4.0-145-generic 

configure keyboard

apt install console-setup

dpkg-reconfigure keyboard-configuration 

generate locale

locale-gen en_US.UTF-8

update grub

grub-update

update initial ram disk

update-initramfs -u

References: https://help.ubuntu.com/lts/installation-guide/powerpc/apds04.html https://www.thegeekstuff.com/2010/01/debootstrap-minimal-debian-ubuntu-installation/

It's even possible to keep multiple distros in each directory under single partition and boot into one of them via a script.

You must log in to answer this question.

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