gkreidl
Posts: 6053
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: HOWTO: Move the filesystem to a USB stick

Sat Jul 12, 2014 5:21 am

dms489 wrote:I'm a newbie trying to do the same thing, but when I first boot the SD card, the Pi automagically runs the file system expansion. How do you stop it so you can control the configuration as the author indicated?
I assume you are using NOOBS and not a clean Raspbian installation.

BTW, this approach also works at a later time; I've used it to move my root fs to a HD after my SD card started to get problems.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

phipix01
Posts: 2
Joined: Wed Mar 05, 2014 8:12 am

Re: HOWTO: Move the filesystem to a USB stick

Tue Jul 22, 2014 2:04 pm

this tutorial is absolute badass! great explanation, worked from the first try, and it's the most detailed about running os from usb out there.
thank you very much sir!

sic698
Posts: 5
Joined: Tue Jul 22, 2014 8:20 am

Re: HOWTO: Move the filesystem to a USB stick

Sat Aug 02, 2014 2:38 am

Hi there,

I was able to follow your initial instructions and it worked perfectly I am able to boot my pi off a usb stick, However I would like to clone/make an iso/img of the sd /boot and the usb stick so if ever either media devices dies out I can just flash it all back.

Example Flash/write boot.img to sd stick, Flash/Write raspberrypiserver.img ---> usb stick.

How do I go on about doing this.

Here my Current Setup

Filesystem Size Used Avail Use% Mounted on
rootfs 7.1G 1.6G 5.1G 25% /
/dev/root 7.1G 1.6G 5.1G 25% /
devtmpfs 239M 0 239M 0% /dev
tmpfs 49M 704K 48M 2% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 98M 0 98M 0% /run/shm
/dev/mmcblk0p1 56M 9.5M 47M 17% /boot
/dev/sda1 1.9T 266G 1.6T 15% /media/USBHDD1

My usb stick is on sdb or sdb1
Boot file is /dev/mmcblk0p1

Device Boot Start End Blocks Id System
/dev/sdb1 2048 15240575 7619264 83 Linux
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 8192 122879 57344 c W95 FAT32 (LBA)
/dev/mmcblk0p2 122880 7741439 3809280 83 Linux
Disk /dev/mmcblk0: 3963 MB, 3963617280 bytes
4 heads, 16 sectors/track, 120960 cylinders, total 7741440 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c7b31

gkreidl
Posts: 6053
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: HOWTO: Move the filesystem to a USB stick

Sat Aug 02, 2014 8:01 am

Why don't you simply create a backup on a second USB stick using rsync?
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

sic698
Posts: 5
Joined: Tue Jul 22, 2014 8:20 am

Re: HOWTO: Move the filesystem to a USB stick

Sat Aug 02, 2014 3:46 pm

How do I go on about using rsync?

gkreidl
Posts: 6053
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: HOWTO: Move the filesystem to a USB stick

Sat Aug 02, 2014 3:54 pm

You already used it. See the first posting.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

harold95
Posts: 20
Joined: Thu Feb 06, 2014 11:28 pm
Location: Pawtucket Rhode Island USA

Re: HOWTO: Move the filesystem to a USB stick

Mon Aug 11, 2014 3:29 pm

hell all

i've noticed i'm getting an error on boot up:

mntent : bad line in fstab line 3

or something like that. i get it repeated 5-6 times.

here is my fstab:

Code: Select all

proc            /proc           proc    defaults          0       0
/dev/mmcblk0p5  /boot           vfat    defaults          0       2
/dev/sda1    /   ext4    defaults,noatime  0       1
#/dev/mmcblk0p6 /               ext4    defaults,noatime  0       1
the system still boots!
i'm using it now.
but i can't help feeling that the next boot will be my last.

any ideas?

thanks
harold
1. B pi, usb ext pwrd hdd 500gb, pwrd usb hub 2a (pwrs pi), wifi, vga adptr, wired kb/mouse, usb audio.
2. B pi, hdlss. adaptd for use as an IRLP node. IRLP rev 3 board wired to gpio, usb audio, Alinco DR135 2 meter ham radio(www.irlp.net)

DirkS
Posts: 9902
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: HOWTO: Move the filesystem to a USB stick

Mon Aug 11, 2014 3:46 pm

Did you copy / paste the 3rd line into the file? It could be that there are one or more (invisible) characters that the system struggles with.
You could try to delete the line and enter it manually.

Gr.
Dirk.

harold95
Posts: 20
Joined: Thu Feb 06, 2014 11:28 pm
Location: Pawtucket Rhode Island USA

Re: HOWTO: Move the filesystem to a USB stick

Mon Aug 11, 2014 4:21 pm

DirkS wrote:Did you copy / paste the 3rd line into the file? It could be that there are one or more (invisible) characters that the system struggles with.
You could try to delete the line and enter it manually.

Gr.
Dirk.

yeah i did. i'll type it in by hand and see what that does.


edit:

yes, that fixed it. thanks for the quick reply and the solution!
1. B pi, usb ext pwrd hdd 500gb, pwrd usb hub 2a (pwrs pi), wifi, vga adptr, wired kb/mouse, usb audio.
2. B pi, hdlss. adaptd for use as an IRLP node. IRLP rev 3 board wired to gpio, usb audio, Alinco DR135 2 meter ham radio(www.irlp.net)

perkas
Posts: 15
Joined: Fri Sep 27, 2013 10:28 pm
Location: Spain

Re: HOWTO: Move the filesystem to a USB stick

Wed Aug 13, 2014 7:53 am

Hi all,
Actually i have installed Raspbmc in a usb drive (with raspbmc installer)
I would like to install also Raspbmc in Usb, and select the s.o. at boot time.

As Noobs doesn't allow usb installation, It is possible to have Raspbian and Raspbmc installed in USB? ( i have read that Berryboot allow it) :?:

If i do a clean installation of raspbmc and raspbian with Noobs, then i would move both to Usb? :?:

Thanks!! :P
-------------------------------------------------------------------------------------------------------------------------------
I´m trying now with BerryBoot. It seems to allow install in USB..

User avatar
pluggy
Posts: 3635
Joined: Thu May 31, 2012 3:52 pm
Location: Barnoldswick, Lancashire,UK
Contact: Website

Re: HOWTO: Move the filesystem to a USB stick

Thu Aug 14, 2014 10:41 am

This old dinosaur wonders why the flash in a USB stick is somehow better than the near identical flash in an SD card ? Its the same dodgy technology with a USB interface, and with the Pi's history with USB issues........
Don't judge Linux by the Pi.......
I must not tread on too many sacred cows......

DaveyWavey
Posts: 6
Joined: Sat Aug 30, 2014 8:45 am

Re: HOWTO: Move the filesystem to a USB stick

Sat Aug 30, 2014 9:56 am

I thought I'd add my voice to the many others thanking paulv for this guide. It worked a treat for me, moving my root filesystem to an SSD drive connected via USB.

Cheers!

paulv
Posts: 558
Joined: Tue Jan 15, 2013 12:10 pm
Location: Netherlands

Re: HOWTO: Move the filesystem to a USB stick

Sat Aug 30, 2014 1:39 pm

Thank you DaveyWavey and the many others.

It's about 90 minutes from my Happy Hour, and I'll drink to that cheers of yours!

There's always somebody somewhere on a forum that has more experience, and I've learned a tremendous lot myself.
Glad to have done something in return.

Paul

gogglehead
Posts: 1
Joined: Sun Sep 14, 2014 8:01 am

Re: HOWTO: Move the filesystem to a USB stick

Sun Sep 14, 2014 8:23 am

Hi

I can see this thread has been around a while, but I was wondering if anyone could help please.

I have installed Raspbmc using the installer stub program and ticked use USB (hopefully you will know what I mean by that, but if not, I can forward any links). Raspbmc and XBMC work perfectly find when I have just the USB pen drive in, but the moment I power on with an additional media Hard drive attached, it refuses to boot. My knowledge of all things linuxy is evolving from nothing, but if I am understanding what I think it's saying, it seems to be suggesting that it can't find the USB as part of the boot process.

Without the additional HD attached It is definitely using the USB stick in the boot process, as apart from the light flashing when it's in, if I take it out, I get exactly the same error message. So it's almost like inserting the HD at boot up time is somehow confusing the file system.

I can see in the cmdline.txt file that it does have root=UUID=da6cec5b-265a-427a-8b33-0ee32d0eb06f, but when I run gdisk I get the following,

root@raspbmc:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 15G 850M 13G 7% / <==== so this is my USB stick
/dev/mmcblk0p1 69M 8.4M 61M 13% /boot

root@raspbmc:~# gdisk /dev/sda1
GPT fdisk (gdisk) version 0.8.5

Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: not present

Creating new GPT entries.

Command (? for help):


Thank you to anyone who can assist/resolve?
Colin

justgetmeon
Posts: 1
Joined: Sun Sep 21, 2014 12:36 pm

Re: HOWTO: Move the filesystem to a USB stick

Sun Sep 21, 2014 12:44 pm

Hi, I am a newbie, so don't offer any concrete advice, but I would say check your fstab is using device id not device assignment, e.g.:

/dev/disk/by-uuid/3d2cb3c9-7e2b-4255-ac63-863bd3ad7993 / ext4 defaults,noatime 0 1

not /dev/sda1

also you may need to up the rootdelay as the hard drive might be slowing disk initialisation routines down??

timbald
Posts: 2
Joined: Sat Oct 25, 2014 7:44 pm

Re: HOWTO: Move the filesystem to a USB stick

Sat Oct 25, 2014 8:24 pm

Many thanks for the very useful guide - I hve set up a Pi with a powered external usb hub and a 120Gb SSD drive in a external case, and followed these guidelines to the letter and it has worked perfectly.

Thanks again.

abramq
Posts: 83
Joined: Sat Jul 26, 2014 10:47 pm

Re: HOWTO: Move the filesystem to a USB stick

Sun Nov 09, 2014 9:27 pm

Hello,
Is it possible to remove all content from the second partition od SD card after all that moving procedure?
I think - when all root node is moved to pendrive - it is possible to clean the SD card... but when i did it - system doesn' boot anymore...
What could make the problem then?

Greetings!

DirkS
Posts: 9902
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: HOWTO: Move the filesystem to a USB stick

Sun Nov 09, 2014 9:30 pm

abramq wrote:Hello,
Is it possible to remove all content from the second partition od SD card after all that moving procedure?
I think - when all root node is moved to pendrive - it is possible to clean the SD card... but when i did it - system doesn' boot anymore...
What could make the problem then?

Greetings!
You have to make sure you only remove the second (larger) partition.
The first partition contains the files needed for booting and configuration.
Best to make a backup (image) of your SD card before fiddling around with partitions.

Gr.
Dirk.

User avatar
ilovemipi
Posts: 161
Joined: Mon Dec 02, 2013 11:52 am
Location: UK + Cyprus
Contact: Website

Re: HOWTO: Move the filesystem to a USB stick

Sat Nov 15, 2014 1:18 am

miamia wrote:
miamia wrote:thanks, but what prefix for blkid shoudl I use in /boot/cmdline.txt? "root=PARTUUID="?
I found on internet this: root=/dev/disk/by-uuid/xxxxxxx. Maybe it helps.
EDITED: my RPi cannot boot with root=/dev/disk/by-uuid/xxxxxxx. With root=dev/sda1 everything works ok.
Did anyone work out what the format is to boot with the bikid?

DirkS
Posts: 9902
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: HOWTO: Move the filesystem to a USB stick

Sat Nov 15, 2014 2:58 pm

ilovemipi wrote:
miamia wrote:
miamia wrote:thanks, but what prefix for blkid shoudl I use in /boot/cmdline.txt? "root=PARTUUID="?
I found on internet this: root=/dev/disk/by-uuid/xxxxxxx. Maybe it helps.
EDITED: my RPi cannot boot with root=/dev/disk/by-uuid/xxxxxxx. With root=dev/sda1 everything works ok.
Did anyone work out what the format is to boot with the bikid?
AFAIK it does not work on stock Raspbian.

Gr.
Dirk.

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: HOWTO: Move the filesystem to a USB stick

Sat Nov 15, 2014 3:18 pm

AFAIK it does not work on stock Raspbian.
So, this all boils down to: Does it matter? Can it ever fail?

And by "it", I mean, if you have two USB "Mass Storage" devices connected at boot time, such that one of them will come up as /dev/sda and the other as /dev/sdb (but, in theory, you don't know which will be which), and you have "root=/dev/sda1" in cmdline.txt, can it ever fail to boot (assuming that only one of the attached devices has a bootable first partition) ?

Obviously, in theory, the answer is "Yes (it can fail)", but in practice, does it ever happen?

I ask, because my own experience is that it doesn't ever fail. I have exactly this configuration, and it has always booted correctly. Note that, for safety, I have my bootable device plugged directly into a USB port on the B+, while the other device is plugged in via a (powered) hub. This, on the theory that the closer a device is to the CPU, the more likely it is to be enumerated first.
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

User avatar
ilovemipi
Posts: 161
Joined: Mon Dec 02, 2013 11:52 am
Location: UK + Cyprus
Contact: Website

Re: HOWTO: Move the filesystem to a USB stick

Sat Nov 15, 2014 3:59 pm

Joe Schmoe wrote:
AFAIK it does not work on stock Raspbian.
So, this all boils down to: Does it matter? Can it ever fail?

And by "it", I mean, if you have two USB "Mass Storage" devices connected at boot time, such that one of them will come up as /dev/sda and the other as /dev/sdb (but, in theory, you don't know which will be which), and you have "root=/dev/sda1" in cmdline.txt, can it ever fail to boot (assuming that only one of the attached devices has a bootable first partition) ?

Obviously, in theory, the answer is "Yes (it can fail)", but in practice, does it ever happen?

I ask, because my own experience is that it doesn't ever fail. I have exactly this configuration, and it has always booted correctly. Note that, for safety, I have my bootable device plugged directly into a USB port on the B+, while the other device is plugged in via a (powered) hub. This, on the theory that the closer a device is to the CPU, the more likely it is to be enumerated first.
Maybe you are right for most people. Just tried it with a B+, powered hub, 2 identical USB sticks and a USB HDD. USB with f/s is in the B+ and the other without f/s is in the hub. HDD is in the hub. All boots fine.

I guess the issue the OP was referring to was when you have filesystems on different sticks and you are swapping them around. Not too often but might occasionally happen.

VoidFox
Posts: 5
Joined: Fri Jan 24, 2014 11:13 pm
Location: Germany

Re: HOWTO: Move the filesystem to a USB stick

Wed Nov 19, 2014 1:04 am

thanks paulv

superb guide ^^

williamh
Posts: 4
Joined: Wed Aug 20, 2014 8:10 pm

Re: HOWTO: Move the filesystem to a USB stick

Fri Nov 28, 2014 9:50 am

I ran into boot problems. Found out that sd_mod was not in the kernel but loaded as module. Got around it by setting up a init ramdrive.

PorterDon
Posts: 69
Joined: Wed Aug 21, 2013 2:09 pm
Location: Thailand

Re: HOWTO: Move the filesystem to a USB stick

Wed Dec 24, 2014 2:56 pm

Everything was going perfectly until I got into the extented part. When I ran:

sudo gdisk /dev/sda

POP! Went the weasel!

----------------------
pi@raspberrypi ~ $ sudo gdisk /dev/sda
GPT fdisk (gdisk) version 0.8.5

Partition table scan:
MBR: MBR only
BSD: not present
APM: not present
GPT: not present


***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format.
THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by typing 'q' if
you don't want to convert your MBR partitions to GPT format!
***************************************************************


Warning! Secondary partition table overlaps the last partition by
33 blocks!
You will need to delete this partition or resize it in another utility.

Command (? for help): q

--------------------------------------------------------------

Huh? What "secondary partition table"? Where did that come from? :shock:

I did a fair amount of Googling but couldn't get the recipe to get past this, and I don't have in-depth knowledge of partition file modification, not to mention knowing zero about MBRs and GPTs. :cry: I was astounded to see this because I was spot on line by line through this tutorial and was getting ready to have a few celebratory cold ones. Fail.

This is what I have:

pi@raspberrypi ~ $ df -h

Filesystem Size Used Avail Use% Mounted on
rootfs 15G 2.8G 12G 21% /
/dev/root 15G 2.8G 12G 21% /
devtmpfs 239M 0 239M 0% /dev
tmpfs 49M 268K 49M 1% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 97M 0 97M 0% /run/shm
/dev/mmcblk0p5 60M 9.6M 50M 17% /boot
/dev/sda1 15G 2.8G 12G 21% /mnt

pi@raspberrypi ~ $ sudo fdisk -l

Disk /dev/mmcblk0: 7822 MB, 7822376960 bytes
4 heads, 16 sectors/track, 238720 cylinders, total 15278080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00018f04

Device Boot Start End Blocks Id System
/dev/mmcblk0p1 8192 1609375 800592 e W95 FAT16 (LBA)
/dev/mmcblk0p2 1613824 15212543 6799360 85 Linux extended
/dev/mmcblk0p3 15212544 15278079 32768 83 Linux
/dev/mmcblk0p5 1622016 1744895 61440 c W95 FAT32 (LBA)
/dev/mmcblk0p6 1753088 15212543 6729728 83 Linux

Disk /dev/sda: 16.0 GB, 16013942784 bytes
6 heads, 16 sectors/track, 325804 cylinders, total 31277232 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x2b828790

Device Boot Start End Blocks Id System
/dev/sda1 2048 31277231 15637592 83 Linux

pi@raspberrypi ~ $
---------------------------------

Obviously I need somebody's assistance. Thanks in advance.

Return to “Advanced users”