Page 5 of 14

Re: HOWTO: Move the filesystem to a USB stick

Posted: Wed Dec 24, 2014 4:26 pm
by gkreidl
Mmh, the SD card looks like a NOOBs installation, not a pure Raspbian installation.

Re: HOWTO: Move the filesystem to a USB stick

Posted: Fri Dec 26, 2014 3:53 pm
by PorterDon
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.

Re: HOWTO: Move the filesystem to a USB stick

Posted: Sun Dec 28, 2014 2:20 pm
by PorterDon
Well, the culprit was my flash drive. Put a new one in and went through the tutorial and all is well. :D

Re: HOWTO: Move the filesystem to a USB stick

Posted: Fri Jan 02, 2015 11:38 pm
by ktb
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

Re: HOWTO: Move the filesystem to a USB stick

Posted: Sat Jan 10, 2015 8:21 pm
by Offcenter
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.

Re: HOWTO: Move the filesystem to a USB stick

Posted: Sun Jan 18, 2015 6:28 pm
by jamesdinsmore
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

Re: HOWTO: Move the filesystem to a USB stick

Posted: Sun Jan 18, 2015 10:12 pm
by gkreidl
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.

Re: HOWTO: Move the filesystem to a USB stick

Posted: Tue Jan 20, 2015 10:08 pm
by mmfc
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?

Re: HOWTO: Move the filesystem to a USB stick

Posted: Tue Jan 20, 2015 10:16 pm
by fruitoftheloom
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

Re: HOWTO: Move the filesystem to a USB stick

Posted: Tue Jan 20, 2015 10:18 pm
by DougieLawson
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).

Re: HOWTO: Move the filesystem to a USB stick

Posted: Tue Jan 20, 2015 11:00 pm
by Joe Schmoe
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+.

Re: HOWTO: Move the filesystem to a USB stick

Posted: Tue Jan 20, 2015 11:21 pm
by mmfc
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...

Re: HOWTO: Move the filesystem to a USB stick

Posted: Wed Jan 21, 2015 8:30 am
by gkreidl
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.

Re: HOWTO: Move the filesystem to a USB stick

Posted: Wed Jan 21, 2015 8:39 am
by mmfc
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?

Re: HOWTO: Move the filesystem to a USB stick

Posted: Wed Jan 21, 2015 8:46 am
by RaTTuS
2 of my RPI's have a HD for a rootfs
no root delay is used on either
YMMV

Re: HOWTO: Move the filesystem to a USB stick

Posted: Fri Jan 23, 2015 9:55 am
by xXAzazelXx
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?

Re: HOWTO: Move the filesystem to a USB stick

Posted: Sat Jan 31, 2015 9:18 am
by abramidgeo
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

Re: HOWTO: Move the filesystem to a USB stick

Posted: Mon Feb 02, 2015 4:43 am
by VonBrownie
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.

Re: HOWTO: Move the filesystem to a USB stick

Posted: Wed Feb 18, 2015 9:08 pm
by jhaprade
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?

Re: HOWTO: Move the filesystem to a USB stick

Posted: Wed Feb 18, 2015 10:00 pm
by gkreidl
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.

Re: HOWTO: Move the filesystem to a USB stick

Posted: Wed Feb 18, 2015 10:10 pm
by jhaprade
I am sorry but I didn't understand. How do I deal with this rsync error?

Re: HOWTO: Move the filesystem to a USB stick

Posted: Wed Feb 18, 2015 10:28 pm
by gkreidl
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.

Re: HOWTO: Move the filesystem to a USB stick

Posted: Mon Mar 02, 2015 8:03 pm
by 359
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?

Re: HOWTO: Move the filesystem to a USB stick

Posted: Mon Mar 02, 2015 9:35 pm
by gkreidl
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.

Re: HOWTO: Move the filesystem to a USB stick

Posted: Tue Mar 03, 2015 12:13 am
by 359
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