5

I'd like to install Ubuntu on a disk which is connected (but not mounted), without booting from a DVD or USB. The goal is to have Ubuntu installed on an external disk, unplug it, plug it to other computer and run.

I know it takes 20 minutes etc etc. I simply want to do it from a running system, without need to reboot that.

What are my options?

Edit: To make it clearer, I have this scenario:

  • my friend comes with an empty disk
  • I install the system on that disk from my running system (Ubuntu)
  • friend puts the disk back to his machine and boots this installed system.

So solutions with USB key or copying my own system are not what I need.

3 Answers 3

5

If you are in an Ubuntu machine, then you can just copy the running system in the external hard drive.

Let us assume you already partitioned the external hard drive. For this example I am going to use 2 partitions: / and /home.

$ sudo mkdir -p /target
$ sudo mount /media/external-hdd/main /target
$ sudo sync
$ sudo cp -ax / /target
$ sudo mount /media/external-hdd/home /target/home
$ sudo cp -ax /home /target/home

cp -ax does not cross different file system and it is archived (preserve permissions, does not follow symlinks, etc.)

Then, you have to update the grub settings and the fstab in the target disk. You can use chroot, but before, you will need:

$ sudo mount -o bind /sys /target/sys
$ sudo mount -o bind /proc /target/proc
$ sudo mount -o bind /dev /target/dev

Now you are ready to chroot:

$ sudo chroot /target
# (now you are in the external HD as root)

Now, you have to update the UUIDs in your fstab and grub. In order to get the UUID, you can run:

# blkid

Then, replace in /etc/fstab the UUID with the appropriate id gotten with blkid.

The last step is to update the configuration for booting and install the bootloader in the external hard drive. In my case I use grub, so, I have edit /boot/grub/menu.lst. There you have to replace the line that starts with # kopt=root=UUID=... ro and replace the content of UUID to the partition that has root file system.

# grub-install /device/name
# update-grub

Where /device/name is the external hdd.

Then, you can exit of chroot and unmount the devices.

# ^D
$ sudo umount /target/sys
$ sudo umount /target/proc
$ sudo umount /target/dev
$ sudo umount /target/home
$ sudo umount /target/

And the disk should be ready to be used. Once you boot it, it might ran fsck, because it was not unmount properly (you copied the content live).

1
  • 1
    Thanks! What should I copy if I want a clean installation? Is there some zip distribution of Ubuntu for this purpose? Oct 22, 2012 at 15:38
3

You can use debootstrap for that, that should be exactly what you need. Take a look at this link.

1
  • This looks it is what I am looking for. Feb 12, 2017 at 2:27
2

If you have the ISO image you can create a bootable USB with a live system with either of those 2 tools mentioned in this article:

https://wiki.ubuntu.com/LiveUsbPendrivePersistent

Just type in USB in the unity and a program to create such a disk will appear.

4
  • A persistent pendrive lacks some features of a full installation.
    – nanofarad
    Oct 16, 2012 at 0:29
  • What is so important that it is missing in the persistent pendrive with space for user files? Maybe I understood it differently, but the goal is to create something that can be booted on every machine, right? If you would like to only prepare something to install on a different machine then a far better choice is dd or unetbootin. Oct 16, 2012 at 16:05
  • The problem is that certain low-level things like bootloaders are different, and drivers are difficult to load for special disk controllers. A better idea would be keeping an entire live CD extracted to a folder(extract the entire Squashfs file from the CD) and chroot into it to run Ubiquity as needed.
    – nanofarad
    Oct 16, 2012 at 19:11
  • Maciek, the goal was rather to install Ubuntu without leaving my comp. I help friends installing it quite often, and I don't want to ride on my chair from one table to another several times :) So I rather ask them to bring a disk and install to it. Oct 22, 2012 at 15:36

You must log in to answer this question.

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