Important information This tutorial is out-dated and has been updated here: In this tutorial, I’m going to talk you through running Raspbian from a USB connected drive instead of from an SD card. If you run Raspbian from a USB Flash drive, you will enjoy performance boosts, speed and reliability improvements just to name a few benefits. SD Cards have a limited read/write cycle, and when hosting a site with a MySQL database from a SD card, it won’t take long before you start getting corruptions and failures. USB Flash drives provide a cheap and reliable alternative. I’ve tested several USB Flash drives, and found Sandisk and Corsair to be the best for speed and reliability. This site is run off a 16GB Corsair Voyager 3 USB Flash drive.
Assumptions before we begin I’m going to assume that you know your way around Terminal, and are using a Mac to perform these steps. You will still need an SD card to store the boot instructions to tell the Raspberry Pi to launch the OS from the USB; the Raspberry Pi’s can’t (yet) boot directly from a USB storage device. Step 1 – Download Raspbian from Raspberry Pi You will need the standard Raspbian OS image, you can download this from the official. Once you’ve downloaded it, unzip it. It’s around 400mb in size, so should only take a couple of minutes over a broadband connection.
Kemudian klik Debian lalu Mulai ( yg dilingkar ) 7. Akan muncul kotak dialog seperti ini, masukan CD Debian-nya yang format ISO, kalau saya menggunakan Debian V.5 Next cara klik lambang Folder, terus cari CD-nya setelah itu Klik Next, lalu klik Finish. Nanti saya akan menggunakan menu ini. Graphical Install: Menu instalan namun secara GUI ( Graphical User Interface ) atau berbasis warna dan gambar layaknya Windows. CARA INSTALL DEBIAN 7.6 untuk server. Instalasi OS untuk server. Kali ini saya mau share cara instalasi OS Debian untuk kebutuhan server. Langkah-langkah: 1.
Step 2 – Install the Raspbian OS to your USB Flash drive Plug in your USB stick and launch Terminal. The first thing we’re going to do is get the device identifier for your USB Flash drive. To do this run the following command: diskutil list The list of attached disks will show up with their identifiers.
Important – make a note of the correct identifier, you can do some serious damage by choosing the wrong one! In the screen shot above, I can see that /dev/disk2 is the correct identifier for my Sandisk USB Flash Drive. Yours may be different so change to suit your configuration. Next we’re going to unmount the USB Flash Drive. To do this enter the following command: diskutil unmountDisk /dev/disk2 Yet again, be really careful to change disk2 to whatever your computer identifies the USB Flash Drive as. You will get a message saying “Unmount of all volumes on disk2 was successful”.
Now we can begin the copy. For ease, I’ve changed the directory in Terminal to where the Raspbian image is located, which in this case is my downloads folder.
If you’ve downloaded and unzipped the disk image to your downloads folder, running this command should take you there: cd /Downloads/ Now run this command to begin the copy: sudo dd bs=1m if=2013-02-09-wheezy-raspbian.img of=/dev/disk2 As with before, make sure you change disk2 to whatever your computer identifies as being the USB Flash Drive, and change 2013-02-09-wheezy-raspbian.img to whatever your image file is called. The blocks will now begin moving to your USB Flash Drive from the Raspbian OS image. This takes anything from 5 to 20 mins depending on the speed of your USB Flash Drive. Go stick the kettle on and have a brew! Eventually, you will see something similar to the above, and it probably took a while too. The next step is to configure your SD Card to give the correct boot instruction to start the OS from the USB Flash Drive Step 3 – Configure your SD card Using Disk Utility, format your SD Card using FAT32. It’s dead easy, choose your SD Card from the devices listed on the right, then click on ‘Erase’, choose FAT32 in the Formats list and click on ‘Erase’.
Once you’ve done this, you’ll notice on your Desktop, there are two mounted volumes; one is your USB Flash Drive, the other is your SD Card. Open up the USB Flash Drive volume and copy all the files from that onto your SD card. This copies the all-important files and instructions to tell your Raspberry Pi to boot from the USB Flash Drive. We’re almost done at this point, only one more step to go. Step 4 – Change the boot path on your SD card Once you’ve completed step 3, you need to change the default boot path to tell the Raspberry Pi to boot from your USB drive. Open a new Finder window and go to your SD card. Open up the file called cmdline.txt in TextEdit or similar and amend the line which reads: root=/dev/mmcblk0p2 To this: root=/dev/sda2 This will instruct your Raspberry Pi to boot from the USB Flash Drive instead of from the SD card.
Save the cmdline.txt file and close the Finder window. We’re almost done! Step 4 – Boot from your USB Flash Drive on your Raspberry Pi Now unmount both your USB Flash Drive and your SD card and pop them both into your Raspberry Pi and switch it on. If all goes well, it should boot from your USB Flash Drive which you’ll find substantially quicker than your SD Card. Step 5 – Expand the Raspbian partition on your USB Flash drive to fill it Finally, we’re just going to do a little housekeeping to utilise all the available space on your USB Flash drive as the method using raspi-config doesn’t work on USB Flash drives. This isn’t essential, but if you have the extra space on a USB Flash Drive, why not use it all? From your Raspberry Pi, type the following command to start FDisk: sudo fdisk /dev/sda Then press p and enter to see the partitions.
There should only be 2. What we’re going to do now is delete the Linux partition, but before we do this, we make a note of the start position for the linux 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 12280 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 using some table yaddah yaddah, 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 command: sudo resize2fs /dev/sda2 Be patient, this will take some time. 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. Run Raspbian from a USB Flash Drive That’s it! You’re now up and running from a USB Flash Drive.
This is a quick, cost effective way of improving the performance of your Raspberry Pi. Hopefully in later models, you’ll be able to do this natively without a boot SD card. Any questions or thoughts, please comment below.
I have used the wireless media server — not connected to the Internet — at various events and most recently with the Pi, to serve a website as a program guide to theatre attendees at an arts festival. That was using Lighttpd, but currently I use the somewhat simpler-to-configure Pancake webserver for Pi from pancakehttp.net.
Also hostapd which enables use of a USB Wi-Fi dongle connected to Pi. (The dongle must be capable of acting as an access point — not all such devices are capable). Attendees tell me they prefer this over printed materials. It has amazed me how quickly they discover the site on their phones and tablets, even before announcements about it. All connections are redirected to the internal webserver.
Going forward I am working on a control panel that enables the admin to change the Wi-Fi SSID, transmission channel, see a list of connected users and edit the website that is broadcast. And — shut down the Pi properly without SSH or access to the desktop GUI. Such servers could be used in situations where content and interactive apps should be broadcast in the immediate area, and Wi-Fi Internet connectivity is not provided, often for cost reasons. Other projects such as LibraryBox, PirateBox, Subnod.es, Byzantium Linux and OccupyHere are working on various pieces of this puzzle from other approaches.
Thank You to the Dingleberry editor for focus on servers. First off, I would like to say that this site was the final push that got me to buy and set up a Pi to replace an older PC I was using as a personal Linux server.
Bought it, configured it, and love it. Second off, thanks for this guide. I didn’t have a Mac but the steps are similar enough that I was able to use Ubuntu to do it.
So here’s my current challenge. I have two USB disks plugged into my Pi: a USB flash drive from which the OS is run (per this guide) and a USB hard drive to store mass quantities of data. I find that it is impossible to say consistently which device will be sda and sdb when the Pi boots. I would love to be able to say “root=UUID” in cmdline.txt however Raspbian’s boot loader doesn’t work that way. Has anybody else encountered this challenge, or come up with a good solution? My Raspberry Pi (which I’ve only had for about a month) has an external USB hard disk – but it never occurred to me that I could make it boot from a USB device. I’d question the logic based on SD cards’ limited write cycle life time – that’s quite true, but I think a USB flash drive uses exactly the same technology and therefore also has limited write cycle lifetime.
Are you sure you’re any better off from the reliability point of view? I’ve mounted my external HD on /home, also put a small swap partition on it, and intend to put any frequently written directories on it, so the SD card won’t be written to much – mostly log files.
If it breaks, I’ll consider putting the whole system on HD, especially after reading this article. The HD data transfer is nearly twice as fast as the SD card, which makes such a change quite tempting. I agree with Anahata on this as aren’t they they same memory and tech on both the SD and USB stick? My thoughts however were on this matter as I have 1 coming and another being delivered a week after that. Would I be able to remove to SD card once the USB stick has booted and is running? (This to start the process on a second pi ) I think this is a good question as in theory you could run multiple pi’s with only the one sd card for initial start-ups.
I also wonder why the pi isn’t looking for a start-up disk on start up but that’s another already asked discussion I’m sure. Thanks for the tasty condiments to go with my pi. You’re both absolutely right, they are based on the same technology, except are intended to be used differently. USB Flash drives tend to be more reliable inherently as they are intended for regular data movement in a way that’s more irregular in size than SD. With SD, generally it tends to be the reading that lets them down, they’re designed for fast write due to their use predominantly in digital cameras.
In my own tests on the Raspberry Pi, USB flash drives are considerably quicker. I tried several high-end SD cards, and found nothing to be a patch on the Corsair Voyager USB flash, and it didn’t take long for MySQL corruptions to occur on the SD cards either. As for not being able to directly boot from USB instead of having to rely on SD for the instruction, I haven’t a clue why this is, but I see it as a slight oversight of the Pi foundation, surely more people have a spare USB flash floating around than a SD?
How would you go about removing the unnecessary FAT32 /dev/sda1 and expand /dev/sda2 to take over the space? I know it’s only, what, 58MB? Out of 32GB in my new USB flash drive But it’s 58MB that could be in my main filesystem and instead is cluttering the partition table. I suppose we could install to a 2GB SD card temporarily, create a new blank partition on the USB drive, and dd it over. But that means starting over – I’m using a 128MB card for boot currently. For those who get confused about how to run the commands when the initial text-based setup menu is displayed: Alt-F2 and use the default pi login. Alt-F1 to go back to the menu.
But I hope I help first with my shortcut if indeed it is. My error was tiny but my questions after are huge thats why I’d like a little help. I hope this shortcut is as good as I think.
I had another sd card of wheezy so let that be a warning for fellow new guys if you try this easy approach. I opened the cmdline.txt in leaf pad in a root folder from the wheezy desktop and changed it to /dev/sda1 (by mistake the first try! It needs to be 2 as 1 is the boot ) and saved it.
I then put my other working sd card in a reader and it worked. I can edit that cmdline.txt file to go back to the original sd card later if I edit it. I did try a raspbmc install after I dd ‘d the image to a usb flash drive but had a fatal error after user pi set up. My thoughts are to try again with a dd’d sd to usb drive. Any thoughts though? Can I have a drive partitioned say with multiple OS ‘s?
I did notice python not starting up on the raspbmc sd card I have through the a usb reader but it did run well as did wheezy. Any thoughts on all this guys? I hope my questioning why not try this is a shortcut but is it problematic?
@fboteroh, The presence of an SD card is required in order for the Pi to boot. This is just an inherent nature of the Pi’s design. As long as the SD contains the appropriate boot configurations, Raspbian can then be loaded off of anything, such as a USB drive as in this tutorial.
@Megan M, I was able to get by just fine using an 8GB USB drive. With all said and done I have the OS occupying only 3GB of that. Because I use a USB hard drive to store the bulk of the data that my Pi serves (same as what you are describing), 8GB is plenty of breathing room for the OS. Thanks for the tutorial- I used an external 2,5″ HDD enclosure and a powered USB hub. With a 64GB Hard disk thePi works really nice, boot time is much shorter than from the SD card. I now use a 512MB SD card for booting (It could be even much smaller but this was the smallest one on the scrap pile).
Under Linux if you have a working install of your raspi you can simply do the following: Take an USB external HDD, create 1 partition on it, mkfs.ext4 this partition and then copy everything from the Data partition of your SD card onto the USB harddisk. Change the cmdline.txt on the SD and the /etc/fstab on the disk and it simply works ?. I have followed the instructions carefully, but neither the SD card nor USB flash drive (Verbatim Store-n-Go, 16gb) would boot (only the red pwr light ever shows up). When I restore cmdline.txt to original, the SD card boots fine and the USB drive appears fine also, although not mounted (of course). I do notice, however, that when the USB dive is plugged into my Win7 laptop, the file system shows as EXT3, not EXT4 as in the fstab config file. Could this be a problem? I have tried with various SD cards and USB flash drives and instructions from other websites, but all with same non-results.
Any clues or things to look at such as log files, config files, etc.? I had no success for the first half dozen attempts. The way I finally made it work was to format my flash drive using gparted under Ubuntu. Delete all existing partitions from your usb stick, and then format the entire thing as one partition to ext4. Then follow the guide on this website verbatim – again using Ubuntu Linux – to ‘burn’ the.iso image of Raspbian to the usb stick. Most of the commands in the bash terminal in Ubuntu are very similar to the ones for Macs (or at least I gather from this article, I’ve never owned a Mac).
Once the image is on the usb stick, the rest proceeded as advertised in this guide. Just change the cmdline.txt file per the instructions and away it goes. This has worked perfectly for me, thank you for a great tutorial!
However, if I add a second USB flash drive (to use for general storage) the pi won’t boot. I assumed this was because it was allocating “sda” to the second USB drive and not the one I wanted to boot from. So to try and get around this I edited /etc/fstab and added two lines – one with the UUID of the partition on the flash drive I wanted to use as my root filesystem and the second line with the UUID of the general storage flash drive which is mapped to a mount point in my home directory. This still hasn’t worked unfortunately ? Is there a solution to this?
Thanks in advance! Just a note, when you change cmdline.txt to point to usb drive and then reboot, ths rpi is actually still “booting” from the sdcard. The difference now is that once the rpi is booted, it now uses the”root” partition on the usb drive. Essentially, all your programs are in the root partition, which is where most disk reads and writes occur, saving your sdcard from wear and tear and potentially speeding things up if you usb drive is faster than your sdcard. The take away here is that the rpi MUST always, always, “boot” from the sdcard by design so, you cant go and erase the boot partition of your sdcard.
If you do, your rpi will fail to boot! You can, however, erase and reformat the sdcards root partition, but i don’t recomend it in case you ever want to return to your old configuration. One other thing, remember to change cmdline.txt on the sdcard but the fstab should be modified on the usb drive! I have done everything up to this point: Step 4 – Change the boot path on your SD card Once you’ve completed step 3, you need to change the default boot path to tell the Raspberry Pi to boot from your USB drive.
Open a new Finder window and go to your SD card. Open up the file called cmdline.txt in TextEdit or similar and amend the line which reads: But i can’t see or find the file called cmdline.txt on the SD card or am i creating the file? ScanDisk class 10 16Gb 2016-05-27-raspbian-jessie.img (Full Disk Version) My OS is El-Captain My target drive is Seagate 1TB SSHD (Hybrid Drive) Any suggestion from anyone? I think it also is smart to change /etc/fstab to reflect that the system is now located on dev/sda2 From: proc /proc proc defaults 0 0 /dev/mmcblk0p1 /boot vfat defaults 0 2 /dev/mmcblk0p2 / ext4 defaults,noatime 0 1 # a swapfile is not a swap partition, so no using swapon off from here on, use $ To: proc /proc proc defaults 0 0 /dev/mmcblk0p1 /boot vfat defaults 0 2 /dev/sda2 / ext4 defaults,noatime 0 1 # a swapfile is not a swap partition, so no using swapon off from here on, use $ It might be important to speed up the USB drive and avoid wearing it out. Thx for a clear and complete tutoral!
Great work Ste!! But as usual I have some minor questions. If followed the tutorial with the jessie-version OS. I believe all is working great since the rasp1 is popping up in my network. I actually believe it is booting from the usb-drivewhywell if I start the rasp without the flashdrive it doesn’t pop up in the LAN. With flashdrive is does.
All guessing because I want it work headless and connect over ssh via putty. In Jessie all you have to do is put a file called ssh on the sd-card. When it boots the fact that the file is there initializes ssh. I have put an ssh-file on both the flashdrive and the sd-card but that doesn’t seem to get ssh up. Any idea how to solve this problem? I followed this guide and “Install MySQL Server on your Raspberry Pi” last year on a Raspberry Pi 3.
That server is running great and serving WordPress wonderfully. I just relied to do it again on another Raspberry Pi 3, but things have changed with cmdline.txt and I couldn’t get it to boot.
It now refers to the boot partition by PARTUUID (root=PARTUUID=402e4a57-02). I’m using 2017-04-10 Raspbian / Raspbian Lite and perhaps this is the problem, not sure. (I was trying to boot a USB 3 flash drive and that may also have been my problem) In the process of figuring it out I learned about USB mass storage boot mode.
I tried that and it works well for me, so far, using an SSD in a USB case using a powered hub. Anyway, I’m so happy that you took the time to make this tutorial that I wanted to share my latest experience Thanks again.
JIka kita memilih monor 1 Install maka kita akan menginstall linux debian berbasi text, jika kita memilih momor 2 Grapichal install maka kita akan menginstall linux debian berbasi GUI (Graphical User Interfaces), jika kita memilih nomor 3 Advanced Options maka kita akan diberi penjelasan mengenai installer boot menu, jika kita memilih nomor 4 Help maka kita akan diberi tahu mengenai tombol navigasi dan perintah yang dapat digunakan pada menu Installer debian. Disini saya memilih Install nomor 1, kemudian enter.