created: 20150511071117085 creator: user modified: 20171002210116759 modifier: user tags: docker [[raspberry pi]] title: use usb stick with docker type: text/vnd.tiddlywiki move current pi stuff ```bash rsync -aSHAXP --info=progress2 --delete /mnt /home/pi ``` moving existing docker graph ```bash rsync -aSHAXP --info=progress2 --delete /var/lib/docker /mnt/usb ``` ; Full system backup with rsync : https://wiki.archlinux.org/index.php/full_system_backup_with_rsync ```bash mke2fs -T ext4,news -L docker -v /dev/sda ``` $ cat /etc/default/docker ```sh # Docker Upstart and SysVinit configuration file # Customize location of Docker binary (especially for development testing). #DOCKER="/usr/local/bin/docker" # Use DOCKER_OPTS to modify the daemon startup options. DOCKER_OPTS="--storage-driver=overlay -D --dns 192.168.22.22 --graph=/mnt/usb/docker --log-driver=syslog --log-opt syslog-address=udp://192.168.22.22:514 --log-opt syslog-format=rfc5424" # If you need Docker to use an HTTP proxy, it can also be specified here. export http_proxy="http://192.168.2.1:3128/" # This is also a handy place to tweak where Docker's temporary files go. #export TMPDIR="/mnt/bigdrive/docker-tmp" export TMPDIR=/mnt/usb/docker-tmp" ``` $ cat /etc/systemd/system/docker.service.d/overlay.conf ``` [Service] ExecStart= ExecStart=/usr/bin/dockerd --storage-driver overlay -D --graph=/mnt/usb/docker --log-driver=syslog --log-opt syslog-address=udp://nas.aiko.sh:514 --log-opt syslog-format=rfc5424 -H fd:// Environment="HTTP_PROXY=http://192.168.22.22:3128/" "TMPDIR=/mnt/usb/docker-tmp" ``` ``` systemctl daemon-reload ``` ```bash mkdir -p /mnt/usb/docker /mnt/usb/docker-tmp ``` ``` $ ls -lathr /dev/disk/by-uuid/ ``` ``` $ cat /etc/fstab proc /proc proc defaults 0 0 /dev/mmcblk0p1 /boot vfat defaults 0 0 /dev/mmcblk0p2 / ext4 noatime 0 1 UUID=16e0972d-6abf-4369-be0e-5fd2e10a070a /mnt/usb ext4 commit=600,noatime 0 0 #none /var/run tmpfs size=1M,noatime 0 0 none /var/log tmpfs size=1M,noatime 0 0 none /var/tmp tmpfs size=1M,noatime 0 0 none /tmp tmpfs size=12M,noatime 0 0 ``` ``` tune2fs -c 1 /dev/disk/by-uuid/16e0972d-6abf-4369-be0e-5fd2e10a070a ``` !!Logging vi /etc/rsyslog.conf ``` $ActionFileDefaultTemplate RSYSLOG_SyslogProtocol23Format ############### #### RULES #### ############### *.* @192.168.22.22:514 ``` vi /etc/systemd/journald.conf ``` [Journal] Storage=none #Storage=auto ``` !! Backup ``` HypriotOS/armv7: pirate@pi47.aiko.sh in ~ $ cat /etc/cron.daily/backup #!/usr/bin/env bash docker run --rm=true --env-file=/mnt/usb/pi/aws.env -e SILO=pi47_data -e BACKUP_PATH=/data --volume=/mnt/usb/pi/data:/data:ro aiko/backup >> /var/log/cron.log #docker run -i -t --rm=true --env-file=/mnt/usb/pi/aws.env -e SILO=pi47_data -e BACKUP_PATH=/data --volume=/mnt/usb/pi/data:/data:ro aiko/backup >> /var/log/cron.log # docker run -d --env-file=/mnt/usb/pi/aws.env -e SILO=pi47_data -e BACKUP_PATH=/data --volume=/mnt/usb/pi/data:/data:ro aiko/backup ```