# Installing Ubuntu to an external hard drive



## AMW1 (Sep 22, 2010)

Im trying to install Ubuntu to a 1Tb external hard drive, Ive been struggling to do this or find info on how to do it. To make thing a little more complicated (and one of the reasons Im struggling) is that there are a number of thing I want to do:
1. Partition the hard drive so that about 300Gb is the Ubuntu partition(s) the rest is a backup for my computer
2. I want to avoid any issues with GRUB/MBR 
3. I only want to see the select operating prompt if the external HDD is attached (if the drive is attached and it boots strait to Ubuntu I can live with that).
4. Id also like to be able to run it on other computers and see the E drive of my laptop but these are not essential. 
I am currently running Window 7 Home Premium 32bit (which I have the disk for) on a laptop. 
Ive been curious about running a Linux partition and using mostly free software on it and seeing how well it/they work, whether there any good and how easy it is to write documents and exchange them with most people running Microsoft programs before I consider a complete switch away from Microsoft . 
Any help is appreciated thank you.


----------



## 1002richards (Jan 29, 2006)

Hi,
I dual boot Vista & Ubuntu on a laptop so can't help on the external drive scheme.

However, Ubuntu comes with OpenOffice which is compatible with Word, Excel etc. Some people are swapping that for LibreOffice which is also compatible with Word, Excel etc.

Here's one site that lists Linux alternatives to Windows progs
http://linuxappfinder.com/alternatives

Within Ubuntu you have access to the Ubuntu Software Centre (quote) "The Ubuntu Software Centre offers hundreds of games, including puzzles, adventures, tactical challenges and more. All free to choose and free to use."

A good read "Linux is not Windows" http://linux.oneandoneis2.org/LNW.htm

Hope this helps?
Richard


----------



## saikee (Jun 11, 2004)

My answers

(1) This is easy. Just click a terminal when running Ubuntu as a Live CD (to try it instead of installing it) and type 

```
sudo
fdisk -l
cfdisk /dev/sdb
```
The "fdisk -l" will display all partitions of every hard disk. I am assuming device sdb is the external hard disk so issue the command cfdisk to partition it.

(2) No issue with Grub if you understand MBR is the first sector of a hard disk so you will have three choices of putting Ubuntu's Grub to (1) sda which will be your Win7 disk, (2) sdb which will be your external hard disk and (3) sdb1 the first 300Gb partition you create in device sdb.

(3) You have a dilema here. You have to allow the boot loader to display the Ubuntu even it is not bootable without the external disk attached. Win7 boot loader bootmgr, using Bios calls, is not known to boot system on a removable disk so you have to let Grub to sit in the MBR of sda. This is totally safe as Win7 MBR can be regenerated any number of times using a Vista/Win7 installation DVD.

As Grub needs its stage2 in booting so you have to install Grub onto the \boot directory of Win7. Ubuntu has Grub2 that can read a NTFS partition. Thus you can have Grub2 and Win7's bootmgr co-exist in the \boot. It works well but requires manually copy Grub2 files over from the external disk into the \boot directory of Win7. Thus you will have Grub2 in both the external disk as well as the Win7 internal disk. When the external disk is removed Grub2 can still work noirmally. The connection between sda MBR and the Grub2 in WIn7 \boot is made using the grub-install command when you run the Ubuntu.

(4) This you can do if

(i) Each other computer is capable of booting from a USB device
(ii) You have Grub2 installed in the MBR of the external disk sdb (in additional to it on sda)

I have moved the internal disk of Ubuntu between computers and the bugger fires up without any issue. In your case Ubuntu will boot as it uses UUID reference instead of the normal device name.


----------



## DVOM (Jun 21, 2002)

I have installed Ubuntu to a 8 Gig USB stick. When I did it, I installed Grub to the USB stick which kept the windows 7 bootloader so it would go straight to Win7.

All I needed to do to boot the Ubuntu USB was to hit F12 while powering up to get to the boot menu, choose USB and go from there. It would then go straight to Grub then Ubuntu. 

If the USB Ubuntu stick wasn't plugged in, the machine would just boot straight to Windows.

I thought it was a fairly convenient setup.


----------



## saikee (Jun 11, 2004)

Using the Bios to have a pre-fix booting order for the device is definitely simpler.

The OP has to amend the Grub menu if Windows were selected for booting though. The alteration involves altering the disk order on-the-fly but Grub can do that.


----------



## AMW1 (Sep 22, 2010)

Ive tried what saikee suggested but have fallen at the first hurdle, when I type the fdisk L command and I dont see anything and when I run the next command I get an error message Ive included two screen shots to help.


----------



## DVOM (Jun 21, 2002)

I believe the Ubuntu Live CD comes with GParted for creating/manipulating partitions. That might be a little easier for someone who's not familiar with Linux.


----------



## jrbuergel (Jan 17, 2004)

To get that list of your hard drives partitions with the fdisk -l command, in Ubuntu be sure to type this; " sudo fdisk -l " and then give your password. So enter the sudo with that command on the same line, and not as a separate command.


----------



## saikee (Jun 11, 2004)

Try copy and paste the commands I posted in Post #3.

If "sudo su" is issued first Ubuntu will change the user status to root after a correct password (for the user as there is not root password in a standard Ubuntu installation).

I favour "sudo su" because that is equivalent to a standard Linux command "su" outside the Ubuntu family. Ubuntu's approach is to supersede every command with "sudo" which seems to be different but it uses essentailly the same set of BASH commands of every Linux kernel. I have to admit that being a normal user and prefix every system-related command with "sudo" does increase the system security. However I also believe it is equally relevant that a Linux user familar with Ubuntu should be able to use any other Linux and vice versa so may be knowing the small difference of ubuntu from others would be helpful.

The "l" in "fdisk -l" is the lower case of "L".

Ubuntu will display nothing for "fdisk-l" to a normal user but to a root user the full information will be provided.

The reason I favour fdisk, which is a terminal command for partitioning only, and not gparted which is a GUI application because the latter combines partitioning with formatting in most of its applications.

To a new beginner to Linux or MS Windows it pays to know that partitioning and formatting are two different operations. The former is totally reversible (before the partition has been written on) and the latter is irreversible. The understanding of the two will benefit any PC user using a hard disk in general and in particular using more than one operating system on the same hard disk.


----------



## AMW1 (Sep 22, 2010)

Ive got as far as getting all the commands working, I now just need to partition the drive and install Ubuntu. Ive included screen shots to show you where Im up to.
Just a side not to anyone trying this, the drive I was using was in NTFS I had to reformat the drive while running the Ubuntu live CD to FAT (dont try it in Windows as it does not work and you cant see the drive) 
Also run the sudo fdisk l command before the sudo fdisk -l chdisk command to check the name of the device first as mine was not sdb (see my previous screen shots).


----------



## saikee (Jun 11, 2004)

OK your second screen shot confirms that sdd now is empty. You can use fdisk to create partitions for Ubuntu installation. In your case I would recommend cfdisk instead of fdisk as the former is more user-friendly but the latter is very powerful if you know how to use scripts.

Use this command to partition sdd

```
cfdisk /dev/sdd
```
you then create sdd1 say size 1Gb and type 82 for swap and then sda2 with say 50 to 100Gb for Ubuntu. Any partition you create with a Linux partitioning tool will default to Type 83 which is native to Linux. You only need to change Type for swap, NTFS or Fat.

As a rule all "terminal" partitioning tools in Linux only do partitioning. This is to define the boundary of the partitions but the created partitions have no filing system inside. A partition without a filing system inside cannot be mounted regardless it is in Linux , Dos or MS Windows. You need to format the partition before it can be mounted.

For installation there is no need to format the partition itself. Leave this to the installer. In fact many installers do trust the user and would reformat it regardless. Traditionally it is an installer's duty to reformat the partition so go with the flow. A MS Windows for example will do it without asking the user.

Thus after the partitions sda1 and sda2 have been created to put Ubuntu into sda2 just click the installer which is visible in the desktop screen. In its disk partitioning section you select the option to choose your own arrangement. Ubuntu will then present the partitions suitable for its installation and that should be sda2. You then highlight it, select to format it in Ext4 filing system and mount it as /.

The installer will then put Ubuntu inside sda2 and configure it to use sda1 because it is recognised by every Linux as swap. Some distros, like the Slackware family may ask your permission to use the sda1 as swap but Ubuntu will do it automatically without consulting you.


----------



## AMW1 (Sep 22, 2010)

Ive got the grey partition screen up Ive entered the sizes of the partitions but when I write the partitions I get the message 
Wrote partition tables, but reread failed.
The installer is also not seeing the partitions
Ive included a screen shot if it helps


----------



## saikee (Jun 11, 2004)

In partitioning use the standard device name like sdd1, sdd2 etc and let the system generates them.

If you want a trouble free installation just write the partition table, exit, do a reboot so that the kernel can detect the new partition table..


----------



## AMW1 (Sep 22, 2010)

Whatever I did last time I rely made a mess of it, when I try to run the cfdisk I get the error
Fatal error: bad partition 0: partition ends in the final partial cylinder 
I tried to reformat the disk in window (quick and long) and in Ubuntu, I deleted the volume using windows disk manager with no luck.


----------

