I wanted to try this to see if my 1.0.5a Frodo 12.2 Xbian build would boot any faster with the Xbian boot partition on a USB2 flash drive or portable hard drive.
As my video library was already on a Western Digital 320GB 2.5" portable HDD, it made sense to just create another partition on there to support the boot process. What follows is how I achieved this.
First off, credit to @Jameson for this post which is what all my effort was based on, thank you. But wait, before you get started and waste 30 minutes of your life, please be aware that it was no faster than booting from my 4GB Class 10 Strontium SD Card. The boot times I got are listed below:
What you'll need if you still want to try it:
Now assuming your Pi is all connected up and working and you can SSH into it, follow these steps. All commands that you need to type are in bold and italics.
As my video library was already on a Western Digital 320GB 2.5" portable HDD, it made sense to just create another partition on there to support the boot process. What follows is how I achieved this.
First off, credit to @Jameson for this post which is what all my effort was based on, thank you. But wait, before you get started and waste 30 minutes of your life, please be aware that it was no faster than booting from my 4GB Class 10 Strontium SD Card. The boot times I got are listed below:
- Boot from 4GB Class 10 Strontium SD Card > 45s
- Boot from USB2 4GB Flash Drive > 60s
- Boot from USB2 4GB HDD partition > 64s
What you'll need if you still want to try it:
- A USB flash drive or portable HDD with a partition formatted in FAT or FAT32 (others may be supported but not tested) that is at least the same size as your SD Card.
- A computer you can SSH into your Pi from and a SD card slot or reader just in case things go wonky.
- Knowledge of how to SSH into your XBMC build.
- The ability to use Nano to edit two files on your Pi.
Now assuming your Pi is all connected up and working and you can SSH into it, follow these steps. All commands that you need to type are in bold and italics.
- Hook up your external drive. Run lsusb to ensure it populates on that list. If it doesn't, it may pay just your reboot XBMC to see if it gets recognised.
- Run df -h to define what the paritions are for your external drive.
- If it's a USB drive, it should report back as /dev/sda1.
- If it's a 2nd parition on an external drive (like mine), it will report as /dev/sda2.
- Assuming your USB stick is /dev/sda1 (usually is…), run sudo dd if=/dev/mmcblk0p2 of=/dev/sda1 bs=512. This will copy your SD card boot partition to your external drive. This took about 15 minutes to execute on my system.
- When the SSH session has returned you to the command prompt, run: sudo nano /boot/cmdline.txt
- Edit where it says root=/dev/mmcblk0p2 to /dev/sda1 if you're using a thumb drive (with one partition) or in my case /dev/sda2
- Next, run: sudo nano /etc/fstab
- Edit the line that says /dev/mmcblk0p2 to /dev/sda1 or in my case (you guessed it), /dev/sda2.
- Reboot by typing (sudo shutdown -r now).
- You should now be booting on your USB stick!
- If it fails to boot for any reason, you can insert the SD Card back into your PC/MAC and edit the cmdline.txt file manually to restore the boot line back to root=/dev/mmcblk0p2. Your PI should now boot even though the /etc/fstab is incorrectly pointing to your external drive. SSH back into your device and follow steps 4 and 5 again to change your fstab file back to the defaults.
- If you modify sudo nano /etc/fstab for /dev/sda1, df -h will no longer be able to see the external drive/s if you change the cmdline.txt back to root=/dev/mmcblk0p2 for any reason, at least that was my experience.
- Even though the boot partition may only be consuming 1GB of the 3.7GB available, your external drive must be the same size or larger than the whole boot partition size.
- To use Nano, edit the line you need and on a Windows machine type ALT+X to close the editing process, Type Y when prompted to confirm the edit and just hit Enter to accept that file name that is presented.
Nice and simple thanks. What's the best way to confirm that its running from the USB drive and not the sd card?
ReplyDeleteI copied the whole sd card (both partitions) to my flash drive, not just /root
Here's my dh -h
$ df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 934M 738M 140M 85% /
udev 10M 4.0K 10M 1% /dev
tmpfs 188M 192K 188M 1% /run
/dev/sda2 934M 738M 140M 85% /
none 5.0M 0 5.0M 0% /run/lock
none 188M 0 188M 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/sda2 934M 738M 140M 85% /home
/dev/sda1 34M 11M 24M 32% /boot
/dev/sda2 934M 738M 140M 85% /media/xbian-root-btrfs-67c085e4-91f4-431c-bd89-404d4625de17
Very informative and well written post! I like your post. It is very helpful and informative. Thank you so much for writing such a good post.I could get lot more knowledge from your article.. thanks for sharing.
ReplyDelete