Install Ubuntu through a USB flash drive

Source: Internet
Author: User
Previously, I introduced How to Install Vista through a USB flash drive. This article will introduce how to install the UbuntuLinux system on a USB flash drive. although Ubuntu is used in this article, it is also feasible to install other LinuxliveCD releases based on this method. running Linux on a USB flash disk enriches the liveCD experience and allows you to install Vista through a USB flash disk before running Linux on any machine, this article describes how to install Ubuntu Linux on a USB flash drive. although Ubuntu is used in this article, it is feasible to install other Linux live CD distributions using this method.

Running Linux on a USB flash drive enriches the live CD experience, allowing you to run Linux on any machine, which is much easier than carrying a CD with you.
1. preparations

Before you start, you must at least make the following preparations:

* A Ubuntu live CD or. iso image file
* At least 1 gb u disk
* Running Linux OS

2. set the USB flash drive

First, insert the USB flash drive to check whether the device is recognized. To locate the device, run the following command:

$ Sudo fdisk-l

In my system, the drive letter of this device is/dev/sdb. This article uses/dev/sdb as an example to explain how to change the drive letter according to the actual situation of your system (which may be sda, sdc ...).

After the system discovers the U disk, it will create a partition.

Note: incorrect drive letters may damage your hard drive partition, so please input them with caution.

Create a partition

Detach an attached U disk:

$ Sudo umount/dev/sdb1

Then use fdisk, a partition editing tool:

Sudo fdisk/dev/sdb

After deleting the partition of the U disk, we create two new partitions: one fat file system partition with a capacity of MB, which is used to save the files in the live CD image and the other partition.

Then, the input format is "d x", and x is the drive letter of the partition. the input is as follows:

* N create a new partition
* P is set as the primary partition.
* 1 is set to the first primary partition.
* Accept the default option or input "1" to start from the first cylindrical disk
* + 750 M set the space to 750 MB
* A sets the partition as an active partition that can be started.
* 1 select this partition
* T change the partition format
* 6 set to FAT16 partition

When the first partition is set, perform the second one:

* N to create yet again a new partition
* N create a partition again
* P is set as the primary partition.
* 2 set as the second partition
* Press enter to accept the default selection
* Accept the default selection and use up all capacity
* Finally, enter w to enable the USB flash drive to complete the above changes.

Format the partition.

Format partitions

The first partition will be in the format of FAT16 file system, and the U disk is set to self-start.

$ Sudo mkfs. vfat-F 16-n liveusb/dev/sdb1

The second partition will be formatted as the ext2 file system, the block length (blocksize) is 4096 bytes, and the volume is casper-rw (otherwise the target will not be successfully completed !)

$ Sudo mkfs. ext2-B 4096-L casper-rw/dev/sdb2

Now, you need to copy the live CD image to the USB drive.

3. install Ubuntu from a USB flash drive

Mount the Ubuntu live CD image

First, you need to mount the ubuntu image. There are two ways to use a ". iso" file or a CD.

Attach from CD

If you insert a Ubuntu or other release CD into your computer, it will be automatically mounted. Otherwise, mount the disk as follows.

$ Sudo mount/media/cdrom

Mount from. iso image file

Create a temporary folder, take/tmp/ubuntu-livecd as an example, and mount it:

$ Mkdir/tmp/ubuntu-livecd
$ Sudo mount-o loop/path/to/feisty-desktop-i386.iso/tmp/ubuntu-livecd

Partitions attached to the U disk

Insert the USB flash drive again. The two partitions are/media/liveusb and/media/casper-rw. If this problem does not occur, you need to manually mount it:

$ Mkdir/tmp/liveusb
$ Sudo mount/dev/sdb1/tmp/liveusb

All required partitions have been mounted, and the copied file is now.

Copy the file to the USB drive.

Find the path of the CD image (which may be/tmp/ubuntu-livecd, or/media/cdrom), and then copy it to the first partition of the U disk as the root partition:

Examples, README. diskdefines, ubuntu. ico, casper/vmlinuz, casper/initrd.gz, and install/mt86plus.

$ Cd/tmp/ubutu-livecd
$ Sudo cp-rf casper disctree dists install pics pool preseed. disk isolinux/* md5sum.txt README. diskdefines ubuntu. ico casper/vmlinuz casper/initrd.gz install/mt86plus/media/liveusb/

A symbolic link may not be created. you can ignore it.

Next we will rename isolinux. cfg in the first partition of the U disk to syslinux. cfg:

$ Cd/tmp/liveusb
$ Sudo mv isolinux. cfg syslinux. cfg

Change/tmp/liveusb according to your settings

Edit the syslinux. cfg file as follows:

DEFAULT persistent
GFXBOOT bootlogo
GFXBOOT-BACKGROUND 0xB6875A
APPEND file = preseed/ubuntu. seed boot = casper initrdw.initrd.gz ramdisk_size = 1048576 root =/dev/ram rw quiet splash --
LABEL persistent
Menu label ^ Start Ubuntu in persistent mode
Kernel vmlinuz
Append file = preseed/ubuntu. seed boot = casper persistent initrd1_initrd.gz ramdisk_size = 1048576 root =/dev/ram rw quiet splash --
LABEL live
Menu label ^ Start or install Ubuntu
Kernel vmlinuz
Append file = preseed/ubuntu. seed boot = casper initrdw.initrd.gz ramdisk_size = 1048576 root =/dev/ram rw quiet splash --
LABEL xforcevesa
Menu label Start Ubuntu in safe ^ graphics mode
Kernel vmlinuz
Append file = preseed/ubuntu. seed boot = casper xforcevesa initrdw.initrd.gz ramdisk_size = 1048576 root =/dev/ram rw quiet splash --
LABEL check
Menu label ^ Check CD for defects
Kernel vmlinuz
Append boot = casper integrity-check initrdw.initrd.gz ramdisk_size = 1048576 root =/dev/ram rw quiet splash --
LABEL memtest
Menu label ^ Memory test
Kernel mt86plus
Append-
LABEL hd
Menu label ^ Boot from first hard disk
Localboot 0x80
Append-
DISPLAY isolinux.txt
TIMEOUT 300
PROMPT 1
F1 f1.txt
F2 f2.txt
F3 f3.txt
F4 f4.txt
F5 f5.txt
F6 f6.txt
F7 f7.txt
F8 f8.txt
F9 f9.txt
F0 f10.txt

Set the U disk to boot

To complete this step, you need to install syslinux:

$ Sudo apt-get install syslinux

Finally, uninstall/dev/sdb1 and make it bootable:

$ Cd
$ Sudo umount/tmp/liveusb
$ Sudo syslinux-f/dev/sdb1

Restart and set the BIOS to boot from the U disk to enjoy Ubuntu in the U disk!

4. troubleshooting

If the boot fails from the U disk, the primary boot record (MBR) may be damaged. You can use lilo to fix this problem:

The MBR on $ lilo-M/dev/sdb will be repaired.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.