How To Make a GRUB Flash Drive.
(Optional: GParted Live on Flash Drive.)
--- A toolkit for building bootable flash drives.
(Key words: GRUB on a Flash Drive, on USB Flash Drive, on Pendrive, on USB Device.
Option: GParted Live on Thumb Drive, on USB Flash Drive, on Pendrive, on USB Device.)
Other related projects:
-- To clone your flash drive, see REFERENCES, dd Command.
-- To build a Live Kubuntu persistent flash drive, see REFERENCES, Build a LIVE Kubuntu Flash Drive, How-To
-- How to Install Kubuntu to an External USB HDD: See Reply #1 (following this post)
External USB hard drives: Same methods as for flash drives!
The methods for USB flash drives are the same as for external hard drives.
-- Comment about other posts in this thread
Reply #1 is maintained:
How to install K/Ubuntu 7.04 to an external USB hard disk drive (HDD).
The following are not maintained any longer: Replies #5, 6, 7, 8, 9, 10, 12.
However, you may find useful information in some of them:
USB experiment: USB drive shifting Reply #5.
Simplifying your menu.lst and all the rest of it, Reply #8
Puppy Linux on USB Flash Drive (UFD) Reply #9
Super Grub Disk, GRUB, GParted & Puppy on a flash drive Reply #10
Knoppix on USB Flash Drive (UFD), Reply #6 & #7
Install Kubuntu 7.10 to a flash drive (UFD) Reply #12
First version of this how-to, the original post, this first post, is attached at the end here, following the REFERENCES.
TABLE of CONTENTS
Abbreviations
1 How-to do it: The basic how-to
2 Notes -- details, tips, options, methods, additional information
3 USB drive shifting: Very important!
=> the key to understanding how to use flash drives and external drives
Super Grub Disk for USB -- usbshift -- special command for dealing with drive shifting
4 Appendix: Put GParted in the same partition with SGD
Alternate way to partition for GParted: Put it in with SGD in partition 1
You do not need a separate partition for GParted.
Adjustments you need to make.
5 REFERENCES
List of Notes
Note 1: BIOS issues, assumptions: “Boot from USB”
Note 2: Compressed files (bz2 & bzip) and using Ark in Kubuntu
Note 3: Using the special SGD USB
Note 4: Use K3b (in Kubuntu) to burn your GParted Live CD
Note 5: How to zero-out your flash drive
Note 6: Setting labels at the command line: This is changed!--see the Note 6.
Note 7: Open a file manager as root
Note 8: Copying hidden folders and files in GUI and CLI
Note 9: Accessing files on a downloaded iso file (without burning a CD)
Note 10: Find out how Kubuntu & GRUB see the flash drive
Note 11: Using GParted Live CD -- logistics
Note 12: md5sum (of downloaded files)
= = = = = = = = = = = = = = = = = = = =
Abbreviations
CLI: command line interface, refers to using Konsole
GUI: graphical user interface, using Konqueror or Dolphin
HD: hard drive; HDD: hard disk drive
MB: megabyte
OS: operating system
SGD: Super Grub Disk
UFD=USB flash drive (thumb drive, pen drive, etc.)
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
1 How-to do it: The basic how-to
Goal
To put your GRUB boot menu and Super Grub Disk on a flash drive.
Optional: To put GParted Live on the same flash drive.
(Instructions are given for GParted, which you may choose to do or to omit.)
-- At a minimum, we will install Super Grub Disk to the flash drive, and we'll include your own boot menu, which you can use to boot your operating systems directly. Super Grub Disk can be used to boot into your operating systems when you are otherwise unable to do so.
-- As an option, you may put GParted Live on the flash drive. GParted is a handy partitioning editor.
-- You will see how to easily include other programs or Puppy Linux on the same flash drive.
-- You may also include a data partition for your personal use.
See Note 1: BIOS issues, assumptions: “Boot from USB”
Overview
We assume you will do this work in Kubuntu/Linux.
Step 1 Download SGD for USB
[and optionally, GParted Live CD files--you do NOT need the USB version of GParted].
Step 2 Prepare the flash drive:
Zero-out (optional), partition, format, set boot flag, set labels
Method: Use GParted Live CD; or gparted from Kubuntu
Step 3 Copy files from SGD [and GParted Live CD] to the flash drive
SGD: Extract the boot directory; copy it into the first partition of the flash drive
GParted: Copy all GParted files to the (second partition) of the flash drive
Step 4 GRUB
Set up GRUB in the MBR of the flash drive;
Build the boot menu (menu.lst)
Step 5 You are done! Re-boot to test it
Step 1 Download SGD for USB [and GParted Live CD files]
-- Download SGD for USB from here:
http://www.supergrubdisk.org/
Example
Super Grub Disk for USB: super_grub_disk_english__usb_0.9766.tar.gz
Download that file to your Desktop. Right-click on it, select Extract Here, you get a folder named “boot”. (We need this folder and its contents to make the UFD bootable and usable.)
See Note 2: Compressed files (bz2 & bzip) and using Ark in Kubuntu.
See Note 3: Using the special SGD USB.
-- GParted Live CD
This is handy. You can use it to build the flash drive, and you can include GParted Live on the flash drive. For my method, you do NOT need to download the USB version of GParted: simply get the regular “live” (live CD) version.
Example: gparted-live-0.3.9-13.iso
(11/28/08--this new version includes capability to make Labels)
Check the MD5sums (See Note 12: md5sum).
See Note 4: Use K3b (in Kubuntu) to burn your GParted Live CD.
Step 2 Prepare the flash drive:
Zero-out (optional), partition, format, set boot flag, set labels
Method: Use GParted Live CD; or gparted from Kubuntu
Example: Flash Drive: 512 MB SanDisk
Desired end result: (partitions sdc2 and sdc3 are optional)
Partition - Label -Format - Size
sdc1 Grub-SGD ext2 8 MB (the minimum allowed by GParted) Boot Flag set
sdc2 GParted FAT32 125 MB
sdc3 MyData FAT32 the rest of the space - for personal data use
CAUTION: Your device names (sdxn) may be different!
See Note 10: Find out how Kubuntu & GRUB see the flash drive
Optional step: Wipe your flash drive clean, like factory-new.
See Note 5: How to zero-out your flash drive
(You can do this in Kubuntu or in GParted.)
Partition table/Master Boot Record: Flash drives that have been zeroed-out: If doing the partitioning using GParted, you will be prompted to accept a DOS-like partition table (in the Master Boot Record). If you are going to make the flash drive bootable with GRUB, accept this offer.
See Note 11: Using GParted Live CD -- logistics
Insert GParted Live CD. Re-boot the PC. Get the GParted screen.
Insert the Flash drive into USB port.
GParted (tab, upper left) > Refresh Devices
Confirm that the flash drive is recognized:
Drop down list at upper right of screen; or GParted (tab) > Devices
Example: Mine came up as sdc.
-- Optional: Zero-out the flash drive to wipe it clean-clean (factory new). See Note 5.
-- Conduct the partitioning and formatting (as indicated above -- “Desired end result”)
Note: In GParted, tabs at top,
Partition > Label
Partition > Flags > Boot (check box)
Labels: You can also set labels at the command line (in GParted or in Kubuntu)
See Note 6: Setting labels at the command line.--CHANGED!!!
The method works only for ext2/ext3, NOT for FAT32, which is a more complicated case and is NOT covered in this How-to.
Step 3 Copy files from SGD [and GParted Live CD] to the flash drive
SGD: Extract the boot directory; copy it into the first partition of the flash drive
GParted: Copy all GParted files to the (second partition) of the flash drive
GUI or CLI: You can do this work in two ways.
GUI: Konqueror or Dolphin (file managers)
CLI: In Kubuntu at Konsole
File managers Konqueror and Dolphin: Use copy/paste or drag-and-drop.
See Note 7: Open a file manager as root
Copying hidden files and folders
Whichever way you use, be certain that you also copy any hidden folders and files.
See Note 8: Copying hidden folders and files in GUI and CLI
Copy the files into the flash drive (using root as necessary):
Copy the SGD files into partition 1 of the flash drive.
Copy the GParted files into partition 2 of the flash drive.
Here's some CLI notes:
-- Copying SGD files into the flash drive partition 1 (Grub-SGD)
Extract the SGD files (Right-click > Extract Here to get boot directory)
Copy the directory boot from Desktop into Grub-SGD.
Example Suppose the first partition of the flash drive is mounted as /media/sdc1.
(You can do that: sudo mount /dev/sdc1 /media/sdc1)
cd Desktop
sudo cp -r boot /media/sdc1
So, when you open the first partition, you see the boot folder (directory).
-- Copying GParted files into the flash drive partition 2 (GParted)
If you burned the GParted Live CD (from the iso), put the GParted CD into the CD drive and let it come up. As an example, suppose it is mounted as /media/cdrom0; and suppose the second flash drive partition is mounted as /media/sdc2 (sudo mount /dev/sdc2 /media/sdc2). Then,
cp -r /media/cdrom0/* /media/sdc2
Using the gparted iso file (without burning the GParted Live CD)
If you did not burn the GParted Live CD (using the gparted iso file), you can open the iso and copy the files into the second partition of the flash drive (without burning the Live CD).
See Note 9: Accessing files on a downloaded iso file (without burning a CD)
Step 4 GRUB
Set up GRUB in the MBR of the flash drive
Build the boot menu (menu.lst)
Reference for GRUB, setup and menu.lst, my how-to:
How To GRUB Methods - Toolkit
http://kubuntuforums.net/forums/inde...opic=3081671.0
Set up GRUB in the MBR of the flash drive
So far, SGD and GParted are copied to the two flash drive partitions SGD-Grub and GParted.
Next, we set up GRUB on the flash drive. Get a grub prompt as root:
sudo grub
We need to know how GRUB names the first partition of the flash drive since it contains the GRUB files we need to set up in the MBR of the flash drive. Use geometry to find out.
grub>geometry (hd<press the TAB key>
Try some of the results: grub>geometry (hd0), grub>geometry (hd1), grub>geometry (hd2), etc.
Study the output to determine which drive is the flash drive.
Example: Suppose it is hd2.
grub>root (hd2,0) # (hd2,0) is the SGD-GRUB partition of the flash drive
grub>setup (hd2) # (hd2) is the Master Boot Record of the flash drive
grub> quit
$: exit
So far, SGD--and its GRUB--is set up on your flash drive.
With the flash drive connected, if you re-boot now from the flash drive, your PC will boot into SGD. The GParted partition is setup but is not on the boot menu yet; nor is your personal menu.lst.
Menu.lst
Build the boot menu (/boot/grub/menu.lst):
Include boot entries for GParted and myLinuxMenu.lst
Have a look at the boot menu. In Kubuntu, plug the flash drive in, open the first partition, Grub-SGD, navigate to and open the main boot menu, /boot/grub/menu.lst. You must modify it by including a boot entry for your personal menu.lst, which we'll call myLinuxMenu.lst, and a boot entry for GParted (actually two, one for normal Live and one for fail-safe mode). When you boot the PC from the flash drive, this is the boot menu you will see first, from which you'll select where to go next.
Here's the desired end result, with various SGD entries abbreviated, after which, we'll explain it:
# /boot/grub/menu.lst for the flash drive
# This is the main boot menu for calling
# your personal menu.lst, GParted, SGD,
# and other programs/OSs you have on the flash drive.
# You can edit this file to add your own distribution
## The two commands: setgrubdevice and usbshift are needed
## so that SGD works well.
#usbshift
#configfile $(grub_device)/boot/sgd/menu.lst
# Just after default and timeout statements you have to put
# setgrubdevice so that grub device is correctly set.
#
# Note that the default boot entry is default=0 which is myLinuxmenu.lst
default 0
timeout 10
setgrubdevice # This is compulsory
#sgdgfxmenu /boot/grub/message
foreground ffffff
background 0c00ff
color white/brown yellow/cyan
title myLinuxMenu.lst
usbshift # this is necessary
configfile $(grub_device)/boot/grub/myLinuxMenu.lst
title GParted Live--Live Start Debian Live, partition 2
root (hd0,1)
kernel /live/vmlinuz1 boot=live union=aufs
initrd=/live/initrd1.img
title GParted Live --Start Debian Live (fail-safe mode), partition 2
root (hd0,1)
kernel /live/vmlinuz1 boot=live union=aufs noapic noapm nodma nomce nolapic nosmp vga=normal
initrd=/live/initrd1.img
#title Inicio normal / Normal Boot: etcetera
#title Soporte de accesibilidad / Accesibility Support -->
#configfile $(grub_device)/boot/grub/menu2.lst
title Super Grub Disk
# The two commands: setgrubdevice and usbshift are needed
# so that SGD works well.
usbshift
configfile $(grub_device)/boot/sgd/sgd.lst
#title Normal boot. Kernel is aware of Boot device, etcetera
#title Normal boot. Selecting kernel and initrd files depending on grub_device
#title Selecthd test
#title findp test
#title set SGD variables and boot SGD
#
# End of the main /boot/grub/menu.lst
Comments: how to build /boot/grub/menu.lst
-- myLinuxMenu.lst
You'll note the boot entry for SGD, which calls its own separate menu.lst stored in the separate SGD folder sgd and called /boot/sgd/sgd.lst.
Likewise, you will do the same thing for YOUR personal menu.lst, but you will put yours in the regular grub folder:
title myLinuxMenu.lst
usbshift # this is necessary
configfile $(grub_device)/boot/grub/myLinuxMenu.lst
Notes:
The usbshift command is a special SGD-for-USB command; it's effect is to make the device references in your personal menu.lst, myLinuxMenu.lst, work correctly from the flash drive.
See the special section 4 below:
4 USB drive shifting: Very important!
=> the key to understanding how to use flash drives and external drives
GParted: root (hd0,1)
Since GParted is located on the flash drive, and the (native) GRUB of the flash drive sees the flash drive as hd0, you do not need the usbshift function to reference the GParted partition: it is simply the second partition of the booted flash drive, or (hd0,1).
$(grub_device) is a SGD variable; in this case, it contains the device name that contains your personal menu.lst, /boot/grub/myLinuxMenu.lst. Its value is set by the statement
setgrubdevice
and is equal to the first partition of the flash drive (i.e., it is equal to “where we are now”!).
Next step: Build myLinuxMenu.lst
Now, obviously, you must create myLinuxMenu.lst and place it in the folder /boot/grub of partition 1 of the flash drive. If you wish, you may simply copy the main menu.lst you use to boot your PC; or you can pick and choose from that menu.lst to build myLinuxMenu.lst. The device references contained in your regular menu.lst, such as root (hd0,0) or root (hd0,1) or (hd1,0), etc., will continue to work when called from the flash drive /boot/grub/menu.lst (or /boot/grub/myLinuxMenu.lst) thanks to the usbshift function.
Example
In my case, I normally boot my PC using a separate GRUB partition sdb1 (as described in my How To GRUB Methods - Toolkit link above (see REFERENCES). The menu.lst in that partition is very simple: it calls the various OSs on my PC using configfile; here it is:
# sdb1 GRUB partition menu.lst
default 0
timeout 10
# Pretty colours
color cyan/blue white/blue
title Kubuntu 8.04 sdb2 = (hd1,1)
configfile (hd1,1)/boot/grub/menu.lst
title Windows XP Home Edition sda1
root (hd0,0)
chainloader +1
title Kubuntu 8.10 Intrepid sdb3 = (hd1,2)
configfile (hd1,2)/boot/grub/menu.lst
Thus, I could copy that and make it the myLinuxMenu.lst to put in /boot/grub partition 1 of the flash drive. But if I ever changed any of those OSs or their partitions, I would then have to modify myLinuxMenu.lst on the flash drive--an inconvenience, and I might forget to do it. So, instead, I will create a very simple myLinuxMenu.lst:
# This boots my GRUB partition on sdb1 = (hd1,0)
default 0
timeout 10
title My GRUB Partition boot menu on sdb1 = (hd1,0)
configfile (hd1,0)/boot/grub/menu.lst
That's it! So here's what happens if I boot the PC using the flash drive:
First I see the main SGD menu.lst. Suppose I choose myLinuxMenu.lst. then I'll see the choice “My GRUB Partition boot menu on sdb1 = (hd1,0)” and I'll select it. Then I'll see the three choices from the menu.lst on my GRUB partition sdb1: “Kubuntu 8.04 sdb2 = (hd1,1),” “Windows XP Home Edition sda1,” and “Kubuntu 8.10 Intrepid sdb3 = (hd1,2).” And I'll choose one of them. Kind of indirect, I admit, but it is easy to maintain (e.g., when there are kernel updates or when I change my partitions or OSs), and keep in mind that I would usually only use the flash drive to boot in an emergency or exceptional situation, not every day. You can, however, set the default 0 statements (as I have) and reduce the timeouts to 2 or 3 seconds to make it all go automatic and fast.
Summary so far So, you must do, for yourself, two things:
First, in partition 1 of the flash drive, in the file /boot/grub/menu.lst, include the following boot stanza that calls your personal menu.lst:
title myLinuxMenu.lst
usbshift # this is necessary
configfile $(grub_device)/boot/grub/myLinuxMenu.lst
Second, create a text file called myLinuxMenu.lst, place your personal boot entries in it (your personal menu.lst), and place the resulting file in the folder /boot/grub of partition 1 of the flash drive.
-- GParted Live boot entries in /boot/grub/menu.lst of the flash drive (in the Grub-SGD partition)
Now, we need a boot entry for GParted.
In Kubuntu, open the second partition of the flash drive, click on the folder isolinux, then open the file
/isolinux/menu.cfg, and you'll see this:
LABEL live
MENU LABEL Start Debian Live
kernel /live/vmlinuz1
append initrd=/live/initrd1.img boot=live union=aufs
LABEL livefailsafe
MENU LABEL Start Debian Live (fail-safe mode)
kernel /live/vmlinuz1
append initrd=/live/initrd1.img boot=live union=aufs noapic noapm nodma nomce nolapic nosmp vga=normal
I used this to construct GRUB boot entries for GParted as follows:
title GParted Live -- Start Debian Live on partition 2
root (hd0,1)
kernel /live/vmlinuz1 boot=live union=aufs
initrd=/live/initrd1.img
title GParted Live -- Start Debian Live (fail-safe mode) on partition 2
root (hd0,1)
kernel /live/vmlinuz1 boot=live union=aufs noapic noapm nodma nomce nolapic nosmp vga=normal
initrd=/live/initrd1.img
Place those two boot stanzas into the main SGD menu.lst above
(# /boot/grub/menu.lst for the flash drive).
That worked for GParted.
If it had not worked, I would have done the following to get correct boot stanzas for GParted:
> Poke around the GParted files and find something else to try;
> Use google to learn about the boot options for GParted;
> Try the GParted site for tips:
> Post a direct question in the GParted user forum and hope that an expert would post a correct boot stanza for me to use; if not, unashamed, I would do a bump .
This completes
Menu.lst -- Build the boot menu (/boot/grub/menu.lst)
and it completes the GRUB work.
-- Optional: Other OSs/programs
You may include any other programs/OSs on this flash drive. For example, you can include Puppy Linux in its own partition, and call it from the main Grub-SGD menu.lst. See Reply #10 for that.
Tips, methods
Here's some tips/methods to help you do the edits to the main SGD menu.lst in the Grub-SGD partition.
Suggestion:
It is probably easier and faster for most people to do the menu.lst work using their file manager, on the Desktop, copy/paste, rather than to use Konsole. If you prefer to use the command line, then you already know how, and I won't include the details, which would only make it seem more complicated than it is.
> You may have to do the edits as root.
> You can do the work at CLI or GUI: Konsole or using a file manager, Konqueror, Dolphin, etc.
> Kate
To open the main Grub-SGD menu.lst as root in the text editor Kate
(assuming the mount point is /media/sdc1):
In 8.10:
kdesudo kate /media/sdc1/boot/grub/menu.lst
In 8.04:
kdesu kate /media/sdc1/boot/grub/menu.lst
=> After making edits, File > Save, File > Quit.
> Mount point:
This assumes that the first partition of the flash drive is mounted as /media/sdc1. If not, substitute the correct mount point.
See mounts points using:
mount
or
cat /etc/mtab
Make mount points and mount:
To make the mount point /media/sdc1 for device /dev/sdc1 and to mount it:
sudo mkdir /media/sdc1
sudo mount /dev/sdc1 /media/sdc1
To unmount it after making edits (note the spelling umount):
sudo umount /dev/sdc1 /media/sdc1
> Open Konqueror or Dolphin as root:
In 8.10:
kdesudo konqueror
kdesudo dolphin
In 8.04:
kdesu konqueror
kdesu dolphin
Then, navigate to the mount point for the partition Grub-SGD (e.g., in /media), and open /boot/grub/menu.lst.
> Copy files
Suppose you build the myLinuxMenu.lst that you want, and it's on your Kubuntu Desktop (as an example). To copy it into the the grub directory of the Grub-SGD partition, assuming the Grub-SGD partition is mounted as /media/sdc1:
sudo cp /home/your_name/Desktop/myLinuxMenu.lst /media/sdc1/boot/grub
> myLinuxMenu.lst: Text files, opening kate, saving the file, using root
The file myLinuxMenu.lst should be a text file.
In Konqueror or Dolphin, create a text file by
right-click > Create New > Text File
At Konsole, open Kate to get a new text document, File > Save As, and name it myLinuxmenu.lst:
Konsole
kate
File > Save As
Navigate to where you want it (your /home Desktop, or the flash drive folder /media/sdc1/boot/grub, etc.).
To open kate as root:
In 8.10:
kdesudo kate
In 8.04:
kdesu kate
If you open Kate as root, beware that saving it in home will save it in root's home, not your home; if you want it in your home, you have to Save As and navigate to home > your name > Desktop or wherever you wish to place it.
Step 5 You are done! Re-boot to test it
= = = = = = = = = = = = = = = = = = = =
2 Notes -- details, tips, options, methods, additional information
Note 1: BIOS setup issues -- Set your BIOS to boot from USB
Your BIOS must support the capability to "boot from USB." With the flash drive connected, re-boot, enter BIOS setup, set your BIOS to boot from USB. Set it to boot from CD first, then the flash drive, then your first hard drive. With no CD in the tray, with the flash drive plugged in, the PC boots from it; when the UFD is not plugged in, the PC boots as usual from the first hard drive. Save and Exit BIOS. The PC then re-boots from the flash drive.
Note 2: Compressed files (bz2 & bzip) and Ark in Kubuntu
Example SGD: super_grub_disk_english__usb_0.9766.tar.gz
The .bz2 is a bzip2 file--a compressed file (to make the file smaller for faster download). (Another type is .gz or gzip.) The extension .tar means the file is a tarball or tape archive file. The tarball has been compressed by bzip2. In Kubuntu, open the tarball with Ark (Archive extractor). Two ways:
(1) K-Menu>Utilities>Ark, File>Open, Desktop, click the file super_grub_disk_english__usb_0.9766.tar.gz, Open, Action>Extract, All files, select destination folder for the extracted files to go. Or,
(2) Right click on super_grub_disk_english__usb_0.9766.tar.gz, select Extract here.
Note 3: Using the special SGD USB
The special SGD for usb is needed if the flash drive is used to boot OSs NOT located on the flash drive, as SGD does or as myLinuxMenu.lst does. See the section below titled, “USB drive shifting: Very important! => the key to understanding how to use flash drives and external drives.”
Note 4: Use K3b in Kubuntu to burn the GParted Live CD
You'll find K3b under the K-menu (perhaps multimedia or system or applications). Select “Burn CD Image,” Image to Burn (Browse to the Desktop--or wherever you downloaded gparted, click gparted-livecd-0.3.9-13.iso, click OK, place a blank CD in CD tray, close the tray door; Speed: select 4x or the slowest speed offered, click Start. Wait for it to finish, click Close, then File>Quit, eject the CD, and using a magic marker write the version on the safe (top) side of the CD (e.g., "gparted-livecd-0.3.9-13.iso" , and release date 11-28-08).
Note 5: How to zero-out your flash drive: dd if=/dev/zero of=/dev/sdx
Wipe your flash drive clean, like factory-new. Easy! BUT, CAUTION! You must get the device-naming sdx correct! If you use the wrong one, you'll wipe out an entire drive!
Result: This will write zeros to every bit of your flash drive, including the Master Boot Record.
Where to do it: You need a terminal in a Linux distro. You can do this in Kubuntu at Konsole (even in Live CD) or in GParted.
In Kubuntu: Insert the flash drive. Open Konsole.
In GParted: Insert the flash drive. GParted (tab at upper left) > Refresh Devices. It should come up under GParted > Devices and under the drop-down list at top right of screen. Double-click Terminal (icon at top).
Commands:
Use this command to identify how your flash drive is named:
sudo fdisk -lu
Put that name sdx in the next command and press Enter:
dd if= /dev/zero of=/dev/sdx
(Sudo: If necessary run it using sudo dd if=/dev/zero of=/dev/sdx)
# Example: dd if=/dev/zero of=/dev/sdc
It will take awhile to run--you will not see any progress status, but the light on your flash drive will blink. When finished, you'll get a brief summary report and returned to the command prompt.
Type exit.
Note 6: Setting labels at the command line
This works only for ext2/ext3 filesystems.
It does not work for FAT32, which is a more complicated case and is NOT included here.
For FAT32: use a recent version of GParted Live CD.
Kubuntu: Open Konsole
GParted Live CD: Double-click Terminal (icon at top)
To set the Labels
Grub-SGD on sdc1
GParted on sdc2
MyData on sdc3
Use these commands:
sudo e2label /dev/sdc1 Grub-SGD
sudo e2label /dev/sdc2 GParted
sudo e2label /dev/sdc3 MyData
CAUTION: Use the correct device names sdxn for your flash drive partitions.
Note 7: Open a file manager as root
In 8.10:
kdesudo konqueror
kdesudo dolphin
In 8.04:
kdesu konqueror
kdesu dolphin
Note 8: Copying hidden folders and files in GUI and CLI -- Check this carefully!
-- GUI (Konqueror or Dolphin):
After opening a window containing the files, click View > Show hidden files.
-- CLI:
Example: To copy the contents (not dir1 itself) of directory dir1 into directory dir2
The following statement should do it:
cp -r dir1/* dir2
HOWEVER, for the wild card * to include hidden folders (and files), you must configure your BASH terminal (Konsole) correctly (if it is not already so by default)--Check this carefully!
Two ways to do:
First way: Issue the command
shopt -s dotglob
before the copy cp command.
Second way: Edit the file ~/.bashrc to include this line:
shopt -s dotglob
See the REFERENCE “Commands at Konsole” (how-to @Kubuntu)
Another way: This statement also does the trick:
cp -RT dir1 dir2
Note 9: Accessing files on a downloaded iso file (without burning a CD)
This works for any downloaded .iso file.
Example: GParted gparted-live-0.3.9-13.iso
Download the iso file to the Desktop. (If it's a tar.gz file or similar, get the iso by right-click, Extract Here, or by using K-Menu > Utilities > ARK) The file name is gparted-live-0.3.9-13.iso (on the Desktop): /home/your_name/Desktop/gparted-live-0.3.9-13.iso.
Open Konsole, make a directory GPartedTemp for your mount point
sudo mkdir /mnt/GPartedTemp
# Mount the iso on GPartedTemp
sudo mount -t iso9660 -o loop /home/your_name/Desktop/gparted-live-0.3.9-13.iso /mnt/GPartedTemp
# If you wish, you can change directories (cd) to /mnt/GPartedTemp
# and list (ls -al) the files to see what's there.
# Make another directory called GParted_Files on the Desktop
sudo mkdir /home/your_name/Desktop/GParted_Files
# Copy the GParted files to GParted_Files
sudo cp -R /mnt/GPartedTemp/* /home/your_name/Desktop/GParted_Files
# (If necessary) Change the ownership so you can have these files by:
# sudo chown -R your_name:your_name /home/your_name/Desktop/GParted_Files
# Then unmount the iso (note the spelling umount)
sudo umount /mnt/GPartedTemp
# To invoke root, use sudo (as I have above when necessary)
Note 10: Find out how Kubuntu & GRUB see the flash drive
Kubuntu (/dev/sdxn)
Command: sudo fdisk -lu
Command: cat /etc/mtab (for mounting)
Command: mount (for mounting)
Also, plug the flash drive into a USB port. After it is recognized, click OK to close the window that pops up.
-- In your file manager (Konqueror/Dolphin): Storage Media or /Media. You will find device and mounting information.
-- Also: Right-click on the flash drive icon, select Properties, you will see information about how it is mounted (e.g., /media/sdc1).
GRUB (hdx,y)
Example
Open Konsole. To get a GRUB prompt, type
sudo grub
grub> geometry (hd<press the TAB key now>
Possible disks are: hd0 hd1 hd2. Try hd2:
grub> geometry (hd2)
drive 0x82: C/H/S = 49600/5/32, The number of sectors = 7936000, /dev/sdc
Partition num: 0, Filesystem type is fat, partition type 0xc
That looks like the flash drive. (The other two disks are too big.)
Note 11: Using GParted Live CD -- logistics
In Kubuntu (or, with your PC on), place GParted CD in the CD tray. Close all open programs. Re-boot into GParted (BIOS must be set to boot first from CD ROM). When the GParted window appears, insert the flash drive, then GParted > Refresh Devices, select the flash drive from the drop-down list of your drives at the upper right. Partition and format as follows: To create the first partition, click on the unallocated space, Partition > New, set the size and type, OK, click the Apply icon to make it go.
NEW flash drives or those that have been zeroed-out: You will be prompted to accept a DOD-like partition table (in the Master Boot record). If you are going to make the flash drive bootable with GRUB, accept this offer.
Repeat this for other partitions. Then GParted > Quit, double click the red Exit button, Eject & re-boot -- OK, remove both the GParted CD and the flash drive, close the CD tray, OK, and wait for re-boot.
In GParted:
To learn about a partition, right-click > properties.
Large icons across the top open with double-click.
Terminal is useful, and can be used to access some programs (e.g., testdisk, partimage).
When done, close the GParted window with File > Quit. Then double-click the Exit icon at top.
Note 12: md5sum
At Konsole, the command is:
md5sum {name of file}.
Then compare the result to the md5sum you downloaded at the site.
Example: suppose the downloaded file is dlfile.iso and it is in your Desktop
cd Desktop
md5sum dlfile.iso
Press Enter to get the MD5sum, something like this (as an example):
260d2651ad2564748e37b468a848f1b2 dlfile.iso
Compare it to the MD5sum published at the site where you downloaded dlfile.iso. If they don't match, repeat the download and compare again.
Note: You have to change to the directory where the downloaded iso file is located.
The command
pwd
means print the (current) working directory, which will tell you where you are when working at the command line.
= = = = = = = = = = = = = = = = = = = =
3 USB drive shifting: Very important!
=> the key to understanding how to use flash drives and external drives
>>> After reading this, the main SGD /boot/grub/menu.lst will make sense to you.
-- The drive hd0: first BIOS boot drive
Useful Fact:
Whenever a USB drive boots the PC, it is seen by BIOS and by GRUB as hd0.
This is true whether the drive is a flash drive or an external USB HD.
To emphasize this: Suppose you boot your PC using a bootable USB drive (flash drive or external USB HD). From the view of the GRUB on that drive, the drive is seen as hd0 -- the first BIOS boot drive. Thus, the other drives on your system are seen as hd1, hd2, hd3, etc. That is called “drive-shifting.” Your normal hd0 drive gets shifted to hd1; your normal hd1 drive gets shifted to hd2; etc.
-- Drive shifting
Your bootable flash drive as seen by Kubuntu, and as seen from the GRUB on the flash drive
Take that same bootable flash drive. Set it on your desk. Boot into your Kubuntu as you normally do (without using the flash drive). Plug the flash drive in, let it be recognized by Kubuntu. Explore your drives using the GRUB geometry command:
sudo grub
grub>geometry (hd0)
grub>geometry (hd1)
grub>geometry (hd2)
etc.
You will see that the flash drive is seen not as hd0 but as something else.
Example: Suppose you have two internal HDs, sda (=hd0) and sdb (=hd1). Then the flash drive will be seen as sdc = hd2 in Kubuntu.
However, as we explained above, if you boot your PC using the bootable flash drive, from the view of the GRUB on that drive, during the session booted by the flash drive, the drive is seen as hd0; your normal hd0 drive is seen as hd1; your normal hd1 drive is seen as hd2.
This is called “Drive shifting (as seen by the GRUB on your bootable flash drive when the flash drive boots the PC.”
--- Super Grub Disk for USB -- usbshift -- special command for dealing with drive shifting
> Your two options: to use SGD for USB or to manually adjust your device names for drive shifting.
> usbshift and configfile
The special SGD for USB includes a special function called usbshift.
You do not have to use it, unless you care to.
When you use it, it has the effect of shifting the drives back to their “normal” order, placing the flash drive at the end of the list (instead of the flash drive being hd0 at the front of the list).
Example
Suppose you have two hard drives sda = hd0 and sdb = hd1 in your PC. When you boot into Kubuntu, your flash drive is seen as sdc = hd2.
Now, boot your PC using your bootable GRUB-SGD-USB flash drive (the one we just built).
How does the GRUB on the flash drive see your drives (during the session booted by the flash drive)?
Answer:
If you do not use the usbshift function, the drives are seen as follows:
hd0 is the flash drive
hd1 is the drive you know as sda = the usual hd0 drive
hd2 is the drive you know as sdb = the usual hd1 drive
That is, the drives get shifted, they get bumped up one device number.
If you use the usbshift function, the drives are seen as follows:
hd0 is the drive you know as sda = the usual hd0 drive
hd1 is the drive you know as sdb = the usual hd1 drive
hd2 is the flash drive, which is how you usually see it when you are in Kubuntu
That is, the drives retain their “normal” device naming you are used to and as seen in Kubuntu.
-- Your two options: to use SGD for USB or to manually adjust your device names for drive shifting
Example
Let's say in your myLinuxMenu.lst (located on the flash drive in the folder /boot/grub), that you wish to boot an OS which is on the third partition of your second internal hard drive. Normally, you'd refer to that as (hd1,2) (e.g., sdb3).
Thus, in the boot stanza for that OS, in myLinuxMenu.lst, you may refer to that operating system in two ways:
title my OS on sdb3
root (hd2,2)
etc etc etc
or:
title my OS on sdb3
usbshift
root (hd1,2)
etc etc etc
=> If you do not use usbshift, you must manually bump the hard drives up one place, from hd1 to hd2.
=> If you use usbshift, it will maintain your “normal” drive order for you (and put the flash drive at the end of your “normal” list of drives as hd2), and you may refer to the partition sdb3 as you normally do; ie., as (hd1,2).
usbshift and configfile
If you use usbshift before calling a configfile statement, the effect of usbshift “transfers through” the configfile to maintain your “normal” drive order.
= = = = = = = = = = = = = = = = = = = =
4 Appendix: Put GParted in with SGD
Alternate way to partition for GParted: Put it in with SGD in partition 1
You do not need a separate partition for GParted.
Adjustments you need to make.
If you wish, you do not need to put GParted in its own partition. You can put it into the first partition with the SGD files. Here's how:
Partitioning
Make the first partition 125 MB.
Other partitions: It's up to you, for another OS (e.g., Puppy Linux) or for personal data.
Label the first partition of the flash drive: Grub-SGD-GParted.
In Kubuntu, open the GParted Live CD (or open the downloaded iso file), copy all the folders and files
you see there into the first partition of the flash drive.
Main SGD menu.lst (/boot/grub/menu.lst -- in partition 1, Grub-SGD-GParted)
Include the following boot stanza for GParted:
title GParted Live--Live Start Debian Live, partition 2
root $(grub_device)
kernel /live/vmlinuz1 boot=live union=aufs
initrd=/live/initrd1.img
That's all the chnages you need to make.
= = = = = = = = = = = = = = = = = = = =
5 REFERENCES
How To GRUB Methods - Toolkit
http://kubuntuforums.net/forums/inde...opic=3081671.0
(Includes: Change default & timeout, make separate “GRUB boot partition,” etc.)
See also the special topics under Reply #1.
GParted: http://gparted.sourceforge.net/
GParted how-to: http://www.howtoforge.com/partitioning_with_gparted
Commands at Konsole: Beginners
http://kubuntuforums.net/forums/inde...opic=3091607.0
In 3 parts, new/improved, complete basic tutorial.
dd Command
http://kubuntuforums.net/forums/inde...opic=3090824.0
Reply#2: dd APPLICATION Making a quick, free backup of your Kubuntu OS
Tells you how to clone your flash drive--see Reply #1 Applications.
Build a LIVE Kubuntu Flash Drive, How-To
http://kubuntuforums.net/forums/inde...089474.new#new
To Remove U3 from flash drive:
http://www.sandisk.com/Assets/u3/launchpadremoval.exe
http://www.u3.com/uninstall/final.aspx
= = = = = = = = = = = = = = = = = = = = = = = =
First version of this how-to, the original post, written April 11, 2007.
++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++
How To: Make GRUB Thumb Drive (USB Flash Drive, or UFD)
Making a bootable thumb drive with GRUB and your boot menu (menu.lst)
Also, Super Grub Disk. (Optional: GParted; a FAT32 data partition; etc.)
*** To put Linux operating systems on your UFD, scroll down. In particular, see “Simplifying your menu.lst and all the rest of it,” Reply #8, and Puppy follows that in Reply #9. You might wish to read Reply #8 now, before continuing. ***
*** UPDATE: See Reply #10, October 23, 2007, for Update and improvements--better tutorial tips--Super GRUB Disk, GParted & Puppy on the flash drive. ***
Note: This worked on my system: Intel D915GAVL Desktop Board; two SATA HDs: on sda1 is WinXP; on sdb, there are four Kubuntu OSs, Freespire, MEPIS. You may have to make adjustments specific to your setup (HDs, BIOS, and OSs).
Notation, Abbreviations:
HD=hard drive; OS=operating system; POST=Power On Self Test; SGD=Super Grub Disk; UFD=USB Flash Drive or “thumb drive”
The issue: Usually, my two HDs are seen (by BIOS and GRUB) as hd0 and hd1. However, when you plug in the UFD, the drives get shifted, in my case the UFD becomes hd0, my hd0 becomes hd1, and my hd1 gets bumped to hd2. You can imagine the effect this has on the device references in your boot menu (/boot/grub/menu.lst).
- - - - - - - - - - - - - - - - - - - -
Method #1 The old-fashioned way using map commands.
Conceptually, it’s simple: Format your UFD, copy GRUB files to it, use root & setup to install GRUB to the UFD, and finally, edit the menu.lst using the GRUB map command to account for the hard drive shifting described above. This last step can get complicated and messy. And if you make changes to hardware or software, you might also have to change the menu.lst and map commands.
For this method see the following (and the links):
- - Kubuntu Edgy -> Installation & Boot -> GRUB on Thumb Drive:
http://kubuntuforums.net/forums/index.php?topic=12995.0
- - Herman’s bigpond: http://users.bigpond.net.au/hermanzone/p15.htm
- - At hardwareguys, Software -> Operating Systems -> GRUB on Thumb Drive:
http://forums.hardwareguys.com/ikonb...ST;f=12;t=5353
- - - - - - - - - - - - - - - - - - - -
Method #2: An easier way using Super Grub Disk (SGD) (and its GRUB files). (See References below)
SGD for USB uses an innovative command, usbshift, which fixes the hard drive shifting problem by restoring the original hard drive order (that exists normally without the UFD) and putting the UFD at the end of the list. In my example above, using usbshift, when I plug in the UFD, my two HDs are seen as they normally are, hd0 and hd1, and the UFD goes at the end of this list as hd2. There is no need for the complication of map commands in the menu.lst.
- - - - - Here’s how to put SGD (and its GRUB using usbshift) on your UFD:
Partition and format the UFD (see notes below on Partitioning/Formatting the UFD and GParted):
(My BIOS is set to boot from CD first, in order.) Plug in the UFD. Wait for it to be recognized in Kubuntu (mine came up as: node /dev/sdc, mounted as /media/usbdisk). To format the UFD, I use GParted Live CD. Insert the GParted Live CD, re-boot, make a partition sdc1 and format it as Linux (ext2 or ext3). Remove the UFD, then properly exit GParted, removing the GParted CD when prompted, choosing re-boot.
Boot into Kubuntu. Download the file sgd_0.9588_for_usb.tar.gz (or latest version) to the Desktop, right-click on it, Extract Here, and that gives a folder on your Desktop containing the SGD/GRUB files you need.
(sudo: To do this work, you may need to use sudo. So you could open Konsole and use sudo before your commands; or at Konsole, type sudo konsole to get a terminal as root.)
Insert the UFD. Wait for it to be recognized in Kubuntu. Open Konsole Then (hash mark # indicates a comment):
# Make a directory called boot on your UFD:
mkdir -p /media/usbdisk/boot
# Copy the contents of the extracted sgd_usb_0.9588 to directory boot of the UFD:
cp –r /home/myname/Desktop/sgd_usb_0.9588/boot/grub /media/usbdisk/boot
cp –r /home/myname/Desktop/sgd_usb_0.9588/boot/sgd /media/usbdisk/boot
# Unmount the UFD (note the spelling umount):
umount /media/usbdisk
# Get a grub prompt as root (it may take a couple minutes):
sudo grub
grub>
# Make the sdc file a drive (my UFD is sdc = (hd2) in Kubuntu):
device (hd2) /dev/sdc
# Set up GRUB in the UFD using root-setup commands:
grub> root (hd2,0)
grub> setup (hd2)
grub> quit
$: exit
Now, SGD is set up on your UFD. Re-boot, get into your BIOS setup (on my PC, I press the F2 key), and set your BIOS to boot from USB. On mine, I set it to boot from CD first, then the UFD, then my hd0. (With no CD in the tray), when the UFD is plugged in, the PC boots from it; when the UFD is not plugged in, the PC boots as usual from hd0. Save and Exit BIOS. The PC then re-boots from the UFD into SGD.
- - - - - How to include your own menu.lst in the boot menu on the UFD
Normally, my “main” OS is Kubuntu on sdb3, and the /boot/grub/menu.lst there is the boot menu you see when turning on the PC. (The GRUB from sdb3 is set up in the MBR of the first hard drive (hd0).)
To include this menu.lst in the boot menu of the UFD, do the following (in Konqueror, or Konsole, or copy/paste or drag/drop).
Off to the side, copy onto Desktop your own GRUB menu.lst; rename it myLinuxMenu.lst (or anything) and save it (as plain text or .txt).
The SGD (on the UFD) contains a /boot/grub directory. Copy the file myLinuxMenu.lst into it:
cp /home/myname/Desktop/myLinuxMenu.lst /media/usbdisk/boot/grub
The SGD (on the UFD) also contains a /boot/grub/menu.lst. Open it (as root), and add a boot stanza entry to this menu.lst (I’m placing this in default position zero, but that’s up to you):
# The SGD main /boot/grub/menu.lst for booting both my GRUB menu.lst and SGD on UFD
default 0 # which is the myLinuxMenu.lst entry below
timeout 10
setgrubdevice # This sets the UFD as the grub device
# and you may see other stuff up front, like gfxmenu
# Then put the boot entry for your own menu.lst, such as:
title myLinuxMenu.lst # Call it anything you want
usbshift # this line is necessary
configfile $(grub_device)/boot/grub/myLinuxMenu.lst
(And following this comes all the “title” boot entries that come with SGD, and the main SGD menu. Save, Exit.)
That’s it. Now, when you re-boot with the UFD plugged in, the boot menu you see will show both your regular menu.lst and other entries for SGD.
- - - - - Partitioning/Formatting the UFD and allowing for other things like GParted on UFD
The SGD with myLinuxMenu (above) took less than 2 MB. Using GParted Live CD to partition/format the UFD, you may want to include other things on the UFD, like a FAT32 data partition. GParted also comes in a USB version that you can put on UFD. I did that, by making two partitions:
sdc1 (bootable) for SGD, including myLinuxMenu, and GParted (which took about 40 MB installed)
sdc2 a FAT32 data partition
Note: I formatted sdc1 as FAT16 because I believe (but am not sure) that GParted USB requires that. I don’t know if it’ll go into FAT32.
Note: When GParted partitions sdc1, it starts sdc1 at sector 63, allowing space for the MBR (512 bytes) (plus the next 62 sectors empty, or 15 sectors for GRUB Stage_1.5).
Note: With two partitions sdc1 and sdc2, in Kubuntu, the UFD shows up as 2 icons, /dev/sdc1 mounted as file /media/usbdisk and /dev/sdc2 mounted as file /media/usbdisk-1. (It may be the reverse of this, or something else on your system. I have two SATA HDs which show up as sda = (hd0) and sdb = (hd1), so the UFD shows up as sdc = (hd2).)
- - Here’s the details for (one method of) putting GParted on the UFD:
Do the partitioning/formatting of sdc1 and sdc2 (above).
At the GParted site, download the gparted-liveusb-0.3.1-1.zip. Using ARK in Kubuntu, extract it to a folder on your Desktop. I called the folder GP0311usb. The contents of GP0311usb were 7 files: boot.cat, boot.msg, gparted, initrd.gz, linux, splash.lss, and syslinux.cfg
Put GParted files and SGD in sdc1:
Copy the contents of the folder GP0311usb to sdc1 of the UFD. Do this any way you want, at Konsole or in Konqueror (copy/paste, drag/drop). NOTE: I did not copy the folder itself, but only the 7 files contained in it. For some reason, that's the only way I could get it to work. Otherwise, I'd get a kernel panic when GParted tried to load. I tried using the folder and naming it in the kernel and initrd paths, like initrd $(grub_device)/GP0311/initrd.gz, but it would not go that way.
Proceed exactly as above to put SGD and myLinuxMenu.lst into sdc1 and set up GRUB using root-setup.
Summary so far:
If you open sdc1, at the top level, you see the folder (from SGD) called boot; you also see the (7) GParted files laying there loose at the same level as the boot folder. Inside boot are two folders, grub and sgd. GRUB is setup in the MBR of the UFD to start the bootloading of both SGD and of GParted.
Next step: Modify the SGD boot menu you see when you turn on the PC (the SGD /boot/grub/menu.lst file of sdc1, on the UFD) by adding a “title” boot entry for GParted. Do this edit as root and save your changes. Like the following:
title GParted 0.3.1.1 for USB
root $(grub_device)
kernel /linux noapic root=/dev/ram0 init=/linuxrc ramdisk_size=65000
initrd /initrd.gz
That's it. Now with the UFD plugged in, re-boot. After the POST, up comes the SGD boot menu (/boot/grub/menu.lst), giving you choices of myLinuxMenu, GParted, Super Grub Disk, (and any other stuff you have included as a boot entry). Select one by highlighting it and press Enter.
- - An example test: I used the GParted on this UFD to partition and format another USB thumb drive that was plugged into a second USB slot on the front of the PC case (which came up as sdd).
- - - - - - - - - - - - - - - - - - - -
Some details you may wonder about.
- - - Where do these two lines come from:
kernel $(grub_device)/linux noapic root=/dev/ram0 init=/linuxrc ramdisk_size=65000
initrd $(grub_device)/initrd.gz
Answer: Kind of by trial-and-error copying luck imitating hoping and pattern-matching
One of the GParted files was syslinux.cfg, a plain text configuration file (some GParted also have a isolinux.cfg.) In there I found a kernel reference line. I separated out the initrd= part, and kept the rest for my kernel line, and used the initrd.gz of initrd=initrd.gz for my initrd line. You can google yourself nuts about kernel options, and even learn some things now and then. An expert could write those lines from scratch. But I can't yet.
- - - usbshift command. Remember that you are using a special sgd_usb version of SGD/GRUB. So when you use it manually or otherwise, don't forget the usbshift.
Example:
With the GParted-SGD UFD plugged in, you re-boot and see the boot menu, and you decide to get a grub> prompt by pressing the “c” key. Then you type a command like configfile (hd1,2)/boot/grub/menu.lst (which is my Kubuntu on sdb3). You will probably get an Error 15: File not found or some other error. So, instead, use the following two lines:
grub> usbshift # then press Enter, usbshift ensures that (hd1,2) makes sense in the next line
grub> configfile (hd1,2)/boot/grub/menu.lst # then press Enter
- - - To manage/extract the GParted zip file, I used ARK. In Kubuntu under K-Menu – Utilities – ARK Archiving Tool. Click Help to get ARK Handbook. It manages, extracts the gparted zip file.
- - - UFD may come with software. My Memorex came with U3 which is neat, but to erase it go to www.U3.com/uninstall . (Must be in Windows to run this)
References
How-To GRUB Methods - Toolkit: http://kubuntuforums.net/forums/inde...opic=3081671.0
GRUB: http://www.gnu.org/software/grub/
Major credit to SuperGrubDisk: http://supergrub.forjamari.linex.org/
(At the SGD site, go to Downloads and scroll to the USB section. Today, the latest version is 0.9588: sgd_0.9588_for_usb.tar.gz)
bigpond at http://users.bigpond.net.au/hermanzone/p15.htm
GParted Live CD at: http://gparted.sourceforge.net/livecd.php
(Optional: GParted Live on Flash Drive.)
--- A toolkit for building bootable flash drives.
(Key words: GRUB on a Flash Drive, on USB Flash Drive, on Pendrive, on USB Device.
Option: GParted Live on Thumb Drive, on USB Flash Drive, on Pendrive, on USB Device.)
Other related projects:
-- To clone your flash drive, see REFERENCES, dd Command.
-- To build a Live Kubuntu persistent flash drive, see REFERENCES, Build a LIVE Kubuntu Flash Drive, How-To
-- How to Install Kubuntu to an External USB HDD: See Reply #1 (following this post)
External USB hard drives: Same methods as for flash drives!
The methods for USB flash drives are the same as for external hard drives.
-- Comment about other posts in this thread
Reply #1 is maintained:
How to install K/Ubuntu 7.04 to an external USB hard disk drive (HDD).
The following are not maintained any longer: Replies #5, 6, 7, 8, 9, 10, 12.
However, you may find useful information in some of them:
USB experiment: USB drive shifting Reply #5.
Simplifying your menu.lst and all the rest of it, Reply #8
Puppy Linux on USB Flash Drive (UFD) Reply #9
Super Grub Disk, GRUB, GParted & Puppy on a flash drive Reply #10
Knoppix on USB Flash Drive (UFD), Reply #6 & #7
Install Kubuntu 7.10 to a flash drive (UFD) Reply #12
First version of this how-to, the original post, this first post, is attached at the end here, following the REFERENCES.
TABLE of CONTENTS
Abbreviations
1 How-to do it: The basic how-to
2 Notes -- details, tips, options, methods, additional information
3 USB drive shifting: Very important!
=> the key to understanding how to use flash drives and external drives
Super Grub Disk for USB -- usbshift -- special command for dealing with drive shifting
4 Appendix: Put GParted in the same partition with SGD
Alternate way to partition for GParted: Put it in with SGD in partition 1
You do not need a separate partition for GParted.
Adjustments you need to make.
5 REFERENCES
List of Notes
Note 1: BIOS issues, assumptions: “Boot from USB”
Note 2: Compressed files (bz2 & bzip) and using Ark in Kubuntu
Note 3: Using the special SGD USB
Note 4: Use K3b (in Kubuntu) to burn your GParted Live CD
Note 5: How to zero-out your flash drive
Note 6: Setting labels at the command line: This is changed!--see the Note 6.
Note 7: Open a file manager as root
Note 8: Copying hidden folders and files in GUI and CLI
Note 9: Accessing files on a downloaded iso file (without burning a CD)
Note 10: Find out how Kubuntu & GRUB see the flash drive
Note 11: Using GParted Live CD -- logistics
Note 12: md5sum (of downloaded files)
= = = = = = = = = = = = = = = = = = = =
Abbreviations
CLI: command line interface, refers to using Konsole
GUI: graphical user interface, using Konqueror or Dolphin
HD: hard drive; HDD: hard disk drive
MB: megabyte
OS: operating system
SGD: Super Grub Disk
UFD=USB flash drive (thumb drive, pen drive, etc.)
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
1 How-to do it: The basic how-to
Goal
To put your GRUB boot menu and Super Grub Disk on a flash drive.
Optional: To put GParted Live on the same flash drive.
(Instructions are given for GParted, which you may choose to do or to omit.)
-- At a minimum, we will install Super Grub Disk to the flash drive, and we'll include your own boot menu, which you can use to boot your operating systems directly. Super Grub Disk can be used to boot into your operating systems when you are otherwise unable to do so.
-- As an option, you may put GParted Live on the flash drive. GParted is a handy partitioning editor.
-- You will see how to easily include other programs or Puppy Linux on the same flash drive.
-- You may also include a data partition for your personal use.
See Note 1: BIOS issues, assumptions: “Boot from USB”
Overview
We assume you will do this work in Kubuntu/Linux.
Step 1 Download SGD for USB
[and optionally, GParted Live CD files--you do NOT need the USB version of GParted].
Step 2 Prepare the flash drive:
Zero-out (optional), partition, format, set boot flag, set labels
Method: Use GParted Live CD; or gparted from Kubuntu
Step 3 Copy files from SGD [and GParted Live CD] to the flash drive
SGD: Extract the boot directory; copy it into the first partition of the flash drive
GParted: Copy all GParted files to the (second partition) of the flash drive
Step 4 GRUB
Set up GRUB in the MBR of the flash drive;
Build the boot menu (menu.lst)
Step 5 You are done! Re-boot to test it
Step 1 Download SGD for USB [and GParted Live CD files]
-- Download SGD for USB from here:
http://www.supergrubdisk.org/
Example
Super Grub Disk for USB: super_grub_disk_english__usb_0.9766.tar.gz
Download that file to your Desktop. Right-click on it, select Extract Here, you get a folder named “boot”. (We need this folder and its contents to make the UFD bootable and usable.)
See Note 2: Compressed files (bz2 & bzip) and using Ark in Kubuntu.
See Note 3: Using the special SGD USB.
-- GParted Live CD
This is handy. You can use it to build the flash drive, and you can include GParted Live on the flash drive. For my method, you do NOT need to download the USB version of GParted: simply get the regular “live” (live CD) version.
Example: gparted-live-0.3.9-13.iso
(11/28/08--this new version includes capability to make Labels)
Check the MD5sums (See Note 12: md5sum).
See Note 4: Use K3b (in Kubuntu) to burn your GParted Live CD.
Step 2 Prepare the flash drive:
Zero-out (optional), partition, format, set boot flag, set labels
Method: Use GParted Live CD; or gparted from Kubuntu
Example: Flash Drive: 512 MB SanDisk
Desired end result: (partitions sdc2 and sdc3 are optional)
Partition - Label -Format - Size
sdc1 Grub-SGD ext2 8 MB (the minimum allowed by GParted) Boot Flag set
sdc2 GParted FAT32 125 MB
sdc3 MyData FAT32 the rest of the space - for personal data use
CAUTION: Your device names (sdxn) may be different!
See Note 10: Find out how Kubuntu & GRUB see the flash drive
Optional step: Wipe your flash drive clean, like factory-new.
See Note 5: How to zero-out your flash drive
(You can do this in Kubuntu or in GParted.)
Partition table/Master Boot Record: Flash drives that have been zeroed-out: If doing the partitioning using GParted, you will be prompted to accept a DOS-like partition table (in the Master Boot Record). If you are going to make the flash drive bootable with GRUB, accept this offer.
See Note 11: Using GParted Live CD -- logistics
Insert GParted Live CD. Re-boot the PC. Get the GParted screen.
Insert the Flash drive into USB port.
GParted (tab, upper left) > Refresh Devices
Confirm that the flash drive is recognized:
Drop down list at upper right of screen; or GParted (tab) > Devices
Example: Mine came up as sdc.
-- Optional: Zero-out the flash drive to wipe it clean-clean (factory new). See Note 5.
-- Conduct the partitioning and formatting (as indicated above -- “Desired end result”)
Note: In GParted, tabs at top,
Partition > Label
Partition > Flags > Boot (check box)
Labels: You can also set labels at the command line (in GParted or in Kubuntu)
See Note 6: Setting labels at the command line.--CHANGED!!!
The method works only for ext2/ext3, NOT for FAT32, which is a more complicated case and is NOT covered in this How-to.
Step 3 Copy files from SGD [and GParted Live CD] to the flash drive
SGD: Extract the boot directory; copy it into the first partition of the flash drive
GParted: Copy all GParted files to the (second partition) of the flash drive
GUI or CLI: You can do this work in two ways.
GUI: Konqueror or Dolphin (file managers)
CLI: In Kubuntu at Konsole
File managers Konqueror and Dolphin: Use copy/paste or drag-and-drop.
See Note 7: Open a file manager as root
Copying hidden files and folders
Whichever way you use, be certain that you also copy any hidden folders and files.
See Note 8: Copying hidden folders and files in GUI and CLI
Copy the files into the flash drive (using root as necessary):
Copy the SGD files into partition 1 of the flash drive.
Copy the GParted files into partition 2 of the flash drive.
Here's some CLI notes:
-- Copying SGD files into the flash drive partition 1 (Grub-SGD)
Extract the SGD files (Right-click > Extract Here to get boot directory)
Copy the directory boot from Desktop into Grub-SGD.
Example Suppose the first partition of the flash drive is mounted as /media/sdc1.
(You can do that: sudo mount /dev/sdc1 /media/sdc1)
cd Desktop
sudo cp -r boot /media/sdc1
So, when you open the first partition, you see the boot folder (directory).
-- Copying GParted files into the flash drive partition 2 (GParted)
If you burned the GParted Live CD (from the iso), put the GParted CD into the CD drive and let it come up. As an example, suppose it is mounted as /media/cdrom0; and suppose the second flash drive partition is mounted as /media/sdc2 (sudo mount /dev/sdc2 /media/sdc2). Then,
cp -r /media/cdrom0/* /media/sdc2
Using the gparted iso file (without burning the GParted Live CD)
If you did not burn the GParted Live CD (using the gparted iso file), you can open the iso and copy the files into the second partition of the flash drive (without burning the Live CD).
See Note 9: Accessing files on a downloaded iso file (without burning a CD)
Step 4 GRUB
Set up GRUB in the MBR of the flash drive
Build the boot menu (menu.lst)
Reference for GRUB, setup and menu.lst, my how-to:
How To GRUB Methods - Toolkit
http://kubuntuforums.net/forums/inde...opic=3081671.0
Set up GRUB in the MBR of the flash drive
So far, SGD and GParted are copied to the two flash drive partitions SGD-Grub and GParted.
Next, we set up GRUB on the flash drive. Get a grub prompt as root:
sudo grub
We need to know how GRUB names the first partition of the flash drive since it contains the GRUB files we need to set up in the MBR of the flash drive. Use geometry to find out.
grub>geometry (hd<press the TAB key>
Try some of the results: grub>geometry (hd0), grub>geometry (hd1), grub>geometry (hd2), etc.
Study the output to determine which drive is the flash drive.
Example: Suppose it is hd2.
grub>root (hd2,0) # (hd2,0) is the SGD-GRUB partition of the flash drive
grub>setup (hd2) # (hd2) is the Master Boot Record of the flash drive
grub> quit
$: exit
So far, SGD--and its GRUB--is set up on your flash drive.
With the flash drive connected, if you re-boot now from the flash drive, your PC will boot into SGD. The GParted partition is setup but is not on the boot menu yet; nor is your personal menu.lst.
Menu.lst
Build the boot menu (/boot/grub/menu.lst):
Include boot entries for GParted and myLinuxMenu.lst
Have a look at the boot menu. In Kubuntu, plug the flash drive in, open the first partition, Grub-SGD, navigate to and open the main boot menu, /boot/grub/menu.lst. You must modify it by including a boot entry for your personal menu.lst, which we'll call myLinuxMenu.lst, and a boot entry for GParted (actually two, one for normal Live and one for fail-safe mode). When you boot the PC from the flash drive, this is the boot menu you will see first, from which you'll select where to go next.
Here's the desired end result, with various SGD entries abbreviated, after which, we'll explain it:
# /boot/grub/menu.lst for the flash drive
# This is the main boot menu for calling
# your personal menu.lst, GParted, SGD,
# and other programs/OSs you have on the flash drive.
# You can edit this file to add your own distribution
## The two commands: setgrubdevice and usbshift are needed
## so that SGD works well.
#usbshift
#configfile $(grub_device)/boot/sgd/menu.lst
# Just after default and timeout statements you have to put
# setgrubdevice so that grub device is correctly set.
#
# Note that the default boot entry is default=0 which is myLinuxmenu.lst
default 0
timeout 10
setgrubdevice # This is compulsory
#sgdgfxmenu /boot/grub/message
foreground ffffff
background 0c00ff
color white/brown yellow/cyan
title myLinuxMenu.lst
usbshift # this is necessary
configfile $(grub_device)/boot/grub/myLinuxMenu.lst
title GParted Live--Live Start Debian Live, partition 2
root (hd0,1)
kernel /live/vmlinuz1 boot=live union=aufs
initrd=/live/initrd1.img
title GParted Live --Start Debian Live (fail-safe mode), partition 2
root (hd0,1)
kernel /live/vmlinuz1 boot=live union=aufs noapic noapm nodma nomce nolapic nosmp vga=normal
initrd=/live/initrd1.img
#title Inicio normal / Normal Boot: etcetera
#title Soporte de accesibilidad / Accesibility Support -->
#configfile $(grub_device)/boot/grub/menu2.lst
title Super Grub Disk
# The two commands: setgrubdevice and usbshift are needed
# so that SGD works well.
usbshift
configfile $(grub_device)/boot/sgd/sgd.lst
#title Normal boot. Kernel is aware of Boot device, etcetera
#title Normal boot. Selecting kernel and initrd files depending on grub_device
#title Selecthd test
#title findp test
#title set SGD variables and boot SGD
#
# End of the main /boot/grub/menu.lst
Comments: how to build /boot/grub/menu.lst
-- myLinuxMenu.lst
You'll note the boot entry for SGD, which calls its own separate menu.lst stored in the separate SGD folder sgd and called /boot/sgd/sgd.lst.
Likewise, you will do the same thing for YOUR personal menu.lst, but you will put yours in the regular grub folder:
title myLinuxMenu.lst
usbshift # this is necessary
configfile $(grub_device)/boot/grub/myLinuxMenu.lst
Notes:
The usbshift command is a special SGD-for-USB command; it's effect is to make the device references in your personal menu.lst, myLinuxMenu.lst, work correctly from the flash drive.
See the special section 4 below:
4 USB drive shifting: Very important!
=> the key to understanding how to use flash drives and external drives
GParted: root (hd0,1)
Since GParted is located on the flash drive, and the (native) GRUB of the flash drive sees the flash drive as hd0, you do not need the usbshift function to reference the GParted partition: it is simply the second partition of the booted flash drive, or (hd0,1).
$(grub_device) is a SGD variable; in this case, it contains the device name that contains your personal menu.lst, /boot/grub/myLinuxMenu.lst. Its value is set by the statement
setgrubdevice
and is equal to the first partition of the flash drive (i.e., it is equal to “where we are now”!).
Next step: Build myLinuxMenu.lst
Now, obviously, you must create myLinuxMenu.lst and place it in the folder /boot/grub of partition 1 of the flash drive. If you wish, you may simply copy the main menu.lst you use to boot your PC; or you can pick and choose from that menu.lst to build myLinuxMenu.lst. The device references contained in your regular menu.lst, such as root (hd0,0) or root (hd0,1) or (hd1,0), etc., will continue to work when called from the flash drive /boot/grub/menu.lst (or /boot/grub/myLinuxMenu.lst) thanks to the usbshift function.
Example
In my case, I normally boot my PC using a separate GRUB partition sdb1 (as described in my How To GRUB Methods - Toolkit link above (see REFERENCES). The menu.lst in that partition is very simple: it calls the various OSs on my PC using configfile; here it is:
# sdb1 GRUB partition menu.lst
default 0
timeout 10
# Pretty colours
color cyan/blue white/blue
title Kubuntu 8.04 sdb2 = (hd1,1)
configfile (hd1,1)/boot/grub/menu.lst
title Windows XP Home Edition sda1
root (hd0,0)
chainloader +1
title Kubuntu 8.10 Intrepid sdb3 = (hd1,2)
configfile (hd1,2)/boot/grub/menu.lst
Thus, I could copy that and make it the myLinuxMenu.lst to put in /boot/grub partition 1 of the flash drive. But if I ever changed any of those OSs or their partitions, I would then have to modify myLinuxMenu.lst on the flash drive--an inconvenience, and I might forget to do it. So, instead, I will create a very simple myLinuxMenu.lst:
# This boots my GRUB partition on sdb1 = (hd1,0)
default 0
timeout 10
title My GRUB Partition boot menu on sdb1 = (hd1,0)
configfile (hd1,0)/boot/grub/menu.lst
That's it! So here's what happens if I boot the PC using the flash drive:
First I see the main SGD menu.lst. Suppose I choose myLinuxMenu.lst. then I'll see the choice “My GRUB Partition boot menu on sdb1 = (hd1,0)” and I'll select it. Then I'll see the three choices from the menu.lst on my GRUB partition sdb1: “Kubuntu 8.04 sdb2 = (hd1,1),” “Windows XP Home Edition sda1,” and “Kubuntu 8.10 Intrepid sdb3 = (hd1,2).” And I'll choose one of them. Kind of indirect, I admit, but it is easy to maintain (e.g., when there are kernel updates or when I change my partitions or OSs), and keep in mind that I would usually only use the flash drive to boot in an emergency or exceptional situation, not every day. You can, however, set the default 0 statements (as I have) and reduce the timeouts to 2 or 3 seconds to make it all go automatic and fast.
Summary so far So, you must do, for yourself, two things:
First, in partition 1 of the flash drive, in the file /boot/grub/menu.lst, include the following boot stanza that calls your personal menu.lst:
title myLinuxMenu.lst
usbshift # this is necessary
configfile $(grub_device)/boot/grub/myLinuxMenu.lst
Second, create a text file called myLinuxMenu.lst, place your personal boot entries in it (your personal menu.lst), and place the resulting file in the folder /boot/grub of partition 1 of the flash drive.
-- GParted Live boot entries in /boot/grub/menu.lst of the flash drive (in the Grub-SGD partition)
Now, we need a boot entry for GParted.
In Kubuntu, open the second partition of the flash drive, click on the folder isolinux, then open the file
/isolinux/menu.cfg, and you'll see this:
LABEL live
MENU LABEL Start Debian Live
kernel /live/vmlinuz1
append initrd=/live/initrd1.img boot=live union=aufs
LABEL livefailsafe
MENU LABEL Start Debian Live (fail-safe mode)
kernel /live/vmlinuz1
append initrd=/live/initrd1.img boot=live union=aufs noapic noapm nodma nomce nolapic nosmp vga=normal
I used this to construct GRUB boot entries for GParted as follows:
title GParted Live -- Start Debian Live on partition 2
root (hd0,1)
kernel /live/vmlinuz1 boot=live union=aufs
initrd=/live/initrd1.img
title GParted Live -- Start Debian Live (fail-safe mode) on partition 2
root (hd0,1)
kernel /live/vmlinuz1 boot=live union=aufs noapic noapm nodma nomce nolapic nosmp vga=normal
initrd=/live/initrd1.img
Place those two boot stanzas into the main SGD menu.lst above
(# /boot/grub/menu.lst for the flash drive).
That worked for GParted.
If it had not worked, I would have done the following to get correct boot stanzas for GParted:
> Poke around the GParted files and find something else to try;
> Use google to learn about the boot options for GParted;
> Try the GParted site for tips:
> Post a direct question in the GParted user forum and hope that an expert would post a correct boot stanza for me to use; if not, unashamed, I would do a bump .
This completes
Menu.lst -- Build the boot menu (/boot/grub/menu.lst)
and it completes the GRUB work.
-- Optional: Other OSs/programs
You may include any other programs/OSs on this flash drive. For example, you can include Puppy Linux in its own partition, and call it from the main Grub-SGD menu.lst. See Reply #10 for that.
Tips, methods
Here's some tips/methods to help you do the edits to the main SGD menu.lst in the Grub-SGD partition.
Suggestion:
It is probably easier and faster for most people to do the menu.lst work using their file manager, on the Desktop, copy/paste, rather than to use Konsole. If you prefer to use the command line, then you already know how, and I won't include the details, which would only make it seem more complicated than it is.
> You may have to do the edits as root.
> You can do the work at CLI or GUI: Konsole or using a file manager, Konqueror, Dolphin, etc.
> Kate
To open the main Grub-SGD menu.lst as root in the text editor Kate
(assuming the mount point is /media/sdc1):
In 8.10:
kdesudo kate /media/sdc1/boot/grub/menu.lst
In 8.04:
kdesu kate /media/sdc1/boot/grub/menu.lst
=> After making edits, File > Save, File > Quit.
> Mount point:
This assumes that the first partition of the flash drive is mounted as /media/sdc1. If not, substitute the correct mount point.
See mounts points using:
mount
or
cat /etc/mtab
Make mount points and mount:
To make the mount point /media/sdc1 for device /dev/sdc1 and to mount it:
sudo mkdir /media/sdc1
sudo mount /dev/sdc1 /media/sdc1
To unmount it after making edits (note the spelling umount):
sudo umount /dev/sdc1 /media/sdc1
> Open Konqueror or Dolphin as root:
In 8.10:
kdesudo konqueror
kdesudo dolphin
In 8.04:
kdesu konqueror
kdesu dolphin
Then, navigate to the mount point for the partition Grub-SGD (e.g., in /media), and open /boot/grub/menu.lst.
> Copy files
Suppose you build the myLinuxMenu.lst that you want, and it's on your Kubuntu Desktop (as an example). To copy it into the the grub directory of the Grub-SGD partition, assuming the Grub-SGD partition is mounted as /media/sdc1:
sudo cp /home/your_name/Desktop/myLinuxMenu.lst /media/sdc1/boot/grub
> myLinuxMenu.lst: Text files, opening kate, saving the file, using root
The file myLinuxMenu.lst should be a text file.
In Konqueror or Dolphin, create a text file by
right-click > Create New > Text File
At Konsole, open Kate to get a new text document, File > Save As, and name it myLinuxmenu.lst:
Konsole
kate
File > Save As
Navigate to where you want it (your /home Desktop, or the flash drive folder /media/sdc1/boot/grub, etc.).
To open kate as root:
In 8.10:
kdesudo kate
In 8.04:
kdesu kate
If you open Kate as root, beware that saving it in home will save it in root's home, not your home; if you want it in your home, you have to Save As and navigate to home > your name > Desktop or wherever you wish to place it.
Step 5 You are done! Re-boot to test it
= = = = = = = = = = = = = = = = = = = =
2 Notes -- details, tips, options, methods, additional information
Note 1: BIOS setup issues -- Set your BIOS to boot from USB
Your BIOS must support the capability to "boot from USB." With the flash drive connected, re-boot, enter BIOS setup, set your BIOS to boot from USB. Set it to boot from CD first, then the flash drive, then your first hard drive. With no CD in the tray, with the flash drive plugged in, the PC boots from it; when the UFD is not plugged in, the PC boots as usual from the first hard drive. Save and Exit BIOS. The PC then re-boots from the flash drive.
Note 2: Compressed files (bz2 & bzip) and Ark in Kubuntu
Example SGD: super_grub_disk_english__usb_0.9766.tar.gz
The .bz2 is a bzip2 file--a compressed file (to make the file smaller for faster download). (Another type is .gz or gzip.) The extension .tar means the file is a tarball or tape archive file. The tarball has been compressed by bzip2. In Kubuntu, open the tarball with Ark (Archive extractor). Two ways:
(1) K-Menu>Utilities>Ark, File>Open, Desktop, click the file super_grub_disk_english__usb_0.9766.tar.gz, Open, Action>Extract, All files, select destination folder for the extracted files to go. Or,
(2) Right click on super_grub_disk_english__usb_0.9766.tar.gz, select Extract here.
Note 3: Using the special SGD USB
The special SGD for usb is needed if the flash drive is used to boot OSs NOT located on the flash drive, as SGD does or as myLinuxMenu.lst does. See the section below titled, “USB drive shifting: Very important! => the key to understanding how to use flash drives and external drives.”
Note 4: Use K3b in Kubuntu to burn the GParted Live CD
You'll find K3b under the K-menu (perhaps multimedia or system or applications). Select “Burn CD Image,” Image to Burn (Browse to the Desktop--or wherever you downloaded gparted, click gparted-livecd-0.3.9-13.iso, click OK, place a blank CD in CD tray, close the tray door; Speed: select 4x or the slowest speed offered, click Start. Wait for it to finish, click Close, then File>Quit, eject the CD, and using a magic marker write the version on the safe (top) side of the CD (e.g., "gparted-livecd-0.3.9-13.iso" , and release date 11-28-08).
Note 5: How to zero-out your flash drive: dd if=/dev/zero of=/dev/sdx
Wipe your flash drive clean, like factory-new. Easy! BUT, CAUTION! You must get the device-naming sdx correct! If you use the wrong one, you'll wipe out an entire drive!
Result: This will write zeros to every bit of your flash drive, including the Master Boot Record.
Where to do it: You need a terminal in a Linux distro. You can do this in Kubuntu at Konsole (even in Live CD) or in GParted.
In Kubuntu: Insert the flash drive. Open Konsole.
In GParted: Insert the flash drive. GParted (tab at upper left) > Refresh Devices. It should come up under GParted > Devices and under the drop-down list at top right of screen. Double-click Terminal (icon at top).
Commands:
Use this command to identify how your flash drive is named:
sudo fdisk -lu
Put that name sdx in the next command and press Enter:
dd if= /dev/zero of=/dev/sdx
(Sudo: If necessary run it using sudo dd if=/dev/zero of=/dev/sdx)
# Example: dd if=/dev/zero of=/dev/sdc
It will take awhile to run--you will not see any progress status, but the light on your flash drive will blink. When finished, you'll get a brief summary report and returned to the command prompt.
Type exit.
Note 6: Setting labels at the command line
This works only for ext2/ext3 filesystems.
It does not work for FAT32, which is a more complicated case and is NOT included here.
For FAT32: use a recent version of GParted Live CD.
Kubuntu: Open Konsole
GParted Live CD: Double-click Terminal (icon at top)
To set the Labels
Grub-SGD on sdc1
GParted on sdc2
MyData on sdc3
Use these commands:
sudo e2label /dev/sdc1 Grub-SGD
sudo e2label /dev/sdc2 GParted
sudo e2label /dev/sdc3 MyData
CAUTION: Use the correct device names sdxn for your flash drive partitions.
Note 7: Open a file manager as root
In 8.10:
kdesudo konqueror
kdesudo dolphin
In 8.04:
kdesu konqueror
kdesu dolphin
Note 8: Copying hidden folders and files in GUI and CLI -- Check this carefully!
-- GUI (Konqueror or Dolphin):
After opening a window containing the files, click View > Show hidden files.
-- CLI:
Example: To copy the contents (not dir1 itself) of directory dir1 into directory dir2
The following statement should do it:
cp -r dir1/* dir2
HOWEVER, for the wild card * to include hidden folders (and files), you must configure your BASH terminal (Konsole) correctly (if it is not already so by default)--Check this carefully!
Two ways to do:
First way: Issue the command
shopt -s dotglob
before the copy cp command.
Second way: Edit the file ~/.bashrc to include this line:
shopt -s dotglob
See the REFERENCE “Commands at Konsole” (how-to @Kubuntu)
Another way: This statement also does the trick:
cp -RT dir1 dir2
Note 9: Accessing files on a downloaded iso file (without burning a CD)
This works for any downloaded .iso file.
Example: GParted gparted-live-0.3.9-13.iso
Download the iso file to the Desktop. (If it's a tar.gz file or similar, get the iso by right-click, Extract Here, or by using K-Menu > Utilities > ARK) The file name is gparted-live-0.3.9-13.iso (on the Desktop): /home/your_name/Desktop/gparted-live-0.3.9-13.iso.
Open Konsole, make a directory GPartedTemp for your mount point
sudo mkdir /mnt/GPartedTemp
# Mount the iso on GPartedTemp
sudo mount -t iso9660 -o loop /home/your_name/Desktop/gparted-live-0.3.9-13.iso /mnt/GPartedTemp
# If you wish, you can change directories (cd) to /mnt/GPartedTemp
# and list (ls -al) the files to see what's there.
# Make another directory called GParted_Files on the Desktop
sudo mkdir /home/your_name/Desktop/GParted_Files
# Copy the GParted files to GParted_Files
sudo cp -R /mnt/GPartedTemp/* /home/your_name/Desktop/GParted_Files
# (If necessary) Change the ownership so you can have these files by:
# sudo chown -R your_name:your_name /home/your_name/Desktop/GParted_Files
# Then unmount the iso (note the spelling umount)
sudo umount /mnt/GPartedTemp
# To invoke root, use sudo (as I have above when necessary)
Note 10: Find out how Kubuntu & GRUB see the flash drive
Kubuntu (/dev/sdxn)
Command: sudo fdisk -lu
Command: cat /etc/mtab (for mounting)
Command: mount (for mounting)
Also, plug the flash drive into a USB port. After it is recognized, click OK to close the window that pops up.
-- In your file manager (Konqueror/Dolphin): Storage Media or /Media. You will find device and mounting information.
-- Also: Right-click on the flash drive icon, select Properties, you will see information about how it is mounted (e.g., /media/sdc1).
GRUB (hdx,y)
Example
Open Konsole. To get a GRUB prompt, type
sudo grub
grub> geometry (hd<press the TAB key now>
Possible disks are: hd0 hd1 hd2. Try hd2:
grub> geometry (hd2)
drive 0x82: C/H/S = 49600/5/32, The number of sectors = 7936000, /dev/sdc
Partition num: 0, Filesystem type is fat, partition type 0xc
That looks like the flash drive. (The other two disks are too big.)
Note 11: Using GParted Live CD -- logistics
In Kubuntu (or, with your PC on), place GParted CD in the CD tray. Close all open programs. Re-boot into GParted (BIOS must be set to boot first from CD ROM). When the GParted window appears, insert the flash drive, then GParted > Refresh Devices, select the flash drive from the drop-down list of your drives at the upper right. Partition and format as follows: To create the first partition, click on the unallocated space, Partition > New, set the size and type, OK, click the Apply icon to make it go.
NEW flash drives or those that have been zeroed-out: You will be prompted to accept a DOD-like partition table (in the Master Boot record). If you are going to make the flash drive bootable with GRUB, accept this offer.
Repeat this for other partitions. Then GParted > Quit, double click the red Exit button, Eject & re-boot -- OK, remove both the GParted CD and the flash drive, close the CD tray, OK, and wait for re-boot.
In GParted:
To learn about a partition, right-click > properties.
Large icons across the top open with double-click.
Terminal is useful, and can be used to access some programs (e.g., testdisk, partimage).
When done, close the GParted window with File > Quit. Then double-click the Exit icon at top.
Note 12: md5sum
At Konsole, the command is:
md5sum {name of file}.
Then compare the result to the md5sum you downloaded at the site.
Example: suppose the downloaded file is dlfile.iso and it is in your Desktop
cd Desktop
md5sum dlfile.iso
Press Enter to get the MD5sum, something like this (as an example):
260d2651ad2564748e37b468a848f1b2 dlfile.iso
Compare it to the MD5sum published at the site where you downloaded dlfile.iso. If they don't match, repeat the download and compare again.
Note: You have to change to the directory where the downloaded iso file is located.
The command
pwd
means print the (current) working directory, which will tell you where you are when working at the command line.
= = = = = = = = = = = = = = = = = = = =
3 USB drive shifting: Very important!
=> the key to understanding how to use flash drives and external drives
>>> After reading this, the main SGD /boot/grub/menu.lst will make sense to you.
-- The drive hd0: first BIOS boot drive
Useful Fact:
Whenever a USB drive boots the PC, it is seen by BIOS and by GRUB as hd0.
This is true whether the drive is a flash drive or an external USB HD.
To emphasize this: Suppose you boot your PC using a bootable USB drive (flash drive or external USB HD). From the view of the GRUB on that drive, the drive is seen as hd0 -- the first BIOS boot drive. Thus, the other drives on your system are seen as hd1, hd2, hd3, etc. That is called “drive-shifting.” Your normal hd0 drive gets shifted to hd1; your normal hd1 drive gets shifted to hd2; etc.
-- Drive shifting
Your bootable flash drive as seen by Kubuntu, and as seen from the GRUB on the flash drive
Take that same bootable flash drive. Set it on your desk. Boot into your Kubuntu as you normally do (without using the flash drive). Plug the flash drive in, let it be recognized by Kubuntu. Explore your drives using the GRUB geometry command:
sudo grub
grub>geometry (hd0)
grub>geometry (hd1)
grub>geometry (hd2)
etc.
You will see that the flash drive is seen not as hd0 but as something else.
Example: Suppose you have two internal HDs, sda (=hd0) and sdb (=hd1). Then the flash drive will be seen as sdc = hd2 in Kubuntu.
However, as we explained above, if you boot your PC using the bootable flash drive, from the view of the GRUB on that drive, during the session booted by the flash drive, the drive is seen as hd0; your normal hd0 drive is seen as hd1; your normal hd1 drive is seen as hd2.
This is called “Drive shifting (as seen by the GRUB on your bootable flash drive when the flash drive boots the PC.”
--- Super Grub Disk for USB -- usbshift -- special command for dealing with drive shifting
> Your two options: to use SGD for USB or to manually adjust your device names for drive shifting.
> usbshift and configfile
The special SGD for USB includes a special function called usbshift.
You do not have to use it, unless you care to.
When you use it, it has the effect of shifting the drives back to their “normal” order, placing the flash drive at the end of the list (instead of the flash drive being hd0 at the front of the list).
Example
Suppose you have two hard drives sda = hd0 and sdb = hd1 in your PC. When you boot into Kubuntu, your flash drive is seen as sdc = hd2.
Now, boot your PC using your bootable GRUB-SGD-USB flash drive (the one we just built).
How does the GRUB on the flash drive see your drives (during the session booted by the flash drive)?
Answer:
If you do not use the usbshift function, the drives are seen as follows:
hd0 is the flash drive
hd1 is the drive you know as sda = the usual hd0 drive
hd2 is the drive you know as sdb = the usual hd1 drive
That is, the drives get shifted, they get bumped up one device number.
If you use the usbshift function, the drives are seen as follows:
hd0 is the drive you know as sda = the usual hd0 drive
hd1 is the drive you know as sdb = the usual hd1 drive
hd2 is the flash drive, which is how you usually see it when you are in Kubuntu
That is, the drives retain their “normal” device naming you are used to and as seen in Kubuntu.
-- Your two options: to use SGD for USB or to manually adjust your device names for drive shifting
Example
Let's say in your myLinuxMenu.lst (located on the flash drive in the folder /boot/grub), that you wish to boot an OS which is on the third partition of your second internal hard drive. Normally, you'd refer to that as (hd1,2) (e.g., sdb3).
Thus, in the boot stanza for that OS, in myLinuxMenu.lst, you may refer to that operating system in two ways:
title my OS on sdb3
root (hd2,2)
etc etc etc
or:
title my OS on sdb3
usbshift
root (hd1,2)
etc etc etc
=> If you do not use usbshift, you must manually bump the hard drives up one place, from hd1 to hd2.
=> If you use usbshift, it will maintain your “normal” drive order for you (and put the flash drive at the end of your “normal” list of drives as hd2), and you may refer to the partition sdb3 as you normally do; ie., as (hd1,2).
usbshift and configfile
If you use usbshift before calling a configfile statement, the effect of usbshift “transfers through” the configfile to maintain your “normal” drive order.
= = = = = = = = = = = = = = = = = = = =
4 Appendix: Put GParted in with SGD
Alternate way to partition for GParted: Put it in with SGD in partition 1
You do not need a separate partition for GParted.
Adjustments you need to make.
If you wish, you do not need to put GParted in its own partition. You can put it into the first partition with the SGD files. Here's how:
Partitioning
Make the first partition 125 MB.
Other partitions: It's up to you, for another OS (e.g., Puppy Linux) or for personal data.
Label the first partition of the flash drive: Grub-SGD-GParted.
In Kubuntu, open the GParted Live CD (or open the downloaded iso file), copy all the folders and files
you see there into the first partition of the flash drive.
Main SGD menu.lst (/boot/grub/menu.lst -- in partition 1, Grub-SGD-GParted)
Include the following boot stanza for GParted:
title GParted Live--Live Start Debian Live, partition 2
root $(grub_device)
kernel /live/vmlinuz1 boot=live union=aufs
initrd=/live/initrd1.img
That's all the chnages you need to make.
= = = = = = = = = = = = = = = = = = = =
5 REFERENCES
How To GRUB Methods - Toolkit
http://kubuntuforums.net/forums/inde...opic=3081671.0
(Includes: Change default & timeout, make separate “GRUB boot partition,” etc.)
See also the special topics under Reply #1.
GParted: http://gparted.sourceforge.net/
GParted how-to: http://www.howtoforge.com/partitioning_with_gparted
Commands at Konsole: Beginners
http://kubuntuforums.net/forums/inde...opic=3091607.0
In 3 parts, new/improved, complete basic tutorial.
dd Command
http://kubuntuforums.net/forums/inde...opic=3090824.0
Reply#2: dd APPLICATION Making a quick, free backup of your Kubuntu OS
Tells you how to clone your flash drive--see Reply #1 Applications.
Build a LIVE Kubuntu Flash Drive, How-To
http://kubuntuforums.net/forums/inde...089474.new#new
To Remove U3 from flash drive:
http://www.sandisk.com/Assets/u3/launchpadremoval.exe
http://www.u3.com/uninstall/final.aspx
= = = = = = = = = = = = = = = = = = = = = = = =
First version of this how-to, the original post, written April 11, 2007.
++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++
How To: Make GRUB Thumb Drive (USB Flash Drive, or UFD)
Making a bootable thumb drive with GRUB and your boot menu (menu.lst)
Also, Super Grub Disk. (Optional: GParted; a FAT32 data partition; etc.)
*** To put Linux operating systems on your UFD, scroll down. In particular, see “Simplifying your menu.lst and all the rest of it,” Reply #8, and Puppy follows that in Reply #9. You might wish to read Reply #8 now, before continuing. ***
*** UPDATE: See Reply #10, October 23, 2007, for Update and improvements--better tutorial tips--Super GRUB Disk, GParted & Puppy on the flash drive. ***
Note: This worked on my system: Intel D915GAVL Desktop Board; two SATA HDs: on sda1 is WinXP; on sdb, there are four Kubuntu OSs, Freespire, MEPIS. You may have to make adjustments specific to your setup (HDs, BIOS, and OSs).
Notation, Abbreviations:
HD=hard drive; OS=operating system; POST=Power On Self Test; SGD=Super Grub Disk; UFD=USB Flash Drive or “thumb drive”
The issue: Usually, my two HDs are seen (by BIOS and GRUB) as hd0 and hd1. However, when you plug in the UFD, the drives get shifted, in my case the UFD becomes hd0, my hd0 becomes hd1, and my hd1 gets bumped to hd2. You can imagine the effect this has on the device references in your boot menu (/boot/grub/menu.lst).
- - - - - - - - - - - - - - - - - - - -
Method #1 The old-fashioned way using map commands.
Conceptually, it’s simple: Format your UFD, copy GRUB files to it, use root & setup to install GRUB to the UFD, and finally, edit the menu.lst using the GRUB map command to account for the hard drive shifting described above. This last step can get complicated and messy. And if you make changes to hardware or software, you might also have to change the menu.lst and map commands.
For this method see the following (and the links):
- - Kubuntu Edgy -> Installation & Boot -> GRUB on Thumb Drive:
http://kubuntuforums.net/forums/index.php?topic=12995.0
- - Herman’s bigpond: http://users.bigpond.net.au/hermanzone/p15.htm
- - At hardwareguys, Software -> Operating Systems -> GRUB on Thumb Drive:
http://forums.hardwareguys.com/ikonb...ST;f=12;t=5353
- - - - - - - - - - - - - - - - - - - -
Method #2: An easier way using Super Grub Disk (SGD) (and its GRUB files). (See References below)
SGD for USB uses an innovative command, usbshift, which fixes the hard drive shifting problem by restoring the original hard drive order (that exists normally without the UFD) and putting the UFD at the end of the list. In my example above, using usbshift, when I plug in the UFD, my two HDs are seen as they normally are, hd0 and hd1, and the UFD goes at the end of this list as hd2. There is no need for the complication of map commands in the menu.lst.
- - - - - Here’s how to put SGD (and its GRUB using usbshift) on your UFD:
Partition and format the UFD (see notes below on Partitioning/Formatting the UFD and GParted):
(My BIOS is set to boot from CD first, in order.) Plug in the UFD. Wait for it to be recognized in Kubuntu (mine came up as: node /dev/sdc, mounted as /media/usbdisk). To format the UFD, I use GParted Live CD. Insert the GParted Live CD, re-boot, make a partition sdc1 and format it as Linux (ext2 or ext3). Remove the UFD, then properly exit GParted, removing the GParted CD when prompted, choosing re-boot.
Boot into Kubuntu. Download the file sgd_0.9588_for_usb.tar.gz (or latest version) to the Desktop, right-click on it, Extract Here, and that gives a folder on your Desktop containing the SGD/GRUB files you need.
(sudo: To do this work, you may need to use sudo. So you could open Konsole and use sudo before your commands; or at Konsole, type sudo konsole to get a terminal as root.)
Insert the UFD. Wait for it to be recognized in Kubuntu. Open Konsole Then (hash mark # indicates a comment):
# Make a directory called boot on your UFD:
mkdir -p /media/usbdisk/boot
# Copy the contents of the extracted sgd_usb_0.9588 to directory boot of the UFD:
cp –r /home/myname/Desktop/sgd_usb_0.9588/boot/grub /media/usbdisk/boot
cp –r /home/myname/Desktop/sgd_usb_0.9588/boot/sgd /media/usbdisk/boot
# Unmount the UFD (note the spelling umount):
umount /media/usbdisk
# Get a grub prompt as root (it may take a couple minutes):
sudo grub
grub>
# Make the sdc file a drive (my UFD is sdc = (hd2) in Kubuntu):
device (hd2) /dev/sdc
# Set up GRUB in the UFD using root-setup commands:
grub> root (hd2,0)
grub> setup (hd2)
grub> quit
$: exit
Now, SGD is set up on your UFD. Re-boot, get into your BIOS setup (on my PC, I press the F2 key), and set your BIOS to boot from USB. On mine, I set it to boot from CD first, then the UFD, then my hd0. (With no CD in the tray), when the UFD is plugged in, the PC boots from it; when the UFD is not plugged in, the PC boots as usual from hd0. Save and Exit BIOS. The PC then re-boots from the UFD into SGD.
- - - - - How to include your own menu.lst in the boot menu on the UFD
Normally, my “main” OS is Kubuntu on sdb3, and the /boot/grub/menu.lst there is the boot menu you see when turning on the PC. (The GRUB from sdb3 is set up in the MBR of the first hard drive (hd0).)
To include this menu.lst in the boot menu of the UFD, do the following (in Konqueror, or Konsole, or copy/paste or drag/drop).
Off to the side, copy onto Desktop your own GRUB menu.lst; rename it myLinuxMenu.lst (or anything) and save it (as plain text or .txt).
The SGD (on the UFD) contains a /boot/grub directory. Copy the file myLinuxMenu.lst into it:
cp /home/myname/Desktop/myLinuxMenu.lst /media/usbdisk/boot/grub
The SGD (on the UFD) also contains a /boot/grub/menu.lst. Open it (as root), and add a boot stanza entry to this menu.lst (I’m placing this in default position zero, but that’s up to you):
# The SGD main /boot/grub/menu.lst for booting both my GRUB menu.lst and SGD on UFD
default 0 # which is the myLinuxMenu.lst entry below
timeout 10
setgrubdevice # This sets the UFD as the grub device
# and you may see other stuff up front, like gfxmenu
# Then put the boot entry for your own menu.lst, such as:
title myLinuxMenu.lst # Call it anything you want
usbshift # this line is necessary
configfile $(grub_device)/boot/grub/myLinuxMenu.lst
(And following this comes all the “title” boot entries that come with SGD, and the main SGD menu. Save, Exit.)
That’s it. Now, when you re-boot with the UFD plugged in, the boot menu you see will show both your regular menu.lst and other entries for SGD.
- - - - - Partitioning/Formatting the UFD and allowing for other things like GParted on UFD
The SGD with myLinuxMenu (above) took less than 2 MB. Using GParted Live CD to partition/format the UFD, you may want to include other things on the UFD, like a FAT32 data partition. GParted also comes in a USB version that you can put on UFD. I did that, by making two partitions:
sdc1 (bootable) for SGD, including myLinuxMenu, and GParted (which took about 40 MB installed)
sdc2 a FAT32 data partition
Note: I formatted sdc1 as FAT16 because I believe (but am not sure) that GParted USB requires that. I don’t know if it’ll go into FAT32.
Note: When GParted partitions sdc1, it starts sdc1 at sector 63, allowing space for the MBR (512 bytes) (plus the next 62 sectors empty, or 15 sectors for GRUB Stage_1.5).
Note: With two partitions sdc1 and sdc2, in Kubuntu, the UFD shows up as 2 icons, /dev/sdc1 mounted as file /media/usbdisk and /dev/sdc2 mounted as file /media/usbdisk-1. (It may be the reverse of this, or something else on your system. I have two SATA HDs which show up as sda = (hd0) and sdb = (hd1), so the UFD shows up as sdc = (hd2).)
- - Here’s the details for (one method of) putting GParted on the UFD:
Do the partitioning/formatting of sdc1 and sdc2 (above).
At the GParted site, download the gparted-liveusb-0.3.1-1.zip. Using ARK in Kubuntu, extract it to a folder on your Desktop. I called the folder GP0311usb. The contents of GP0311usb were 7 files: boot.cat, boot.msg, gparted, initrd.gz, linux, splash.lss, and syslinux.cfg
Put GParted files and SGD in sdc1:
Copy the contents of the folder GP0311usb to sdc1 of the UFD. Do this any way you want, at Konsole or in Konqueror (copy/paste, drag/drop). NOTE: I did not copy the folder itself, but only the 7 files contained in it. For some reason, that's the only way I could get it to work. Otherwise, I'd get a kernel panic when GParted tried to load. I tried using the folder and naming it in the kernel and initrd paths, like initrd $(grub_device)/GP0311/initrd.gz, but it would not go that way.
Proceed exactly as above to put SGD and myLinuxMenu.lst into sdc1 and set up GRUB using root-setup.
Summary so far:
If you open sdc1, at the top level, you see the folder (from SGD) called boot; you also see the (7) GParted files laying there loose at the same level as the boot folder. Inside boot are two folders, grub and sgd. GRUB is setup in the MBR of the UFD to start the bootloading of both SGD and of GParted.
Next step: Modify the SGD boot menu you see when you turn on the PC (the SGD /boot/grub/menu.lst file of sdc1, on the UFD) by adding a “title” boot entry for GParted. Do this edit as root and save your changes. Like the following:
title GParted 0.3.1.1 for USB
root $(grub_device)
kernel /linux noapic root=/dev/ram0 init=/linuxrc ramdisk_size=65000
initrd /initrd.gz
That's it. Now with the UFD plugged in, re-boot. After the POST, up comes the SGD boot menu (/boot/grub/menu.lst), giving you choices of myLinuxMenu, GParted, Super Grub Disk, (and any other stuff you have included as a boot entry). Select one by highlighting it and press Enter.
- - An example test: I used the GParted on this UFD to partition and format another USB thumb drive that was plugged into a second USB slot on the front of the PC case (which came up as sdd).
- - - - - - - - - - - - - - - - - - - -
Some details you may wonder about.
- - - Where do these two lines come from:
kernel $(grub_device)/linux noapic root=/dev/ram0 init=/linuxrc ramdisk_size=65000
initrd $(grub_device)/initrd.gz
Answer: Kind of by trial-and-error copying luck imitating hoping and pattern-matching
One of the GParted files was syslinux.cfg, a plain text configuration file (some GParted also have a isolinux.cfg.) In there I found a kernel reference line. I separated out the initrd= part, and kept the rest for my kernel line, and used the initrd.gz of initrd=initrd.gz for my initrd line. You can google yourself nuts about kernel options, and even learn some things now and then. An expert could write those lines from scratch. But I can't yet.
- - - usbshift command. Remember that you are using a special sgd_usb version of SGD/GRUB. So when you use it manually or otherwise, don't forget the usbshift.
Example:
With the GParted-SGD UFD plugged in, you re-boot and see the boot menu, and you decide to get a grub> prompt by pressing the “c” key. Then you type a command like configfile (hd1,2)/boot/grub/menu.lst (which is my Kubuntu on sdb3). You will probably get an Error 15: File not found or some other error. So, instead, use the following two lines:
grub> usbshift # then press Enter, usbshift ensures that (hd1,2) makes sense in the next line
grub> configfile (hd1,2)/boot/grub/menu.lst # then press Enter
- - - To manage/extract the GParted zip file, I used ARK. In Kubuntu under K-Menu – Utilities – ARK Archiving Tool. Click Help to get ARK Handbook. It manages, extracts the gparted zip file.
- - - UFD may come with software. My Memorex came with U3 which is neat, but to erase it go to www.U3.com/uninstall . (Must be in Windows to run this)
References
How-To GRUB Methods - Toolkit: http://kubuntuforums.net/forums/inde...opic=3081671.0
GRUB: http://www.gnu.org/software/grub/
Major credit to SuperGrubDisk: http://supergrub.forjamari.linex.org/
(At the SGD site, go to Downloads and scroll to the USB section. Today, the latest version is 0.9588: sgd_0.9588_for_usb.tar.gz)
bigpond at http://users.bigpond.net.au/hermanzone/p15.htm
GParted Live CD at: http://gparted.sourceforge.net/livecd.php
Comment