Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question

3 Answers 3

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).

share|improve this answer
    
Thanks! What should I copy if I want a clean installation? Is there some zip distribution of Ubuntu for this purpose? –  Ondra Žižka Oct 22 '12 at 15:38

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.

share|improve this answer
    
A persistent pendrive lacks some features of a full installation. –  hexafraction Oct 16 '12 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. –  Maciej Szlosarczyk Oct 16 '12 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. –  hexafraction Oct 16 '12 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. –  Ondra Žižka Oct 22 '12 at 15:36

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

Good luck!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.