Logo.png
Ubuntu Karmic Koala Encrypted Flash Memory  Installation
Edited Wednesday, November 18 2009 Document made with KompoZer

Ubuntu 9.10 Karmic Koala - currenty under development

Ubuntu Release Cycle - ubuntu.com

Ubuntu 9.10 Karmic Koala Release Schedule - wiki.ubuntu
This web-page is part of a larger site giving examples of how to install Windows+Ubuntu Linux operating systems 'dual boot' in a computer.  Illustrated Dual Boot HomePage.

This is not a dual boot installation.

This install guide is about how to install Ubuntu 'Karmic Koala' in a USB flash memory stick or Solid State Drive with the LUKS encrypted ext4 file system by running the Ubuntu Karmic Koala 'Alternate CD'.

Flash technology is advancing rapidly and now SSD drives are starting to become affordable to the average consumer. SSD drives contain flash memory and are more robust than mechanical hard drives, they withstand physical shock and all kinds of environmental extremes better. They run cooler and use less power because they contain no moving parts. SSD drives are also much faster than mechanical hard disc drives. Flash memory isn't called 'flash' for nothing.
p19/vertex_01.png
p19/vertex_02.png
p19/vertex_03.png

You may want to install Ubuntu Karmic Koala in a USB flash memory stick or SSD if you want to be able to carry your entire operating system along with all of your files and settings around with you in your pocket. Files people may need will probably including work and business files as well as vital personal information, passwords and so on.
Unfortunately, they're also easy to lose, misplace or to have stolen from you. Without an encrypted file system anyone with physical access to your USB flash memory stick, SSD drive or laptop or can access all of your files. If you own a USB flash memory stick or a laptop with an operating system installed in it, you should at least have an encrypted /home directory to protect any sensitive files from unauthorized access. 

The Karmic Koala 'Alternate Installation' CD allows us to easily install our Ubuntu operating system in a fully encrypted ext4 file system. With an encrypted file system, only someone who knows your pass phrase can access your personal information or your corporate, political or military secrets.

The ext4 file system will be the new default file system for Ubuntu. Ext4 is by far the most advanced file system available today for SSD drives and flash memory. The ext4 file system is ready to support the new ATA TRIM command for flash memory, as soon as flash memory and SSD manufacturers begin to make hardware available that will support the new command.

Drives plugged in by the USB connection have never been as fast as drives plugged in by IDE or SATA cables, so of course the operating system will work a little slower. That is to be expected.
New technology in USB drives is just around the corner, it's called USB3, and basically it will mean that in the future the USB interface will be about the same speed as a SATA_II connection, and roughly ten times faster than the high speed USB we use now.
LINKS:
youtube: YouTube - @ - USB 3- (butterscotch.com)
youtube: USB3.0 - (Nostromo2k50)
youtube: USB 3.0 live demo: USB IF chairman Jeff opening & Sarah - (michelle8885)
Did you notice that the laptop in the last youtube link is running Ubuntu? Cool!  :)

For now though the reality is, most of us are still stuck with plain old fashioned USB flash memory sticks or USB external hard disk drives. I've made the leap and invested in a real SSD. I know I won't have any USB3 capable hardware for some time yet though. Even so, it's still good practice to try to do the best we can with what we have.
To perform this installation you will need,
  • a Ubuntu Karmic Koala 'Alternate Installation' CD for i386 PCs
  • access to a computer with a CD/DVD drive to run the 'Alternate Installation' CD in
  • an 8 GB or more USB flash memory stick would be best, but Ubuntu will fit in one as small as 4 GB if that's all you have. An SSD drive would be the ultimate.
The length of time this installation might take will depend mainly on the write speed of the flash memory stick or or the transfer speed of the slowest piece of hardware involved in the operation.
A normal Ubuntu  installation to a hard disk in a standard computer, for example one with a 3.0 Ghz CPU and 512 MB or RAM, might take about half an hour.
Most USB flash memory sticks are pretty slow to write to. This installation could take a while if you're using a flash memory stick. Write speeds vary greatly between different kinds of flash memory sticks.
I think an average flash memory stick should take around one or two hours to install Ubuntu in. The slowest USB flash memory stick I have tried took almost three hours to perform this installation.
Once the system has been installed, it will run okay in most flash memory sticks because most flash memory is quite fast to read from and that makes up for it's slowness with disk writes. Most of us probably do a lot more reading than writing.
SSD drives are much faster to write than flash memory sticks if you're lucky enough to have an SSD drive in your possession. As I understand it, they contain a lot of pieces of flash memory in parallel to get around the slow write speed issue, so SSD drives are about as fast as we can get both ways, (read and write).  The USB2 interface will be the slow part if you have an SSD drive in an external USB drive caddy like I do.

This is not an official Ubuntu website.
These three are  |  Ubuntu  |   Ubuntu Forums  |    Official Ubuntu Wiki

Here is a link to the Official Ubuntu Installation Guide,  it explains all about the Debian installer. You may wish to read that first and refer to this website for the illustrations.

External Links:
SSD Myths and Legends - "write endurance" - classic article - storagesearch.com

Intel X25-M SSD: Intel Delivers One of the World's Fastest Drives - Anandtech

Understanding SSDs and New Drives from OCZ - AnandTech.

KernelTeam/Specs/KarmicSSD - Karmic Koala - SSD support (proposed)

Block layer discard requests - LWM.net - Johnathan Corbett - ATA TRIM

[Solved] Gutsy encryption options on Alternate CD? - Ubuntu Web Forums

Hard Drive Encryption in My Ubuntu Installation - Martti Kuparinen

Encrypted Ubuntu 8.04 - Step-by-step installation tutorial with screenshots! - Softpedia

Running fsck on a LUKS encrypted partition in LVM - i, quaid

Rescue an encrypted LUKS LVM volume - Ubuntu geek

How to Resize a LUKS Encrypted File System - bodhi.zazen - Ubuntu Web Forums





To begin, you need to place your CD in your CD-ROM drive and re-start your computer.
You should see something like the illustration below in your monitor.

p2d/001.png
fig 1


p2d/1bfat32.png
fig 2

The choices here are:

F1 for Help
- explains what the other modes are for, (F2 to F6).                      

Check the CD-ROM for defects, that is a good idea! I recommend checking the CD for defects. It only takes five minutes or so and might save you hours of frustration if you have a bad burn. You already ran an md5sum test on your .iso download too, of course.

Test Memory, you can test your computer's RAM to make sure it's okay. (Memtest86+)

Boot from first hard disk, - useful if you left the CD in the drive by accident and you really wanted to boot the computer up without running the CD.

Rescue a broken system, - Rescue Mode

Install Ubuntu - The text mode install, this is the correct item to choose here.
It's a good idea to scroll down one line and check your CD for defects first though.
I will run through the rest of the options below, but this option is the one that this web-page is mainly about. 

 Here is a link to the Official Ubuntu Installation Guide's,  'How the Installer Works',  it explains all about the Debian installer. The Ubuntu Alternate CD's installer closely follows the Debian model.

Here is a link to the Official Ubuntu Installation Guide's,  'Components Introduction' too. Reading the official documentation in addition to looking at the illustrated example below here is recommended and might result in a better installation. 


Start of the first stage of the installation

As I mentioned first, I pressed 'Enter', for the 'text mode install', and here's the first decision, (below), it's an easy one.
p2d/x2.png
fig 3
Choose your language.  Your arrow keys can move the red rectangle up or down the list to select a language. Then press 'Enter'.
 
 We are now proceeding with Setting up Ubuntu Installer and Hardware Configuration.
You may wish to refer to the above link to the official Ubuntu documentation for a  more detailed explanation of what will be happening.

The <Go Back> option is shown in the lower left corner of almost every panel. It does the same as explained above (read <Go Back> again). Your 'Tab' key is the one to use throughout this installation for moving the red highlighting from  'Yes' to 'No' or 'Go Back'.
 
This can be a very handy thing to know about.  For one thing, it is useful if you need to go back one or two steps and repeat something you didn't get right. There are also things you can do from the 'Ubuntu Installer Main Menu' later on, after the install. For example, if you need to re-install Grub or Lilo boot loaders to your MBR or to a partition, you might want to access these options from the Ubuntu Installer's Main Menu. You don't necessarily have to be doing an install to run the Ubuntu Install CD.
You can also use the Ubuntu Install CD's partitioner to do partitioning work if you need to.
Nowadays a GParted -- LiveCD is better for that though.
 
The 'Ubuntu Installer Main Menu' also offers an escape route in case something has gone wrong and you need to abort the installation and re-boot to fix something. Or it may be that you have suddenly realized you have made a mistake and wish to cancel everything and try again.
If you do find yourself wanting to do this, just be aware that the line for 'abort the installation' and it is right down below the bottom of your monitor's screen, and out of view. People may not realize they need to scroll down to find it. Highlight that and press 'Enter', and be ready to remove your CD from it's drawer or it will boot from the CD again before you know it.


[!!] Choose language

Based on your language, you are probably located in one of these countries or regions.

Choose a country, territory or area:

                       Antigua and Barbuda
                        Australia      
                       Botswana      
                       Canada        
                       Hong Kong      
                       India          
                       Ireland        
                       New Zealand
                       Nigeria    

                       Phillipines    
                       Singapore      
                       South Africa  
                       United Kingdom
                       United States
                       Zimbabwe
                       other

<Go Back>
fig 4                            
                                                 Choose your country.
(Use your up or down arrow keys for scrolling, then press 'Enter')


[!] Ubuntu installer main menu

You can try to have your keyboard layout detected by pressing a series of keys. If you do not want to do this, you will be able to select your keyboard layout from a list.

Detect keyboard layout?

<Go Back>                                                                                                    <Yes>           <No> 
fig 5         
If you have a special keyboard, you can choose <Yes> for a series of keyboard tests to help Ubuntu set up your special keyboard correctly. You will be asked to press certain keys.

I chose <No> for this, to skip the keyboard tests and move on to choose my keyboard from a list.
This will be faster.


[!!] Ubuntu installer main menu

The origin of the keyboard:

    Norway   
    Pakistan
    Poland 
    Portugal
    Romania
    Russia

    Serbia 
    Slovakia
    Slovenia
    South Africa
    Spain
    Sri Lanka
    Sweden
    Switzerland
    Syria
    Tajikistan
    Thailand
    Turkey
    USA                    

<Go Back>                                         
Fig 6       
Choose your keyboard.


[!!] Ubuntu installer main menu

There are more than one keyboard layouts with the origin you selected. Please select the layout matching your keyboard.

Keyboard Layout:

  USA                                                      
  USA - Alternative international (former us_intl)
  USA - Cherokee
  USA - Classic Dvorak
 
USA - Colemak
  USA - Dvorak international
  USA - Dvorak
  USA - Group toggle on multiply/divide key
  USA - International (AltGr dead keys)
  USA - International (with dead keys)
  USA - Left handed Dvorak
  
USA - Macintosh
  USA - Right handed Dvorak
  USA - Russian phonetic
  USA - With Eurosign on 5 

<Go Back>                                         
fig 7 
The USA keyboard is the standard choice for most people in the world, even if I live in Australia. We use the USA style keyboard here.



Detecting hardware to find CD-ROM drives

                                                                        21%                                                                 

Loading module 'floppy' for 'Linux Floppy'...

fig 8 

Scanning CD-ROM

                                                                            19%                                                               

Scanning /cdrom/pool/main/l...

fig 9 

Loading additional components

                                                                             45%                                                                  

Retrieving Partman

fig 10 

Detecting network hardware 

                                                                                      21%                                                                

Detecting hardware please wait...

fig 11

Configuring the network with DHCP

                                                                                           21%                                                            

This may take some time...

 <Cancel>
fig 12
If you forgot to plug your ethernet in and network autodetection fails, highlight
<Go Back>  in the next screen, plug your network in and try again.


[!] Configure the network

Please enter a hostname for this system.

The hostname is a single word that identifies your system to the network. If you don't know what your hostname should be, consult your network administrator. If you are setting up your own home network, you can make something up here.

Hostname:

 ocz-karmic
__ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _                                                          _
 
<Go Back>                                              <Continue>
fig 13
Give your new operating system a host name. The way to do this is to move the cursor to the left with your 'backspace' key, and type in whatever you like here.
Press your 'tab' key to highlight '<continue>', and press 'Enter' when ready.

Setting up the clock

                                                                                    19%                                                                         

Getting the time from a network time server ...

fig 14

[!] Configure the clock

Select a city in your time zone:

    Lord Howe Island
    Hobart
    Melbourne
    Sydney
    Broken Hill
    Brisbane            
    Lindeman
    Adelaide
    Darwin    Perth

<Go Back>                                         
fig 15

Detecting disks and other hardware

                                                                                       21%                                                             

Starting PC card services
...

fig 16

Loading additional components

                                                                                        45%                                                               

Retrieving Partman

fig 17

Starting up the partitioner

                                                                                       21%                                                             

Please wait
...

fig 18

End of the first stage of the installation

Start of the partitioning stage of the installation

 We are now about to begin the Partitioning and Mount Point Selection phase of the installation. You may wish to refer to the above link to the official Ubuntu documentation for a  more detailed explanation of what can be done here.

[!!] Partition Disks

This installer can guide you through partitioning a disk (using different standard schemes) or, if you prefer, you can do it manually. With guided partitioning you will still have a chance later to review and customize the results.

If you choose guided partitioning for an entire disk, you will next be asked which disk should be used.

Partitioning method:

 Guided - resize SCSI1 (0,0,0), partition #1 (hda1) and use freed s
 Guided - use entire disk
 Guided - use the largest continuous free space
 Guided - use entire disk and set up LVM
 Guided - use entire disk and set up encrypted LVM                 
 Manual
<Go Back>                                          
fig 19            
For this installation we're choosing the fifth option, use an entire disk and set up encrypted LVM.


[!!] Partition Disks

Note that all data on the disk you select will be erased, but not before you have confirmed that you really want to make the changes.

Select disk to partition:
 
 SCSI1 (0,0,0) (sda) - 80.0 GB ATA ST380012A
 SCSI1 (0,1,0) (sdb) - 80.0 GB WDC WD800JB-00JJ
 SCSI2 (0,0,0) (sdc) - 7.5 GB ATA WDC WD75AA-75BAA                  

 SCSI3 (0,0,0) (sdd) - 64.0 GB OCZ-VERT EX                     


<Go Back>                                          
fig 20   
In this illustration I am being shown a list of my hard disks.
The computer I am installing in now has three hard disks at the moment, plus my USB external SSD drive, that makes four disks.
I'm selecting my fourth disk, which is my 64. GB USB SSD drive. You may use a USB flash memory stick of sufficient capacity instead if you don't own an SSD drive.

IMPORTANT: Remember which disk number you are installing to as this number designates your USB hard disk.
You will need to know this later on when you need to decide what MBR to install the boot loader to.


[!!] Partition Disks

Before the Logical Volume Manager can be configured, the current partitioning scheme has to be written to disk. These changes cannot be undone.

After the Logical Volume Manager is configured, no aditional changes to the partitioning scheme of disks containing physical volumes are allowed during the installation. Please decide if you are satisfied with the current partitioning scheme before continuing.

The following partition tables of the following devices are changed:
  SCSI3 (0,0,0) (sdd)  


 Write the changes to disk and configure LVM?

 <Yes>                                                                                                                              <No>
fig 21
We are being reminded about which hard disk we have decided to format. This will be our last chance to change our minds and cancel the installation if we suddenly remember there might be some data on that disk we might want some day that hasn't been backed up.

Also, take note of which disk you're installing in so you cn install GRUB to MBR in that disk later on in the installation process. You may wish to write this information down on some scrap paper to make sure you won't forget it.





Loading additional components

                                                                               45%                                                                

Retrieving Partman


Please wait...

                                                                                    21%                                                            

Creating ext2 file system for /boot in




[!!] Partition Discs

You need to choose a passphrase to encrypt SCSI2 (0,0,0), partition #1 (sdc).

The overall strength of the encryption depends strongly on this passphrase, so you should take care to choose a passphrase that is not easy to guess. It should not be a word or sentence found in dictionaries, or a phrase that could easily be associated with you.

A good password will contain a mixture of letters, numbers and punctuation. Passphrases are recommended to have a length of 20 or more characters.

There is no way to recover this passphrase if you lose it. To avoid losing data, you should normally write down the passphrase and keep it in a safe place separate from this computer.

Encryption passphrase:

 ************************_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _                                             
 
<Go Back>                                                                                                               <Continue>

[!!] Set up users and passwords

Please enter the same passphrase again to verify you have typed it correctly.

Re-enter password to verify:

 ************************_ _ _ _ _ _ _ _                                                _ _ _ _ _ _ _ _ _ _ _ _  
 
<Go Back>                                                                                                                   <Continue>




Starting up the partitioner

                                                                                  21%                                                                

Please wait
...



[!!] Partition Discs

You may use the whole volume group for guided partitioning, or part of it. If you use only part of it, or if you add more disks later, then you will be able to grow logical volumes later using LVM tools, so using a smaller part of the volume group at installation may offer more flexibility.

The minimum size of the selected partitioning recipe is 596.0 MB (or 8%); please note that the packages you choose to install may require more space than this. The maximum available size is 63.8 GB.

Hint" "max" can be used as a shortcut to specify the maximum size, or enter a percentage (e.g. "20%") to use that percentage of the maximum size.

Amount of volume group to use for guided partitioning:

  63.8 GB_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _                                                      _
 
<Go Back>                                                                                                                    <Continue>

Guided Partitioning

                                                                                           45%                                                                



Starting up the partitioner

                                                                                      21%                                                                      

Please wait
...




[!!] Partition Disks

If you continue, the changes listed below will be written to the disks. Otherwise, you will be able to make further changes manually.

WARNING: This will destroy all data on any partitions you may have removed as well as on the partitions that are going to be formatted.

The following partition are going to be formatted:
   LVM VG ocz-karmic, LV root as ext4
   LVM VG ocz-karmic, LV swap_1 as swap

 Write the changes to disks?

 <Yes>                                                                                                                                            <No>


Partitions formatting

                                                                                    21%                                                             

Creating ext4 file system for / in partition #1 of LVM VG ocz-karmic, LV root...




End of the partitioning stage of the install

Start of the final stage of the installation


Installing the base system

                                                                                     30%                                                                   

Extracting zlib1g...


We are now about to begin the Setting up the System stage of the installation.
You may refer to the above link to the official Ubuntu documentation for more detailed advice about the questions you will be asked next. 


[!!] Set up users and passwords

A user account will be set up for you to use instead of the root account for non-administrative activities.

Please enter the real name of this user. This information will be used for instance as default origin for emails sent by this user as well as any program which displays or uses the user's real name. Your full name is a reasonable choice.

Full name for the new user:

 Herman_H_Felderhof_  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _                                                       
 
<Go Back>                                               <Continue>
fig 
I just type in my first name and surname here. You are allowed to use capital letters.
Whatever you type here will be remembered by your new system and used for automatically configuring some things like parts of your email account. Make sure you don't type anything foolish here because your e-mail recipients might be reading this some day.

[!!] Set up users and passwords

Select a username for the new account. Your first name is a reasonable choice.  The username should start with a lower-case letter, which can be followed by any combination of numbers and more lower-case letters.

Username for your account:

 herman_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _                                                             
 
<Go Back>                                               <Continue>
fig 
Your first name should automatically appear here as a default username. You can change it to a nickname if you want, and with numbers too if you like. (Check your numlock). Lower case letters only though, no capitals.

[!!] Set up users and passwords

A good password will contain a mixture of letters, numbers and punctuation and should be changed at regular intervals.

Choose a password for the new user:

 ****************_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _                                                         
 
<Go Back>                                               <Continue>

[!!] Set up users and passwords

Please enter the same user password again to verify you have typed it correctly.

Re-enter password to verify:

 ****************_ _  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _                                                    
 
<Go Back>                                               <Continue>
fig 
It is a good idea to write your new username and password down and keep them on a piece of paper for a while until you are sure you will remember them. You will need them to log in to your new system.

We are now about to begin the Installing the Base System and Installing Additional Software stages of the installation. You may refer to the above links to the official Ubuntu documentation for more detailed advice about what happens next.       


[!!] Set up users and passwords

You may configure your home directory for encryption, such that any files stored in there remain private even if your computer is stolen.

The system will seamlessly mount your encrypted home directory each time you login and automatically unmount when you log out of all active sessions.

Encrypt your home directory?
 
<Go Back>                                                                                                            <Yes>          <No>
fig
It's no good double-doing file encryption, we already have an encrypted /, we don't need to also encrypt /home too. I tried it and I suspect that may have made my system slow opening my /home/username directory, and I couldn't access it for simulated file rescue either.
I don't recommend encrypting /home if the / (root) is already encrypted.

Configuring apt

                                                                                     40%                                                                 

Scanning the mirror ...



[!!] Configure the package manager

If you need to use a HTTP proxy to access the outside world, enter the proxy information here. Otherwise, leave this blank.

The proxy information should be given in the standard form of "http://[[user][:pass]@]Host[:port]/".

HTTP proxy information (blank for none):

 _ _ _ _ _ _ _  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _                                                              
 
<Go Back>                                               <Continue>
fig 
I always just skip this one by leaving it blank and selecting <Continue>
Those who need it will probably know what to do here.


Configuring apt

                                                                                    40%                                                                      

Scanning the mirror ...



Select and install software

                                                                                19%                                                                      

Copying gimp ...
fig
This process involves a lot of writing to the disc, so this part of the whole installation takes a lot of time.
How fast does your computer write data to disk? (Or how fast can your disk take it?).

You will have time to go do some martial arts exercises or have a cup of coffee or whatever it is you like to do.


We are now about to begin the Making Your System Bootable part of the installation.
You may refer to the above link to the official Ubuntu documentation for more detailed advice about the options you can expect to be offered here. 

Installing Grub bootloader

                                                                                   
66%                                                                  

Installing the 'grub' package...

fig 


[!] Install the GRUB boot loader on a hard disk

The following other operating systems have been detected on this computer: Windows XP (loader), Debain GNU/Linux (4.0), Ubuntu 7.04 (7.04), Ubuntu 9.04 (9.04), Ubuntu 8.04.2 (8.04)

If all of your operating systems are listed above, then it should be safe to install the boot loader to the master boot record of your first hard drive. When your computer boots, you will be able to choose to load one of these operating systems or your new system.

Install the GRUB boot loader to the master boot record?

        <Go Back>                                                                                   <Yes>              <No>          
fig
The Ubuntu installer wants to install GRUB, the GRand Unified Bootloader to MBR in the computer's first hard disk.
This is not what we want if we are trying to install Ubuntu in a USB.
I will choose <No> for a chance to specify where else I might want to install GRUB instead, (the USB disk's MBR or the boot sector of the /boot partition).

Choosing 'No' doesn't mean GRUB will not be installed, it just means we don't necessarily want to install GRUB's IPL to first hard disk's MBR. Maybe we want to install GRUB's IPL somewhere else?

[!!] Install the GRUB bootloader on a hard disk

You need to make the newly installed system bootable, by installing the GRUB boot loader on a bootable device. The usual way to do this is to install GRUB to the master boot record of your first hard drive. If you prefer, you can install GRUB elsewhere on the drive, or to another drive, or even to a floppy.

The device can be specified using GRUB's "(hdn,m)" notation, or as a device in /dev. Below are some examples:
- "(hd0)" or "/dev/hda" will install GRUB to the master boot record of your first hard drive (IDE);
- "(hd0,1)" or "/dev/hda2" will use the second partition of your first IDE drive;
-"(hd2,4)" or "/dev/hdc5" will use the first extended partition of your third drive (SCSI here);
-"(fd0)" or "/dev/fd0" will install GRUB to a floppy.

Device for boot loader installation

 (hd3)__ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _                                                

 
<Go Back>                                                                                                                <Continue>
       fig 10 mbr
This panel comes next, you can type in a custom location on the dotted line to specify where exactly you do want GRUB to be installed.

If you want GRUB's IPL installed to your second hard disk's MBR instead of your first one, type (hd1) or /dev/hdb here.
If you want GRUB's IPL installed to your third hard disk's MBR instead of your first one, type (hd2) or /dev/hdc here.
If you want GRUB's IPL installed to your fourth hard disk's MBR instead of your first one, type (hd3) or /dev/hdd here.

I'm typing in '(hd3)', because I already have three hard disks inside this computer, and my USB external SSD will be disk number 4.
BE CAREFUL HERE, because there are a few computers which might list any USB drive as first hard disk instead.

Many computers have a BIOS that allows the user to easily choose which hard disk to boot. Mine does, click hard disk boot priority to see what I mean. Then you can either enter your BIOS to set which MBR to boot or use another system's GRUB to chainload any disk you want providing there's valid boot loader code in its MBR.

Installing GRUB boot loader

                                                                                          66%                                                                  

Running "update-grub  ...



Here is the link to what the official Ubuntu documentation has to say about Finishing the Installation and Miscellaneous     


Finishing the installation

                                                                                     25%                                                                  

Storing language ...


[!!] Finish the installation
Installation complete
Installation is complete, so it is time to boot into your new system. Make sure to remove the installation media (CD-ROM, floppies), so that you boot into the new system rather than restarting the installation.

<Go Back>                                                                                                                  <Continue> 
fig 
At this point, my CD drawer pops open automatically and I remove my CD from it and press 'Enter'.
Some computers might not have a CD drawer with a mechanism to open the CD-ROM drawer automatically. If this is the case, you should remove your CD manually.

Finishing the installation

                                                                                     90%                                                                       








sending SIGKILL to all processes ...
Please standby while rebooting the system

Booting your USB flash memory stick
The next major step is to reboot into your new Ubuntu Karmic Koala operating system in your USB flash memory stick.

Since we chose not to install GRUB to MBR in our first hard disk, our computer isn't going to boot our USB flash memory installation by itself. We'll need to do something special to get our USB flash memory stick to boot for us.

If your computer has the GRUB in the computer you used for installing, you'll have no problem booting your USB flash memory stick from your GRUB's Command Line Interface.

What if you don't have GRUB?
If your computer doesn't have GRUB
One way you'll be able to boot would be from your BIOS. Here's a link to help people who don't know how to boot from the BIOS boot menu, How I boot from my BIOS

Another way would be to use a Super Grub Disk CD or floppy, Super Grub Disk Page.

NOTE: Not all computers are capable of booting from a USB drive.



GNU GRUB version 1.97~beta4

Ubuntu 9.10, linux 2.6.30-8-generic                            
Ubuntu 9.10, linux 2.6.30-8-generic (single-user mode)
Ubuntu 9.10, memtest86+
Other operating systems:





Use the up or down arrow keys to select which entry is highlighted. Press enter to boot the selected OS, 'e' to edit the commands before booting, or 'c' for a command-line.
 GRUB Menu





















Unlocking the disk /dev/disk/by-uuid/42635c42-0355-43d4-b4a2-161f1b5594cea (sdc1 crypt)
Enter Passphrase:_
Here's where we need to type our LUKS passphrase.



p22/043.png
fig   
This is not actually the Karmic Koala login screen yet, to do!  
You'll see the new login screen for Ubuntu in your  USB flash memory stick.
I just need to type in my user name, then it will ask me for my user password.


p2d/d027.png
fig
This is not actually the Karmic Koala desktop either, to do!  
When you have made it this far, your new desktop should be different from the one shown in the illustration above. Congratulations! You have successfully installed Ubuntu in a USB flash memory stick!

     
  
There are a few optional things to do to make Ubuntu work the way I want it to.

1. Reduce swappiness
In this installation the swap area is built in, inside the encrypted LVM volume, so we will be using our flash memory to write our swap data to and read from. Writing to flash memory is generally a little slow. The idea of reducing swappiness here is to cause the operating system to prefer not to use the swap area too much and prefer to use the memory modules instead. The operating system should be a lot faster if it uses the memory modules instead of the swap area.
By using this method, the swap area is still available to the operating system in case it is really needed.

Open your /etc/sysctl.conf file with gedit text editor,
gksudo gedit /etc/sysctl.conf

/etc/sysctl.conf
vm.swappiness=10
At the bottom of the file, add this line 'vm.swappiness=10'.

See: Performance tuning with 'swappiness' - Ubuntu Community Docs.



2. Edit /etc/fstab with noatime option.
Theodore Ts'o, the lead developer of the ext series of file systems recommends mounting the ext4 file system with the noatime option when using in in flash memory sticks or SSD drives, please read this link, SSD’s, Journaling, and noatime/relatime. I'm taking his advice.

Open the /etc/fstab file with gedit text editor,
gksudo gedit /etc/fstab

/etc/fstab
# /etc/fstab: static file system information.
#
# Use 'vol_id --uuid' to print a universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name
devices.
# That works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>  <type>  <options>        <dump>    <pass>
proc             /proc         proc    defaults          0         0
#  /   was on /dev/mapper/eeepc--karmic-root during installation
UUID=74fa50a4-0aef-4505-a398-aa4d5077b195  /     ext3  noatime,errors=remount-ro  0   1
#  /boot was on /dev/sdd5 during installation
UUID=559c5376-7cc2-441d-bd31-27b901fb6928  /boot ext2  noatime,defaults 0     2
# swap was on /dev/mapper/eeepc--karmic-swap_1 during installation
UUID=50e6065b-0ca4-441d-af03-5093f4d66d27 none    swap    sw   0     0
/dev/scd0       /media/cdrom0  udf,iso9660 user,noauto,exec,utf8 0    0
/dev/scd0       /media/cdrom1  udf,iso9660 user,noauto,exec,utf8 0    0
/dev/fd0       /media/floppy0  auto    rw,user,noauto,exec,utf8 0    0
Change the words 'relatime' to 'noatime' and save the changes before closing the file.

This means Ubuntu will no longer go to the extra work of updating the access time (atime) every time we open a file. To see what I mean, right-click on any file and click 'properties', and you'll see the last access time listed there.



3. GNU GRUB - also see this website's GRUB2 Pages.

Splashimage
You might like to set up your GRUB with a beautiful splashimage, GRUB2 Splashimages.

noop i/o scheduler
One more thing that can be done in GRUB would be to add the kernel option for the noop I/O scheduler to the GRUB menu.  Noop scheduler - wikipedia. 
As far as I know, cfg is the default I/O scheduler for Ubuntu. An I/O scheduler is useful for re-organising writes to hard disk drives so that instead of just doing things in chronological order, writes that are physically close to where the hard disk's read and write heads may happen to be at any point in time will be done first. Writes to places on the hard disk that are a long way away from the read and write heads will be held for later. That's a more efficient way to manage mechanical hard disks, and it usually results in better performance.
Flash memory doesn't have any read-write heads or controller arms, so we don't need any fancy, complicated I/O scheduler, for us it might even slow things down.
It is widely believed that using the simpler noop I/O scheduler will speed up your system and anyway it's all we need if we're mainly reading and writing to and from flash memory .

gksudo gedit /etc/default/grub

# This file is sourced by update-grub, and its variables are propagated
# to its childs in /etc/grub.d/
GRUB_DEFAULT=0
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s`
GRUB_CMDLINE_LINUX="elevator=noop quiet splash"
Type in the words 'elevator=noop', in the line before the other kernel options.
Save and close the file.


sudo grub-mkconfig -o /boot/grub/grub.cfg
This is the command for updating /boot/grub/grub.cfg with the changes.

How to add kernel options - TWEAKING GRUB 2 - Dr.Lock

Switching IO Schedulers on runtime - www.LinuxHowtos.org

The downside could be that booting with the 'elevator=noop' kernel option changes the way the kernel write to all disks, at least according to Blazeix  in post #5 in Enable noop scheduler by default for an SSD - Ubuntu Web Forums.  So what happens when we have a want to use the USB flash memory operating system to write to a hard disk? Probably it will be just a little bit slower. We could edit /etc/sysfs.conf instead, but that method seems to tie the USB to a device file name like /dev/sda. If it can handle UUID numbers it would be great. I'll update this topic if more information comes to light.


4. Update and upgrade
It's time to open up our repositories and get an update, install the software we want, and start configuring, personalizing and customizing our Ubuntu installation.
Here's a link to a page with some information to get you started, Post-install Page.



6. Skip the login screen
During boot up, we have to type our LUKS encryption passphrase to open the file system, then we see the login screen and type in our user name and user password before we see our desktop.

It's okay to leave it like that if you want the extra security. If you are the only person who will be using this operating system, you might find it inconvenient to be typing two passwords for every boot-up. The LUKS passphrase should be enough.

Go 'System'-->'Administation'-->'Login Window'.
Under the Security tab, check 'Enable Automatic login'
Type your username in the 'User' field.

From now on your operating system will boot up directly to your own desktop and not stop at the login screen and not ask for your user name and password.



6. Install Logical Volume Manangement GUI
'Applications'-->'Add/Remove Programs'-->'System Tools'-->'Logical Volume Management'.

GParted isn't designed to be able to manipulate Logical Volumes, but Logical Volume Management can.

I don't know much about LVM yet, but it's bundled with the encryted installation.
It doesn't seem to me as if LVM will be useful in this particular type of installation.
LVM is an interesting subject for another web page and and some other day.

External Links:
Get to know Ubuntu's Logical Volume Manager -  Linux.com

An introduction to Logical Volume Management - DistroWatch

Linux’s Logical Volume Management  -  David Hogue

RAID-5 Encrypted with Logical Volume Management  - TJ



7. Run 'sudo apt-get clean'
This is only useful if you have installed in a small disk and you need to regain some disc space.
Linux file systems work best if the file system is kept less than about 80% full.
The command for checking file system usage is 'df -h',
df -h

Software packages come in .deb files which are downloaded from the internet and stored in /var/cache/apt/archives/, and after the software has been installed, the left-over .deb files remain in /var/cache/apt/archives/ in case they're ever needed again. Normally, I like to leave them there so I can make a backup of them if I ever need to re-install for some reason. (Sometimes I do some risky experiments). That way I don't need to re-download them all from the internet again.
 In a USB flash memory stick where I don't have the spare disk space, it's often best to get rid of all those .deb packages sitting around in there, not doing anything.

The quickest and easiest way to do that is to run 'sudo apt-get clean',
sudo apt-get clean
 
In my 4 GB USB flash memory installation, my disk usage was reduced from 77% used to 68% used, so I cleared a significant proportion of my disk space.
In a larger disk, this command might be a waste of time, and actually, those with slow internet speeds or a low monthly bandwidth allowance might want to do the opposite and make a backup of their /var/cache/apt/archives instead.



8. SSH Networking
Control your home computer and access all your stored data in it from anywhere you may travel with your USB flash memory stick.

Install your SSH Networking software in your home or office computer running Ubuntu and set up 'port forwarding' to your internet modem. SSH stands for 'Secure SHell'. The port you use will be password protected and your password and data will be transferred securely over the internet in encrypted form.  There are some extra security precautions you can add as well if you think they're necessary. See this website's SSH Network page.



Important Parts of a Flash Disk Drive

It's probably not recommended for you to open an SSD drive or thumb drive, but there are some nice photos in the following recommended link, Vertex Internal Components - BenchmarkReviews.com
If you look in that link,  you'll see pictures of the following items on the circuit board,

Cache Memory
SSD drives have a cache memory just like hard disk drives do, it's a fast SDRAM module where data can be quickly queued up while it's waiting to be written to the flash memory. 

Flash Memory Controller Chip
The flash memory controller chip makes the flash memory ICs and the dies inside them appear on the surface to the operating system and the user as if they are a hard disc drive.
The flash memory controller chip takes care of logical block addressing, wear leveling, bad block management and if there are more than one flash memory ICs, then it might organize the ICs into a RAID0 array for faster reads and writes.

Flash Memory ICs
These are the rectangular boxes that contain the flash memory itself.
A USB flash memory stick may contain one,  two or more of these, but most commonly they only contain one.
In an SSD drive there can be eight of more memory ICs.
The flash memory ICs can also be stacked on top of each other piggyback fashion to save space on the SSD board if necessary.




Flash Memory Wear - Measuring writes to disk - disk I/O

Will Your Flash Memory Wear Out?
The short answer is 'Yes', probably it will some day, but that depends on what kind of flash memory you have, how large it is, what you use it for and how much time you spend using it.
The fact is, I don't know because none of my flash memory devices have worn out yet.

Flash memory has a bad reputation for wearing out. This is a carry-over from days gone by when it was not yet designed for this kind of use but people went ahead and installed operating systems in it anyway. You can still get flash memory that isn't very well suited for prolonged hard work and there are plenty of people around the internet who have nothing better to do with their time than to spread the FUD - (Fear, Uncertainty and Doubt). Attitudes are changing though.

Here's a link to a survey being carried out by some Linux users, Flash Drive Lifespan Survey - NSLU2
Did you take a look at the flash drive lifespan survey linked above?
Those flash memory sticks are small, between 512 MB and 4 GB.
The oldest were made way back in 2006, so they're using old technology.
Only two out of fifteen are reported to have failed so far.
Many of them have a root file system in them running 24/7.

Flash memory technology is advancing rapidly and scientists and engineers are putting a lot of work into it. The length of time your flash memory will last will depend on what kind of flash memory product you have, SD drive, thumb drive, SSD drive, and the work the manufacturer invested in it.
An item like a camera card is designed to be small and not very many people will install an operating system in it. It seems unlikely to me that camera card can be expected to have a disk controller with advanced wear levelling features. They're simply not designed for this kind of use.
USB flash memory sticks are available in a wide range of sizes, prices, and speeds. Most of them are not really designed for installing operating systems in, but most of them do have pretty good endurance capabilities anyway. We can only guess about that. A few of the best come with guarantees, and there is at least one brand that is guaranteed for life.
SSD drives are being designed for operating system use and these are getting better and better.

Wear Levelling
Your operating system doesn't actually write directly to the flash disk like a lot of people seem to imagine.
We're actually writing to the flash memory's controller chip and the controller chip writes data to the flash memory.
The flash memory controller chip makes the flash memory look to like a disk when viewed from the operating system side. Underneath, it controls electronic pathways leading to blocks of flash memory made of stacks of wafers containing mazes of honeycomb like lattices of flash memory tranistors.
Nearly all thumb drives and SSD drives today will have some kind of wear levelling program built into their controller chip. There are two kinds of wear levelling, and most flash memory uses some combination of each.

Dynamic wear leveling
'Dynamic Wear Levelling' works by shuffling around all the 'dynamic' (free) erase blocks, the ones that aren't currently in use for storing data. Blocks containing static data are not included. That means if your system and files fill up say 75% of your drive, only 25% of your drive is left over for wear levelling. That will still give you 25 times the endurance than if your drive didn't use any wear levelling at all. However, it's still only about 1/4 of the endurance that would be possible if the entire storage space could be rotated.

Static-wear-leveling
'Static Wear Levelling' involves a much more complex process which keeps track of the useage of blocks and tries to write data to the least used physical blocks. A static wear level algorithm evenly distributes data over an entire system and searches for the least used physical blocks. Once it finds them, it writes the data to those locations. If blocks are empty, the write occurs normally. If they contain static data, it moves that data to a more heavily used location before it moves the newly written data.
You calculate the endurance of a storage system using static wear leveling to be 100 times better than an approach without wear leveling. A system with 75% of the storage containing static data is four times better than a card that implements dynamic wear leveling. Static wear leveling provides better endurance because it writes data to all blocks of the storage system.

Here's an interesting article which gives us mathematical equations we might use to try to predict the endurance of a flash memory drive, Accurately judging endurance for solid-state storage - EDN, 1/19/2006 - Gary Drossel

As you can see if you read that article, the size of the drive compared with the proportion of used and free space is a factor, and also the type of wear levelling that is used.

Here's another interesting web page that explores the endurance of flash memory drives, SSD Myths and Legends - "write endurance" - classic article  -  storagesearch.com

Block erasure
One limitation of flash memory is that although it can be read or programmed a byte or a word at a time in a random access fashion, it must be erased a "block" at a time. Each flash drive is made up of a series of erase blocks.
These typically are 2mb in size. - http://managedflash.com/understanding/wear.htm
Another way of thinking of this is that even if your data is only one megabyte in size, the average write will still always be 256 kilobytes.
This generally sets all bits in the block to 1.
Starting with a freshly erased block, any location within that block can be programmed.
However, once a bit has been set to 0, only by erasing the entire block can it be changed back to 1.
In other words, flash memory (specifically NOR flash) offers random-access read and programming operations, but cannot offer arbitrary random-access rewrite or erase operations.
A location can, however, be rewritten as long as the new value's 0 bits are a superset of the over-written value's.
For example, a nibble value may be erased to 1111, then written as 1110.
Successive writes to that nibble can change it to 1010, then 0010, and finally 0000.
In practice few algorithms can take advantage of this successive write capability and in general the entire block is erased and rewritten at once.
Although data structures in flash memory cannot be updated in completely general ways, this allows members to be "removed" by marking them as invalid.
This technique must be modified somewhat for multi-level devices, where one memory cell holds more than one bit.


to do:
  • discuss factors that determine flash wear or longevity
  • make a script(s) to be run on shutdown that keeps track of writes to disc, .cvs to spreadsheet, and turn into graph.
  • introduce formula for (trying to) guess or predict flash memory lifespan
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]




 (brand)
Information on the internet




Flash Memory Performance - Benchmarking

Ubuntu Linux Disk Encryption Benchmarks - by Michael Larabel

to do:
  • explain some ways to measure a drive's read speeds and write speeds




Why the new ATA TRIM command is important

The Anatomy of an SSD - Anandtech p5
Putting Theory to Practice: Understanding the SSD Performance Degradation Problem


Byte Conversion Calculator - T1 Shopper