Browse Source

describe mounting a USB device

pull/67/head
remotenemesis 3 weeks ago
parent
commit
55684d7423
4 changed files with 71 additions and 6 deletions
  1. 1
    1
      README.md
  2. 55
    0
      hardware/usb-flash-drive.md
  3. 1
    1
      services/nextcloud.md
  4. 14
    4
      services/postgres.md

+ 1
- 1
README.md View File

@@ -51,7 +51,7 @@ If you're not using the [link for beginners](for-beginners/README.md), the follo
51 51
 
52 52
 ## Additional Services
53 53
 
54
-- [Postgresl](services/postgres.md): database server, required for NextCloud, Gitea, Wallabag, and TT-RSS, and other services; helpful if you will be a heavy user of your Lollipop Cloud
54
+- [Postgresql](services/postgres.md): database server, required for NextCloud, Gitea, Wallabag, and TT-RSS, and other services; helpful if you will be a heavy user of your Lollipop Cloud
55 55
 - [Monitoring](armbian/monitoring.md): basic system monitoring
56 56
 - [NextCloud](services/nextcloud.md): file syncing, calendar syncing, contact syncing; an alternative to Dropbox and iCloud
57 57
 - [Syncthing](services/syncthing.md): sync for large numbers or large sized files, an alternative to NextCloud

+ 55
- 0
hardware/usb-flash-drive.md View File

@@ -0,0 +1,55 @@
1
+# Using USB Drives for Storage
2
+
3
+An external USB Drive can be used to supplement internal storage and to reduce the number of writes to the internal Micro SD Card. The low-profile of slimline style USB Flash Drives makes them perfect for use with ARM-based SBCs.
4
+
5
+On some operating systems, like standard Raspian, drives are mounted automatically when they are inserted. These instructions are for operating systems like Raspian Lite where this is not the case.
6
+
7
+## Identify Device
8
+
9
+Without the USB drive inserted run `ls /dev` to list all the currently known devices. Also run `ls /dev/disk/by-uuid` to list all attached disk devices by their UUID. Now insert the USB flash drive and run the same commands again. The device will likely be named something like sda1, sdb1, sdc1, etc. depending on how many other devices are known to the operating system. Note: do not use sda, sdb, sdc, etc. because these are the raw devices. 
10
+
11
+You should now know the device name and UUID for your USB drive. UUIDs are supported to provide a stable identifier for your device regardless of how many other devices were inserted before. 
12
+
13
+You can check you have the correct device by running `sudo fdisk -l | grep /dev/{device-name}` and substituting the correct device name for your USB flash drive. This might be a good time to check the device size is close to what you expect.
14
+
15
+If you are unsure whether you have identified the correct device, remove the USB drive and repeat these steps.
16
+
17
+## Reformat
18
+
19
+Caution: this is a destructive operation that will erase all data from a storage device for practical purposes. Ensure you have the correct device ID before proceeeding!
20
+
21
+USB Flash Drives typically ship with the exFAT filesystem, and often some preinstalled tools.  However, for Lollipop services to best use your device, we recommend you reformat your USB Flash Device with a Linux-native filesystem like EXT4. 
22
+
23
+To format your device using the EXT4 filesystem:
24
+
25
+``` bash
26
+sudo mkfs.ext4 /dev/{device-id}
27
+``` 
28
+
29
+## Mount Device
30
+
31
+To be usable, you must *mount* your device into the filesystem of your computer.
32
+
33
+Create a *mount-point* in your filesystem as a subdirectory from `/media`, perhaps something like this: `sudo mdkir -p /media/usb/device-uuid`. This is the directory you will use to access your storage device. You will need to change the owner of this directory to match the user and group that will own the mount (on Raspian this will usually be *pi*): 
34
+
35
+``` bash
36
+sudo chown -R pi:pi {mount-point}
37
+```
38
+
39
+Next we will need the user ID and group ID for the user that will own the mount. Run the following commands, replacing *user-name* with the name of the user you wish to own the mount (again, on Raspian this will usually be *pi*):
40
+
41
+``` bash
42
+id -u {user-name}
43
+id -g {user-name}
44
+```
45
+
46
+Next edit `/etc/fstab` with your preferred text editor (remember to run with sudo if necessary) and append the following line, subsituting values for device-uuid, mount-point, user-uid and user-gid from the previous steps:
47
+
48
+``` bash
49
+UUID={device-uuid} {mount-point} auto nofail,uid={user-uid},gid={user-gid},noatime 0 0
50
+```
51
+
52
+You can now test whether the drive can be mounted by running `sudo mount -a` to mount all currently unmounted devices. If successful, you should be able to list the contents at the *mount-point* (which should be empty) by running `ls {mount-point}`.
53
+
54
+If successful, now would be a good time to reboot your computer to ensure the device is mounted on boot: `sudo reboot`
55
+

+ 1
- 1
services/nextcloud.md View File

@@ -2,7 +2,7 @@
2 2
 
3 3
 NextCloud in a container. A simple PHP-FPM deployment. You'll need the Web Server container setup to get access. This just gives a very basic, non-web-server version of NextCloud.
4 4
 
5
-*NOTE: You may want to use a filesystem on a USB disk instead of /var for the volumes setup in the below Docker command(s) to help reduce writes to the micro sd card*
5
+*NOTE: You may want to use a filesystem on a [USB drive](../hardware/usb-flash-drive.md) instead of /var for the volumes setup in the below Docker command(s) to help reduce writes to the micro sd card*
6 6
 
7 7
 ## Inspiration / Sources
8 8
 

+ 14
- 4
services/postgres.md View File

@@ -4,10 +4,14 @@ A database for all those awesome services you'll be running.
4 4
 
5 5
 ## Install / Update / Run Script
6 6
 
7
-Setup a generic script that'll auto update , build a container and launch it. You should only run this script at first launch and/or when you're looking for updates.
7
+Setup a generic script that'll auto update, build a container and launch it. You should only run this script at first launch and/or when you're looking for updates.
8
+
9
+If you are running your operating system from a Micro SD Card, You may wish to store your data directory on a [USB drive](../hardware/usb-flash-drive.md) to reduce the number of writes to the SD card. If you do so, don't forget to change the volume mount path when starting the docker container. 
8 10
 
9 11
 ``` bash
10 12
 
13
+# Create directory for postgres to store data. 
14
+# Alternatively, create a directory on a USB drive
11 15
 mkdir -p /var/postgres/data
12 16
 
13 17
 cat > /scratch/docker/postgres.sh << EOF
@@ -17,7 +21,7 @@ VERSION=""
17 21
 
18 22
 ARCH=\`arch\`
19 23
 
20
-# Cleanup arch/container image here
24
+# Cleanup arch/container image here.
21 25
 if [ \$ARCH == "aarch64" ]
22 26
 then
23 27
     echo "64bit arm"
@@ -29,11 +33,16 @@ fi
29 33
 
30 34
 docker pull \$VERSION
31 35
 
32
-# Cleanup existing container
36
+# Cleanup existing container.
33 37
 docker stop postgres
34 38
 docker rm postgres
35 39
 
36
-# Re-run/create container with latest image
40
+# Re-run/create container with latest image.
41
+# Don't forget to change the volume mount path 
42
+# if you changed it above. 
43
+#
44
+# Please change user and password below to something
45
+# approrpriate to your installation.
37 46
 docker run \\
38 47
     --name postgres \\
39 48
     --restart unless-stopped \\
@@ -41,6 +50,7 @@ docker run \\
41 50
     --ip 172.30.12.12 \\
42 51
     -e TZ=UTC \\
43 52
     -e DEBUG=1 \\
53
+    -e POSTGRES_USER=mypostgres
44 54
     -e POSTGRES_PASSWORD=test1234 \\
45 55
     -v /var/postgres/data:/var/lib/postgresql/data \\
46 56
     \$VERSION

Loading…
Cancel
Save