usb:install_ubuntu_linux_on_a_usb_pendrive
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
usb:install_ubuntu_linux_on_a_usb_pendrive [2019/12/04 21:59] โ removed peter | usb:install_ubuntu_linux_on_a_usb_pendrive [2020/07/19 13:57] (current) โ old revision restored (2016/07/16 22:12) 164.68.117.152 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== USB - Install Ubuntu Linux on a USB pendrive ====== | ||
+ | |||
+ | This tutorial will show how-to install Ubuntu on a usb stick. Even though this tutorial uses Ubuntu as its base distribution, | ||
+ | |||
+ | Being able to run Linux out of a usb bar is a great way to enjoy the live CD experience (being able to use Linux on any computer you might get by) and the big advantage of being easier to carry around than a CD. | ||
+ | |||
+ | 1. Requirements | ||
+ | |||
+ | In order to reproduce this tutorial, you will need a few items such as: | ||
+ | |||
+ | * a ubuntu liveCD | ||
+ | * a usb bar of at least 1G | ||
+ | * a running Linux operating system | ||
+ | |||
+ | Now that you have all this, it is time to prepare you USB bar do host the Ubuntu liveCD files. | ||
+ | |||
+ | 2. Setting up the USB disk | ||
+ | |||
+ | 2.1. Finding the device | ||
+ | |||
+ | In the first place, you need to plug your usb drive and check under which device it is associated. To find out the device, run: | ||
+ | |||
+ | <code bash> | ||
+ | sudo fdisk -l | ||
+ | </ | ||
+ | |||
+ | On my system, the device appears as being /dev/sdb, I will therefore use /dev/sdb as a reference for this tutorial, please replace it accordingly to your system (might be sda, sdc ...). | ||
+ | |||
+ | Once you found your device, you are going to create the partitions. | ||
+ | |||
+ | Using the wrong device name might destroy your system partition, please double check | ||
+ | |||
+ | |||
+ | 2.2. Making the partitions | ||
+ | |||
+ | Make sure every of your already mounted partition are unmounted: | ||
+ | |||
+ | <code bash> | ||
+ | sudo umount /dev/sdb1 | ||
+ | </ | ||
+ | |||
+ | and then launch fdisk, a tool to edit partition under linux: | ||
+ | |||
+ | <code bash> | ||
+ | sudo fdisk /dev/sdb | ||
+ | </ | ||
+ | |||
+ | We are going delete all the partition and then create 2 new partition: one fat partition of 750M which will host the files from the live CD iso, and the rest on another partition. | ||
+ | |||
+ | At fdisk prompt type d x where x is the partition number (you can simply type d if you only have one partition), then: | ||
+ | |||
+ | n to create a new partition | ||
+ | p to make it primary | ||
+ | 1 so it is the first primary partition | ||
+ | Accept the default or type 1 to start from the first cylinder | ||
+ | +750M to make it 750 Meg big | ||
+ | a to toggle the partition active for boot | ||
+ | 1 to choose the 1 partition | ||
+ | t to change the partition type | ||
+ | 6 to set it to FAT16 | ||
+ | |||
+ | Now we have out first partition set up, let's create the second one: | ||
+ | |||
+ | n to create yet again a new partition | ||
+ | p to make it primary | ||
+ | 2 to be the second partition | ||
+ | Accept the default by typing Enter | ||
+ | Accept the default to make your partition as big as possible | ||
+ | Finally, type w to write the change to your usb pendrive | ||
+ | |||
+ | Partitions are now created, let's format them. | ||
+ | |||
+ | |||
+ | 2.3. Formatting the partitions | ||
+ | |||
+ | The first partition is going to be formated as a FAT filesystem of size 16 and we are going to attribute it the label " | ||
+ | |||
+ | <code bash> | ||
+ | sudo mkfs.vfat -F 16 -n liveusb /dev/sdb1 | ||
+ | </ | ||
+ | |||
+ | The second partition is going to be of type ext2 with a blocksize of 4096 bytes and the label casper-rw. | ||
+ | |||
+ | <code bash> | ||
+ | sudo mkfs.ext2 -b 4096 -L casper-rw /dev/sdb2 | ||
+ | </ | ||
+ | |||
+ | |||
+ | At this stage, our USB pendrive is ready to host the liveCD image. | ||
+ | |||
+ | |||
+ | 3. Installing Ubuntu on the USB stick | ||
+ | |||
+ | 3.1. Mounting Ubuntu liveCd image | ||
+ | |||
+ | In the first place we need to mount our Ubuntu iso. Depending if you have the .iso file or the CD, there is 2 different ways of mounting it. | ||
+ | |||
+ | 3.1.1. Mounting from the CD | ||
+ | |||
+ | People using Ubuntu or any other user-friendly distro, might just have to insert the cd and it will be mounted automatically. | ||
+ | |||
+ | <code bash> | ||
+ | sudo mount / | ||
+ | </ | ||
+ | |||
+ | should mount it. | ||
+ | |||
+ | |||
+ | 3.1.2. Mounting from an .iso image file | ||
+ | |||
+ | We will need to create a temporary directory, let say / | ||
+ | |||
+ | <code bash> | ||
+ | mkdir / | ||
+ | sudo mount -o loop / | ||
+ | </ | ||
+ | |||
+ | Once the cd image is ready, it is time to mount the newly created usb bar partitions: | ||
+ | |||
+ | 3.2. Mounting the usb bar partitions | ||
+ | |||
+ | Same here, you might be able to get both your partition by simply replugging the usb pendrive, partition might appears as: / | ||
+ | |||
+ | <code bash> | ||
+ | mkdir / | ||
+ | sudo mount /dev/sdb1 / | ||
+ | </ | ||
+ | |||
+ | All the partitions we need are now mounted, let's copy the files. | ||
+ | |||
+ | |||
+ | 3.3. Copying the files to the usb bar | ||
+ | |||
+ | Let positionned yourself on the CD image directory (in my case: / | ||
+ | |||
+ | * the directories: | ||
+ | * The content of directory ' | ||
+ | * and files ' | ||
+ | * as well as files: ' | ||
+ | |||
+ | <code bash> | ||
+ | cd / | ||
+ | sudo cp -rf casper disctree dists install pics pool preseed .disk isolinux/* md5sum.txt README.diskdefines ubuntu.ico casper/ | ||
+ | </ | ||
+ | |||
+ | It might complain about symbolic links not being able to create, you can ignore this. | ||
+ | |||
+ | Now let's go to the first partition of your usb disk and rename isolinux.cfg to syslinux.cfg: | ||
+ | |||
+ | <code bash> | ||
+ | cd / | ||
+ | sudo mv isolinux.cfg syslinux.cfg | ||
+ | </ | ||
+ | |||
+ | change / | ||
+ | |||
+ | Edit syslinux.cfg so it looks like: | ||
+ | |||
+ | <file bash syslinux.cfg> | ||
+ | DEFAULT persistent | ||
+ | GFXBOOT bootlogo | ||
+ | GFXBOOT-BACKGROUND 0xB6875A | ||
+ | APPEND | ||
+ | LABEL persistent | ||
+ | menu label ^Start Ubuntu in persistent mode | ||
+ | kernel vmlinuz | ||
+ | append | ||
+ | LABEL live | ||
+ | menu label ^Start or install Ubuntu | ||
+ | kernel vmlinuz | ||
+ | append | ||
+ | LABEL xforcevesa | ||
+ | menu label Start Ubuntu in safe ^graphics mode | ||
+ | kernel vmlinuz | ||
+ | append | ||
+ | LABEL check | ||
+ | menu label ^Check CD for defects | ||
+ | kernel vmlinuz | ||
+ | append | ||
+ | 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 | ||
+ | </ | ||
+ | |||
+ | Woof, finally we have our usb disk almost usuable. | ||
+ | |||
+ | |||
+ | 3.4. Making the usb bar bootable. | ||
+ | |||
+ | in order to make our usb disk bootable, we need to install syslinux and mtools: | ||
+ | |||
+ | <code bash> | ||
+ | sudo apt-get install syslinux mtools | ||
+ | </ | ||
+ | |||
+ | And finally unmount /dev/sdb1 and make it bootable: | ||
+ | |||
+ | <code bash> | ||
+ | cd | ||
+ | sudo umount / | ||
+ | sudo syslinux -f /dev/sdb1 | ||
+ | </ | ||
+ | |||
+ | Here we are ๐ , reboot, set your BIOS to boot from the usb bar and enjoy Ubuntu linux from a pendrive. | ||
+ | |||
+ | |||
+ | 4. Troubleshooting | ||
+ | |||
+ | If you are having trouble booting on the usb bar, this might be due to your MBR being corrupted. In order to fix it up, you can use lilo (I installed lilo on my box only for third purpose). | ||
+ | |||
+ | <code bash> | ||
+ | $ lilo -M /dev/sdb | ||
+ | </ | ||
+ | |||
+ | will fix the MBR on device /dev/sdb | ||
+ | |||
usb/install_ubuntu_linux_on_a_usb_pendrive.1575496799.txt.gz ยท Last modified: 2020/07/15 09:30 (external edit)