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

Re: HOWTO: Move the filesystem to a USB stick

Wed Dec 24, 2014 4:26 pm

Mmh, the SD card looks like a NOOBs installation, not a pure Raspbian installation.
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

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

Re: HOWTO: Move the filesystem to a USB stick

Fri Dec 26, 2014 3:53 pm

Not NOOBS on my SD, in fact I noticed there was a new Raspbian image released on the 24th so I loaded that and did everything one more time from scratch. Got the same nasty warning. (I think the first time somehow I hadn't cleared the partition table from previous work, but this time I totally reformatted the flash). Anyway, this is what I got this time:
----------------------------
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
pi@raspberrypi ~ $ df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 15G 2.9G 11G 21% /
/dev/root 15G 2.9G 11G 21% /
devtmpfs 239M 0 239M 0% /dev
tmpfs 49M 256K 49M 1% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 97M 0 97M 0% /run/shm
/dev/mmcblk0p1 56M 9.7M 47M 18% /boot
pi@raspberrypi ~ $ sudo fdisk -l

Disk /dev/mmcblk0: 7948 MB, 7948206080 bytes
4 heads, 16 sectors/track, 242560 cylinders, total 15523840 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: 0x000c45c9

Device Boot Start End Blocks Id System
/dev/mmcblk0p1 8192 122879 57344 c W95 FAT32 (LBA)
/dev/mmcblk0p2 122880 15523839 7700480 83 Linux

Disk /dev/sda: 16.0 GB, 16013942784 bytes
150 heads, 63 sectors/track, 3309 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: 0x00000000

Device Boot Start End Blocks Id System
/dev/sda1 2048 31277231 15637592 83 Linux
pi@raspberrypi ~ $
----------------------------

I tried to attach screen shots from my GParted GUI run but had the same problem as an earlier poster who got tangled up with SSH and couldn't make a screen copy to insert here. But GParted showed two devices, /dev/mmcblk0 and /dev/sda.

/dev/mmcblk0 showed:

unallocated 4.00MiB
/dev/mmcblk0p1 fat16 /boot 56.00 MiB
/dev/mmcblk0p2 ext4 /media/c13949585 etc 7.34 GiB

and /dev/sda showed:
size used unused
/dev/sda1 ext4 / rootfs 14.91GiB 3.16GiB 11.75 GiB

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

I felt obligated to follow up on this since I introduced this issue so I am posting the above information, although I don't personally really need the extended method since I have a simple configuration and usage. Should have stopped while I was ahead. Some Googling suggested I should just ignore this ominously stated warning message so I am going to proceed using my SD/flash setup as is and see if I run into problems. So on to my Lighttpd/SQLite/WordPress install I go, writing my WP database to a new flash partition. WP installs are always a joy.... :?

Excellent tutorial nonetheless, Paulv! Everybody else did great, just something odd going on with me.

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

Re: HOWTO: Move the filesystem to a USB stick

Sun Dec 28, 2014 2:20 pm

Well, the culprit was my flash drive. Put a new one in and went through the tutorial and all is well. :D

ktb
Posts: 1380
Joined: Fri Dec 26, 2014 7:53 pm

Re: HOWTO: Move the filesystem to a USB stick

Fri Jan 02, 2015 11:38 pm

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.
I'll share the PARTUUID and UUID configuration which works for me just in case somebody else comes across this issue (perhaps after reading all the conflicting advice available on the internet). NOTE: I do not use a USB stick, but the following is the way I mount the main MicroSD card on my B+ running Raspbian Jessie (3.18.1+):

Information from the command blkid /dev/mmcblk0:
/dev/mmcblk0
PTUUID=000c45c9
PTTYPE=dos

/dev/mmcblk0p1
SEC_TYPE=msdos
LABEL=boot
UUID=936C-7154
TYPE=vfat
PARTUUID=000c45c9-01

/dev/mmcblk0p2
LABEL=root
UUID=c1398422-7a7c-4863-8a8f-45a1db26b4f2
TYPE=ext4
PARTUUID=000c45c9-02

So, the /boot/cmdline.txt looks something like this:

smsc95xx.turbo_mode=N dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=PARTUUID=000c45c9-02 rootfstype=ext4 elevator=deadline rootwait ip=192.168.1.11::192.168.1.1 init=/bin/systemd

And then the /etc/fstab looks something like this:

UUID=936C-7154 /boot vfat defaults 0 2
UUID=c1398422-7a7c-4863-8a8f-45a1db26b4f2 / ext4 defaults,noatime,nodiratime 0 1
# a swapfile is not a swap partition, no line here
# use dphys-swapfile swap[on|off] for that

User avatar
Offcenter
Posts: 182
Joined: Wed Jul 31, 2013 4:57 pm
Location: Northwestern New Jersey USA

Re: HOWTO: Move the filesystem to a USB stick

Sat Jan 10, 2015 8:21 pm

Paulv, Thank you very much for this well written tutorial.
I just finished moving my file system to a hard drive on my B+.
Your instructions worked perfectly.
Couldn't have done it without your help.
Thanks again.
George in New Jersey.
(learning a little bit every day.)
(and darned confused most of the time!)

jamesdinsmore
Posts: 3
Joined: Sun Jan 18, 2015 6:22 pm

Re: HOWTO: Move the filesystem to a USB stick

Sun Jan 18, 2015 6:28 pm

OMG! Way too many steps! Maybe something could be adapted from Berryboot, which as a matter of course allows you to select whether to install to an SD card or to USB memory, etc (effortlessly!) http://www.berryterminal.com/doku.php/berryboot

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

Re: HOWTO: Move the filesystem to a USB stick

Sun Jan 18, 2015 10:12 pm

jamesdinsmore wrote:OMG! Way too many steps! Maybe something could be adapted from Berryboot, which as a matter of course allows you to select whether to install to an SD card or to USB memory, etc (effortlessly!) http://www.berryterminal.com/doku.php/berryboot
The RPi has been developed for learning something, not to supply one click solutions for everything. And you can learn a lot, if you work through this great HOWTO.
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

mmfc
Posts: 15
Joined: Tue Jan 06, 2015 6:40 pm

Re: HOWTO: Move the filesystem to a USB stick

Tue Jan 20, 2015 10:08 pm

I'm trying to set up the boot partition to be on my hdd that is normally connected to my pi as a media storage device, so most of these changes are being done in raspbmc not raspbian (will that make a difference?)

Created a partition in windows, which was then formatted in the steps on this how to (I skipped the delete/create partition stages). I set it up using /dev/sda2 which was to be the boot drive.

When i rebooted my pi it tells me "Kernel panic - VFS - unable to mount root fs to [can't remember what] incorrect block (8,2)

As far as I am aware the only changes I made to the boot config was to add a root delay of 10 (to allow for the hdd to spin up) and to change the boot address. Anyone else seen this error?

fruitoftheloom
Posts: 20733
Joined: Tue Mar 25, 2014 12:40 pm
Location: Delightful Dorset

Re: HOWTO: Move the filesystem to a USB stick

Tue Jan 20, 2015 10:16 pm

mmfc wrote:I'm trying to set up the boot partition to be on my hdd that is normally connected to my pi
The RPi can only have the boot partition on the SD Card

https://thekandyancode.wordpress.com/20 ... i-boots-up
Retired disgracefully.....

User avatar
DougieLawson
Posts: 36135
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: HOWTO: Move the filesystem to a USB stick

Tue Jan 20, 2015 10:18 pm

The boot partition MUST be the first primary FAT or FAT32 partition on the SDCard or the Raspberry Pi can't boot.

The root filesystem for any Linux based operating system must use a Linux native filesystem (ext2, ext3, ext4, reiserfs, etc), you can't use Windows native filesystems (FAT, FAT32, exFAT or NTFS).
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

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

Re: HOWTO: Move the filesystem to a USB stick

Tue Jan 20, 2015 11:00 pm

DougieLawson wrote:The boot partition MUST be the first primary FAT or FAT32 partition on the SDCard or the Raspberry Pi can't boot.

The root filesystem for any Linux based operating system must use a Linux native filesystem (ext2, ext3, ext4, reiserfs, etc), you can't use Windows native filesystems (FAT, FAT32, exFAT or NTFS).

As usual, I think the responders (to this last query) are totally missing the point.

Yes, the poster was a little loose with terminology, since, as we know, you can't really "boot" off of anything other than an SD card. But it is clear from his text that he has gotten past that hurdle, since he is booting; it is just failing to mount the roots. So, he must be booting from the SD card (to get as far as he did).

Now, having said all that, let me comment that, from a purely functional point of view (i.e., not counting the aesthetics of the situation), there really isn't all that much point in "moving the filesystem to a USB stick" (the title and nominal subject matter of this thread). To my mind, because of the fact that you always have to have the SD card for booting, means that you might as well just leave the system there as well.

Aesthetically, I can see reasons for doing it, but if you're the "I just want it to work" type, then it is probably not necessary.

Myself, I did it for the simple reason that I didn't have any micro-SD cards bigger than 2G laying around, so I couldn't fit the system onto the SD card when I "upgraded" to the B+.
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)

mmfc
Posts: 15
Joined: Tue Jan 06, 2015 6:40 pm

Re: HOWTO: Move the filesystem to a USB stick

Tue Jan 20, 2015 11:21 pm

Ok so i was a bit loose with terminology... I meant i wanted to put the OS on the HDD, and yes obviously leave the boot part on the SD card, as Joe pointed out...

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

Re: HOWTO: Move the filesystem to a USB stick

Wed Jan 21, 2015 8:30 am

Joe Schmoe wrote:...
Now, having said all that, let me comment that, from a purely functional point of view (i.e., not counting the aesthetics of the situation), there really isn't all that much point in "moving the filesystem to a USB stick" (the title and nominal subject matter of this thread). To my mind, because of the fact that you always have to have the SD card for booting, means that you might as well just leave the system there as well.

Aesthetically, I can see reasons for doing it, but if you're the "I just want it to work" type, then it is probably not necessary.
An USB stick is no great alternative to running it from SD, but a HDD really is: much faster, no SD card corruption any more and lots of space for data.
So the title of the OP is a bit misleading, but in fact it is the best tutorial for running your root FS from any USB media.

mmfc did not follow the tutorial closely and that's why he completely messed it up.
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

mmfc
Posts: 15
Joined: Tue Jan 06, 2015 6:40 pm

Re: HOWTO: Move the filesystem to a USB stick

Wed Jan 21, 2015 8:39 am

So I think I've discovered the fault - Somewhere (presumably when doing stuff in fdisk) it has caused the hdd to lose its filesystem for whatever reason...

Time to recover all the data from backup and start again. poo.

Does anyone else use this on a HDD? What kind of rootdelay are you using?

User avatar
RaTTuS
Posts: 10459
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: HOWTO: Move the filesystem to a USB stick

Wed Jan 21, 2015 8:46 am

2 of my RPI's have a HD for a rootfs
no root delay is used on either
YMMV
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

xXAzazelXx
Posts: 135
Joined: Tue Sep 18, 2012 8:32 am
Location: Australia
Contact: Website

Re: HOWTO: Move the filesystem to a USB stick

Fri Jan 23, 2015 9:55 am

Hey Guys,

How do i go about backing up this set up?
Do i just plug both USD and SD in and Win32DiskImager them both?

abramidgeo
Posts: 1
Joined: Sat Jan 31, 2015 9:07 am

Re: HOWTO: Move the filesystem to a USB stick

Sat Jan 31, 2015 9:18 am

Hello
I have some troubles after moving root folder to usb when sudden power cut-off occurs. In some of these cases (not all of them but 80% of them lets say...) I have got an error after color booting image

sh:can't access tty;job control turned off

In order to get raspberry to boot I remove the SD and The Usb stick and then plug them in again and then it boots without problem (sometimes I need to repeat the remove-plug in procedure once more in order to start working).

I did not follow the procedure of this forum for moving the root to usb, I followed an other one, more Simple :oops: .
First after reading about the rootdelay parameter I thought that may be this is what I need. But no lack....

I added avoid_safe_mode=1 into cmdline.txt but nothing changed.
I noticed that when I remove the RTC (clock) module the error does not occur.
When the root folder was in SD there were no problems of this nature (only corruption problems :D )
I am confused......

Because this is going to be a remote system with no person to remove/plug-in the devices is there a way to solve this.....

Please Help :shock:

Thanks,
George

VonBrownie
Posts: 1
Joined: Tue Jul 01, 2014 4:48 pm
Location: 1 AU
Contact: Website

Re: HOWTO: Move the filesystem to a USB stick

Mon Feb 02, 2015 4:43 am

A big thanks to all the contributors to this thread... I am running my Raspberry Pi B with the root filesystem moved to an old 1TB external USB hard drive. I imagine an always-on Pi would enjoy more robust performance from a hard drive than an SD card.

jhaprade
Posts: 3
Joined: Wed Feb 18, 2015 9:01 pm

Re: HOWTO: Move the filesystem to a USB stick

Wed Feb 18, 2015 9:08 pm

Hello,

I followed the instructions and was able to mount the USB stick on /dev/sda1 on /mnt.

But when I did the "rsync" step, I got some errors. And after that, when I do "cd /mnt; ls", I get the following message:

Code: Select all

[ 3475.526102] EXT4-fs error (device sda1): htree_dirblock_to_tree:896: inode #2: block 9249: comm ls: bad entry in directory: inode out of bounds - offset=0(0), inode=2922024487, rec_len=1096, name_len=213
None of the following commands are working. Any suggestions?

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

Re: HOWTO: Move the filesystem to a USB stick

Wed Feb 18, 2015 10:00 pm

jhaprade wrote:Hello,

I followed the instructions and was able to mount the USB stick on /dev/sda1 on /mnt.

But when I did the "rsync" step, I got some errors. And after that, when I do "cd /mnt; ls", I get the following message:

Code: Select all

[ 3475.526102] EXT4-fs error (device sda1): htree_dirblock_to_tree:896: inode #2: block 9249: comm ls: bad entry in directory: inode out of bounds - offset=0(0), inode=2922024487, rec_len=1096, name_len=213
None of the following commands are working. Any suggestions?
rsync errors meant corrupted files, I suppose. The error message when mounting is the result.
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

jhaprade
Posts: 3
Joined: Wed Feb 18, 2015 9:01 pm

Re: HOWTO: Move the filesystem to a USB stick

Wed Feb 18, 2015 10:10 pm

I am sorry but I didn't understand. How do I deal with this rsync error?

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

Re: HOWTO: Move the filesystem to a USB stick

Wed Feb 18, 2015 10:28 pm

jhaprade wrote:I am sorry but I didn't understand. How do I deal with this rsync error?
Try again and if you are getting errors again have a look at the error messages. They will give you (and us) a hint what went wrong.
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

359
Posts: 16
Joined: Thu May 29, 2014 7:55 pm

Re: HOWTO: Move the filesystem to a USB stick

Mon Mar 02, 2015 8:03 pm

Hi. Thanks to this thread, I have been running an old PiB for many months from a usb stick. Thank you all

My PiB sd card is actually a micro sd running in an Adafruit adapter.

Now I have a Pi2. I wish to move the PiB micro sd and usb to the Pi2 as is, hoping to avoid lot of configuration. On the PiB, have run sudo update, upgrade and so on, I have read this is needed to move a SD card to the Pi2. Then plugged the micro sd into the Pi2, usb into a slot but it doesn't boot, no nothing if hdmi is plugged in, just a red light. The psu is a 1.5A 5v supply so pretty sure it is not that.

Any thoughts on how to accomplish this?

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

Re: HOWTO: Move the filesystem to a USB stick

Mon Mar 02, 2015 9:35 pm

359 wrote:Hi. Thanks to this thread, I have been running an old PiB for many months from a usb stick. Thank you all

My PiB sd card is actually a micro sd running in an Adafruit adapter.

Now I have a Pi2. I wish to move the PiB micro sd and usb to the Pi2 as is, hoping to avoid lot of configuration. On the PiB, have run sudo update, upgrade and so on, I have read this is needed to move a SD card to the Pi2. Then plugged the micro sd into the Pi2, usb into a slot but it doesn't boot, no nothing if hdmi is plugged in, just a red light. The psu is a 1.5A 5v supply so pretty sure it is not that.

Any thoughts on how to accomplish this?
Overclocking / Overvolting is a bit different between Pi1 and 2. Remove all overclocking settings in config.txt.

I've successfully replaced two Pi1s with Pi2s with the root FS on HDDs.
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

359
Posts: 16
Joined: Thu May 29, 2014 7:55 pm

Re: HOWTO: Move the filesystem to a USB stick

Tue Mar 03, 2015 12:13 am

Good to know it has been done with success, thank you gkreidl.

I don't believe there is any overclocking but will check this later. Appreciate the reply

Return to “Advanced users”