by salafrance » Fri Apr 08, 2016 1:20 pm
I set up one of my Pies as a file server. Filesystems which needed persistence were given to an external, powered, 5.25" drive. Non-persistent filesystems were handed to tmpfs. Everything else was set read-only.
The /boot/cmdline.txt file:
$this->bbcode_second_pass_code('', '
ariane@hermod ~ $ cat /boot/cmdline.txt
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
ariane@hermod ~ $
')
The /etc/fstab file:
$this->bbcode_second_pass_code('', '
######################################################################################################
# a swapfile is not a swap partition, so no using swapon|off from here on, use dphys-swapfile swap[on|off] for that
######################################################################################################
proc /proc proc defaults 0 0
tmpfs /tmp tmpfs nodev,nosuid,size=32M,mode=1777 0 0
tmpfs /var/log tmpfs nodev,nosuid,size=32M,mode=1777 0 0
UUID=e7092694-21b1-4758-b15f-a78bfc0d5b6f /var ext4 defaults,noatime 0 3
/dev/mmcblk0p1 /boot vfat defaults,ro,noatime 0 2
/dev/mmcblk0p2 / ext4 defaults,noatime,ro 0 1
TYPE=swap none swap pri=100 0 0
UUID=9a65d7af-b092-42b8-b126-06432ad52a96 /home ext4 defaults 0 2
UUID=1e99eadb-254e-40de-90d9-c9430eb59933 /media/Elements ext4 defaults 0 4
UUID=98dfc6c9-e4cf-4b81-9bae-05a819dd1d28 /media/Samsung ext4 nosuid,nodev,nofail,auto 0 4
')
Note that I've used device UUIDs to refer to the external drive partitions - this means that I can rely on them being found and mounted correctly regardless of the USB slot into which I plug them.
The swap devices:
$this->bbcode_second_pass_code('', '
ariane@hermod ~ $ swapon -s
Filename Type Size Used Priority
/dev/sdb3 partition 8388604 36 100
/var/swap file 102396 0 -1
ariane@hermod ~ $
')
There are guides which cover this. This system was Raspbian based, but I've made another, Arch-based, Pi read-only as I plan to use it as a Pulse and Bluetooth audio server for other systems. The latter system is much simpler; here's the /boot/cmdline.txt:
$this->bbcode_second_pass_code('', '
[ariane@fafnir qemu]$ cat /boot/cmdline.txt
root=/dev/mmcblk0p2 ro rootwait console=ttyAMA0,115200 console=tty1 selinux=0 plymouth.enable=0 smsc95xx.turbo_mode=N dwc_otg.lpm_enable=0 kgdboc=ttyAMA0,115200 elevator=noop
[ariane@fafnir qemu]$
')
And here's the /etc/fstab:
$this->bbcode_second_pass_code('', '
#
# /etc/fstab: static file system information
#
# <file system> <dir> <type> <options> <dump> <pass>
/dev/mmcblk0p1 /boot vfat defaults,ro,noatime 0 0
tmpfs /var/log tmpfs nodev,nosuid 0 0
tmpfs /var/tmp tmpfs nodev,nosuid 0 0
tmpfs /home/pulse/.config/pulse tmpfs nodev,nosuid,uid=1002,gid=1002 0 0
')