Arduino Forum upgrade scheduled for Monday, October 20th, 11am-4pm (CEST). Sorry for the inconvenience!
Pages: [1] 2 3   Go Down
Author Topic: How to expand the storage memory on the Yún  (Read 4273 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Milano, Italy
Offline Offline
Edison Member
*****
Karma: 23
Posts: 1180
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You might have noticed that on the Linux side of the Yún the amount of available storage memory of the onboard flash memory is limited. Installing additional software packages you can run out of space soon. You can manually install software packages on an external SD card but it's tricky...and it's manual. OpenWRT gives you the possibility to move the root file system to an external storage as large as desired.

We wrote a sketch that is able through the Bridge library to format the SD card, prepare the partitions and configure the system to change the root directory. Then to move all your previous configuration to the new root file system.

Here the sketch:
https://github.com/Fede85/YunSketches/blob/master/YunOverlayOnSD/YunOverlayOnSD.ino

The advantage of this approach is that you only need to upload a sketch and follow the step-by-step procedure on the serial monitor.
The requirements are only the presence of the SD card in the socket and that the Yún is connected to internet.


The documentation to extend the storage space is documented on the OpenWRT wiki at the page called Rootfs on External Storage (extroot).


I would be glad if you want to try it and reply with the feedback or suggestions for improvements.
Logged

F

Offline Offline
Edison Member
*
Karma: 38
Posts: 1442
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

We are going to publish this sketch on the blog and we would like to make sure it works fine for everyone, so your feedback is highly appreciated.

It's much more a linux script than a sketch, but we thought that using a sketch would make it easier to use for everyone.

To give you an example, I used my 2Gigas micro sd card and told the sketch to split it in two halves.

This was the previous df -h / output
Code:
Filesystem                Size      Used Available Use% Mounted on
rootfs                    7.0M    356.0K      6.7M   5% /

And this is the output of df -h / /mnt/sda1 after running the sketch
Code:
Filesystem                Size      Used Available Use% Mounted on
rootfs                  861.8M     30.4M    788.2M   4% /
/dev/sda1              1022.0M     12.0K   1022.0M   0% /mnt/sda1

As you can see I went from 6.7M available to 788.2M and my /mnt/sd folder has 1G

If you encounter any error and would like to restore your yun to its previous state, all you need to do is to reboot it with the SD card UNplugged, then edit file /etc/config/fstab removing the following section
Code:
config mount
option target '/overlay'
option device '/dev/sda2'
option fstype 'ext4'
option enabled '1'
option enabled_fsck '0'
option options 'rw,sync,noatime,nodiratime'
and reboot once more
Logged

Have you upgraded the Yún? If you've just got it, then it needs to be upgraded! Check out the tutorial

Offline Offline
Full Member
***
Karma: 1
Posts: 236
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That sounds awesome!
Logged

Earth
Offline Offline
Edison Member
*
Karma: 53
Posts: 1910
My browser no longer is binding static IP, Floating is the way to go.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It worked for me. Thanks
Logged

0
Offline Offline
Newbie
*
Karma: 1
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Does not look like the link to the sketch is working anymore (Page not found)?
Logged

Earth
Offline Offline
Edison Member
*
Karma: 53
Posts: 1910
My browser no longer is binding static IP, Floating is the way to go.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

https://github.com/Fede85/YunSketches/blob/master/YunDiskSpaceExpander/YunDiskSpaceExpander.ino
Logged

Offline Offline
Edison Member
*
Karma: 38
Posts: 1442
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

We have also published it as a downloadable zip file. It's in the latest blogpost http://blog.arduino.cc/2014/05/06/time-to-expand-your-yun-disk-space-and-install-node-js/
Logged

Have you upgraded the Yún? If you've just got it, then it needs to be upgraded! Check out the tutorial

Offline Offline
Full Member
***
Karma: 1
Posts: 169
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is a really good idea!
However I would rather just run/tweak the Linux script instead of via the sketch. Any Chance of publishing this? If not, I'll extract it from the sketch myself.
Logged

Earth
Offline Offline
Edison Member
*
Karma: 53
Posts: 1910
My browser no longer is binding static IP, Floating is the way to go.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://forum.arduino.cc/index.php?topic=228204.msg1653830#msg1653830
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 36
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Does running the Yun from the microSD have any impact on performance? I.e. what is the relative performance of a typical microSD vs the onboard memory?

Thanks.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 36
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

My first Yun conversion went smoothly. But my second one failed (error detailed below). I surmised this was a issues with free space on / (of course that's why I was happy to see this extension scheme). I recalled I was at about 90% before running the conversion script. I removed a couple of packages to get to 83% full on / and re-ran the sketch. It ran correctly.

Bottom line is you may want to ensure you have about 80% free space on / before running this conversion.

Software list updated. Installing software (this will take a while)...
err. installing e2fsprogs mkdosfs fdisk
Logged

Offline Offline
Edison Member
*
Karma: 38
Posts: 1442
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you @roadfun, we'll try to check free space before running it

Regarding performance, we observed similar performances. However, when running on the SD card the Yun could go much much faster

When configuring the SD card, we forced writes to be in sync
This ensures that files do not corrupt even if you suddenly unplug the yun while you're writing a file (or at least this reduces the changes that such a corruption may happen)
However, if you just run  the following command
Code:
mount -o remount,async /dev/sda2
you'll see a great performance improvement (this is temporary: once you'll reboot, it will get back to "sync")

This is much more unsecure as files may get corrupted or you may lose data if the yun loses power while writing on the SD card

It's a trade-off and we chose with the conservative way as it is more secure and gives you a similar experience
Logged

Have you upgraded the Yún? If you've just got it, then it needs to be upgraded! Check out the tutorial

Global Moderator
Milano, Italy
Offline Offline
Edison Member
*****
Karma: 23
Posts: 1180
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

My first Yun conversion went smoothly. But my second one failed (error detailed below). I surmised this was a issues with free space on / (of course that's why I was happy to see this extension scheme). I recalled I was at about 90% before running the conversion script. I removed a couple of packages to get to 83% full on / and re-ran the sketch. It ran correctly.

Bottom line is you may want to ensure you have about 80% free space on / before running this conversion.

Software list updated. Installing software (this will take a while)...
err. installing e2fsprogs mkdosfs fdisk


@roadfun: Good point! thank you!!
I've checked and the 4 software you need to install for this procedure requires around 700KB.
So, I've added a function that checks if you have at least 1MB of free space on the flash memory and stops the procedure if you don't have enough space.

You can find the updated code on github or at zip attached to the tutorial page: http://arduino.cc/en/Tutorial/ExpandingYunDiskSpace
Logged

F

Global Moderator
Milano, Italy
Offline Offline
Edison Member
*****
Karma: 23
Posts: 1180
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

This is a really good idea!
However I would rather just run/tweak the Linux script instead of via the sketch. Any Chance of publishing this? If not, I'll extract it from the sketch myself.

We decided to adopt the "Arduino sketch way" to keep the procedure as simple as possible (means you don't have to deal with the Linux terminal).
I'm sorry but we are not going to publish a Linux bash script with the same commands. However, extracting them form the sketch is very simple.
Logged

F

Italy
Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

the procedure has been easy, thanks but during this I haven't read carefully and I made the Linux partition bigger than I wanted and trying to do the procedure again "arduino" says that the sd is already been prepared/modified..how can I do?

I know I am an asshole, but thanks for answering!
Logged

Pages: [1] 2 3   Go Up
Arduino Forum upgrade scheduled for Monday, October 20th, 11am-4pm (CEST). Sorry for the inconvenience!
Jump to: