Expand the storage by SD card/USB flash/USB hard drive for Yun & compatible

  1. Put Micro SD card into slot.

  2. Run

wget -O simplesd.sh https://www.dropbox.com/s/jl4oytptxrb6q5u/simplesd.sh?dl=0 --no-check-certificate
/bin/ash simplesd.sh

WARNING
Your SD card will be formatted and you will lose the files it contains. Be sure you have backed it up before using it for expanding Yún’s disk space.

"simplesd.sh" Code:

opkg update
opkg install e2fsprogs fdisk
if fdisk -l |grep /dev/sda > /dev/null; then
    echo "Start"
else
    echo "/dev/sda not found!"
    exit 0
fi
dd if=/dev/zero of=/dev/sda bs=4096 count=10
(echo n; echo p; echo 1;  echo;  echo; echo w)  | fdisk /dev/sda
umount -f  /mnt/sda1
mkfs.ext4 /dev/sda1
mkdir -p /mnt/sda1
mount  /dev/sda1 /mnt/sda1
mkdir -p /tmp/cproot
mount --bind / /tmp/cproot
tar -C /tmp/cproot -cvf - . | tar -C /mnt/sda1 -xf -
umount /tmp/cproot
uci add fstab mount
uci set fstab.@mount[0].target=/
uci set fstab.@mount[0].device=/dev/sda1
uci set fstab.@mount[0].fstype=ext4
uci set fstab.@mount[0].enabled=1
uci set fstab.@mount[0].enabled_fsck=0
uci set fstab.@mount[0].options=rw,sync,noatime,nodiratime
uci commit
reboot

In case fresh OS is needed:

Run following before expand the storage memory.

reset-to-factory-anyway
reboot

Revision script:

opkg update
opkg install bash
wget -O expand.sh https://www.dropbox.com/s/x2zhfqr4ssfetz1/expand.sh?dl=0 --no-check-certificate

for micro SD card:

/bin/bash expand.sh

or

/bin/bash expand.sh sda

for USB flash:

/bin/bash expand.sh sdb

for USB hard disk

/bin/bash expand.sh sdc

"expand.sh" code:

if [ -n "$1" ]; then
device=$1
else
device="sda"
fi
driver=$device"1"
opkg update
opkg install e2fsprogs fdisk
if fdisk -l |grep /dev/$device > /dev/null; then
    echo "Start"
else
    echo "/dev/$device not found!"
    exit 0
fi
dd if=/dev/zero of=/dev/$device bs=4096 count=10
(echo n; echo p; echo 1;  echo;  echo; echo w)  | fdisk /dev/$device
umount -f  /mnt/$driver
mkfs.ext4 /dev/$driver
mkdir -p /mnt/$driver
mount  /dev/$driver  /mnt/$driver
mkdir -p /tmp/cproot
mount --bind / /tmp/cproot
tar -C /tmp/cproot -cvf - . | tar -C /mnt/$driver  -xf -
umount /tmp/cproot
uci add fstab mount
uci set fstab.@mount[0].target=/
uci set fstab.@mount[0].device=/dev/$driver
uci set fstab.@mount[0].fstype=ext4
uci set fstab.@mount[0].enabled=1
uci set fstab.@mount[0].enabled_fsck=0
uci set fstab.@mount[0].options=rw,sync,noatime,nodiratime
uci commit
reboot

Remove SD card entry at fstab:

nano removesd.sh
#!/bin/ash
/sbin/uci delete fstab.@mount[0]
/sbin/uci commit fstab
/sbin/uci show fstab
/bin/ash removesd.sh

For USB flash size >= 64GB here is revision code.

wget -O newexpand.sh https://www.dropbox.com/s/jnrwhrc0dhjynyp/newexpand.sh?dl=0 --no-check-certificate
/bin/bash newexpand.sh sdb

When use External USB Hard Drive:

USB Y Cable for External Hard Drive is needed.

sonnyyu:
When use External USB Hard Drive:

USB Y Cable for External Hard Drive is needed.

Not necessarily (anymore). Most recent drives an perfectly be powered with a single (500mA) USB 2.0 port. The only catch might be if you are trying to power a USB 3.0 drive (with the two-part micro plug) from a regular USB 2.0 port and the drive draws more than 500mA, and in that case your Y-cable isn't an option from the start (and I am not aware of any 3.0 Y-cables)...

Of course as soon as I posted the above, I found that there are micro-USB 3.0 cables with a Y USB 2.0 set of plugs.

Ralf

PCWorxLA:
Not necessarily (anymore). Most recent drives an perfectly be powered with a single (500mA) USB 2.0 port. The only catch might be if you are trying to power a USB 3.0 drive (with the two-part micro plug) from a regular USB 2.0 port and the drive draws more than 500mA, and in that case your Y-cable isn't an option from the start (and I am not aware of any 3.0 Y-cables)...

Ralf

Yun compatible answer is Yes.
Yun, since its USB only output 4.5 V at USB V+, Y-cables is mandatory.

Expand the storage by USB flash for Dragino:

opkg update
opkg install bash
opkg install wget
wget -O newexpand.sh https://www.dropbox.com/s/jnrwhrc0dhjynyp/newexpand.sh?dl=0 --no-check-certificate
/bin/bash newexpand.sh sda

Low-Profile Flash Drive:

Is there a difference in performance between USB Drive vs. SD Card?

From I learned for reading speed USB Drive beat SD Card, for writing speed is close.

sonnyyu:
Yun compatible answer is Yes.
Yun, since its USB only output 4.5 V at USB V+, Y-cables is mandatory.

But using a Y cable doesn't increase the possible voltage, it will only allow for a higher drawn amperage...

Ralf

PCWorxLA:
But using a Y cable doesn't increase the possible voltage, it will only allow for a higher drawn amperage...

Ralf

I don't think Y cable is going to offer load balance here, It is more less USB Power Inject.

An other looking feel type USB Power Injector:

Recover bricked expanded Yun

turn off
take micro SD out
turn on

reset-to-factory-anyway
reboot

after Yun complete started
turn off
put micro SD back
turn on

wget -O simplesd.sh https://www.dropbox.com/s/jl4oytptxrb6q5u/simplesd.sh?dl=0 --no-check-certificate
/bin/ash simplesd.sh

Revert back to boot from internal flash:

wget -O reset.sh https://www.dropbox.com/s/4g1yfpnas25cepn/reset.sh?dl=0 --no-check-certificate
/bin/ash reset.sh
nano reset.sh
/bin/mkdir -p /mnt/mtdblock3
/bin/mount -t jffs2 /dev/mtdblock3 /mnt/mtdblock3
/usr/bin/head -n 9  /mnt/mtdblock3/etc/config/fstab > /tmp/fstab
/bin/mv /tmp/fstab /mnt/mtdblock3/etc/config/
/sbin/reboot

wget -O simplesd.sh Dropbox - simplesd.sh - Simplify your life --no-check-certificate
/bin/ash simplesd.sh


result after running it:
./.gnupg/secring.gpg
./.extroot.md5sum
cfg044d78
root@Arduino:~# Write failed: Broken pipe
Monas-MacBook-Pro:~ mona$ ssh root@192.168.1.148
ssh: connect to host 192.168.1.148 port 22: Host is down

What should I do now?

lamiastella:
wget -O simplesd.sh Dropbox - simplesd.sh - Simplify your life --no-check-certificate
/bin/ash simplesd.sh


result after running it:
./.gnupg/secring.gpg
./.extroot.md5sum
cfg044d78
root@Arduino:~# Write failed: Broken pipe
Monas-MacBook-Pro:~ mona$ ssh root@192.168.1.148
ssh: connect to host 192.168.1.148 port 22: Host is down

What should I do now?

192.168.1.148 is wifi's ip address or ethernet address?

after run simplesd.sh the Yun will be back to factory default state, i.e. ethernet port has ip address from system router DHCP release pool and wifi port has "192.168.240.1". The WIFI port is at ap for Access Point mode.