Monday, January 13, 2014

Booting Raspberry Pi from USB Flash Drive

      Loading OS over SD card is ok but it is not that faster and also have limited read/write cycles so one might look for USB Flash drive to load the OS and is also a cheaper option.It makes the PI little faster.So here i am posting how to boot your Pi from USB drive.

      First write the image file to the USB Drive as int this post(installing-raspbian-over-raspberry-pi).This will write the os to the Drive.Now remove the SD card from the Pi and insert it to the PC , it will show 2 drives open the boot and open the cmdline.txt file


 This file will be containing booth path as shown below image.

 

 To boot from USB Flash Drive we have to  change the path to dev/sda2.


    Now plug the Drive and SD card to the Raspberry PI and if everything went write it will boot from Flash Now follow the steps listed in this post (installing-raspbian-over-raspberry-pi). And you are ready.You can see while clicking over Expand filesystem it showing not able to expand.Don't worry you need to expand the FS from the command prompt , as shown below.. 

 
     sudo fdisk /dev/sda 

     Then press p and enter to see the partitions. There should only be 2.Make a note of the start position for the partition sda2. Press d and then when prompted type 2 and then hit enter. This will delete the partition.Now we’re going to create a new partition, and make it large enough for the OS to occupy the full space available on the USB Flash Drive. To do this type n to create a new partition, when prompted to give the partition type, press p for primary. Then it will as for a partition number, press 2 and hit enter.You will be asked for a first sector, set this as the start of partition 2 as noted earlier. In my case this as 122880 but this is likely to be different for you.After this it will ask for an end position, hit enter to use the default which is end of disk. Now type w to commit the changes. You will see a message about the Kernel just ignore this. Type the following to reboot:

 
    sudo reboot 
   Once your Raspberry Pi has rebooted, we need to resize the partition. To do this type the following

   
  sudo resize2fs /dev/sda2
 
Once it’s done reboot again. Then type:

   
  df -h 
 
     This will show the partitions and the space, you’ll see the full USB Flash Disk has all the space available now. That’s it, all done!

No comments:

Post a Comment