lundi 5 août 2013

Bootable linux flash drive


Hello, Everyone :)

In this tutorial post, we are going to show you how to create a bootable Linux flash drive, for your emergency system installations :)

In this tutorial, I have chosen SliTaz which is a light-weight distribution.
it requires approximately 100 MB of hard disk space.

Slitaz is a French standalone distribution built directly from the kernel due to its lightweight and it is not based on other distribution like Redhat, Fedora, Ubuntu, ...

For the sake of this tutorial, I have chosen the Oracle virtual box to do the installation.





I- prepare the flash disk

First things first, prepare the Flash disk.
Let start by creating a folder USB and then create a new primary partition in the flash drive :


root@RH # mkdir usb

root@RH # fdisk /dev/sdd

   n (new)

   p (primary)

   1 (n° of partition)

   1 (starting @)

   12 (ending @)

   w (writing the modifications )


Once done let's format the flash drive with ext3 and then mount the drive in the USB folder :

root@RH # mkfs -t ext3 /dev/sdd1

root@RH # mount /dev/sdd1 usb



II-install the grub

Grub is a piece of program that is called BootLoader. This program allows the user to boot one or multiple operating systems in the hard drive, for our example, Grub is going to allow us to boot the Slitaz distribution from the USB drive.
The master boot record (the MBR for short) located in the first sector of the drive, will call the BootLoader to launch the OS.

To install the Grub it's quite simple, you just need to use the command grub-install and it will do the trick like this :


root@RH # grub-install roor-directory=/root/exo/usb /dev/sdd



III-copy the files from the disk into the flash drive

After the grub installation is done, we proceed to copy the OS files to the USB drive.

root@RH# cp -rf disk/* usb/


Here I made some optional modifications, I moved the kernel file "vmlinuz-2.6.37-slitaz" and some additional modules files with the pattern "rootfs*"  into the parent directory.


root@RH# cd usb/boot/

root@RH# mv rootfs* ../

root@RH# mv vmlinuz-2.6.37-slitaz ../linux





IV-configure the grub.conf file

Now it's time to set the configuration file grub.conf.


root@RH# cd grub

root@RH# cp /boot/grub/grub.conf .

root@RH# ln -s grub.conf menu.lst

root@RH# vi grub.conf



   default=0

   timeout=300

   color blue/black

   title Linux_SliTaz

   root (hd3,0)

   kernel /linux rw root=/dev/null

   initrd /rootfs1.gz

   initrd /rootfs2.gz

   initrd /rootfs3.gz

   initrd /rootfs4.gz



   :wq



V- reboot the VM with the flash drive connected

root@RH# init 6

Before login the grub start and shows us the user interface to choose which system to load.




Once you get to the login prompt , you can use the user root with the password root to login.
And now you can enjoy configuring your brand new system linux system as you pleased :)

I hope this tutorial allowed you guys to create a bootable Linux flash drive with Slitaz.

Thank you for reading! :)

Aucun commentaire:

Enregistrer un commentaire