[Unfortunately, the following method cannot be used as is for Arch or Pidora, which symlink /bin
, /sbin
, and /usr/bin
. See comments. It will work for Raspbian.]
If you're installing rails and nginx from raspbian packages, moving /home
is not going to make that much difference because they're not being put there. So you will end up with no space left on the 2GB partition and a near empty 16 GB partition.
I'm presuming you have another linux system on which you can mount both devices (the card and the stick). You cannot do this from the pi itself while the system is running. First, undo whatever you did to move /home
and, if there's no room to put it back on the SD card right now, put it somewhere else temporarily. You want the partition on the stick empty.
More than half of the space is probably taken up by stuff in /usr
(that should be where rails and nginx go). du -h /usr
will demonstrate that; I have ~3.4 GB on the SD card and 1.7 GB of that is in /usr
. That's what you should move to the stick. I'll refer to the stick as /mnt/stick
and the card as /mnt/card
. I've also left out sudo
in the instructions below; hopefully you can sort out the need for that (I prefer to just do this kind of thing su root
).
Copy /usr
to the ext4 partition on the stick:
cp -a /mnt/card/usr/* /mnt/stick/
Note you don't want to move the directory stub (usr
) itself. You just want what's inside (directories: bin games include lib local sbin share src
). Be certain that worked (you don't have to check too hard, just look to see if the directories are there and there's stuff in them). Now delete the original:
rm -fr /mnt/card/usr/*
Make sure that worked too. /mnt/card/usr
should now be empty.
Get the UUID of the stick partition. You need to know the device node it's currently using. If it's /dev/sdb1
:
> blkid /dev/sdb1
/dev/sdb1: UUID="ae6c22c6-aafd-11e3-bf7a-6b21bc3e493c" TYPE="ext4"
That output is an example. If it doesn't have a UUID, you need to give it one. Check to see if the system you are using has uuid
or uuidgen
on it; if not install one or the other (search for a package with "uuid" in the title, it should be obvious). Make sure it works (all it has to do is produce that random token). Now:
tune2fs /dev/sdb1 -U `uuid`
Notice the backticks around uuid
; this appends its output. If you're not sure about that just run it and copy paste the UUID (e.g. tune2fs /dev/sdb1 -U ae6c22c6-aafd-11e3-bf7a-6b21bc3e493c
).
Add a line to /mnt/card/etc/fstab
:
UUID=[that UUID] /usr ext4 defaults,noatime 0 3
The last number presumes there's a 1 and 2 already in that column (see man fstab
for details).
That's it; put the card and the stick in the pi and try it out. The other thing you will want to think about is where rails, etc, keeps data. If you want that kind of stuff on the stick too, the easiest method is create a /usr/link
into which you can copy whatever other subdirectories -- e.g., /var/rails_stuff
. Copy that that in, delete the original (including the directory stub this time), and then ln -s /usr/link/rails_stuff /var/rails_stuff
. You can do this with whatever from /home
(or all of /home
) too if you want. This can be done on the pi while the system is running.