kemonine
/
lollipopcloud
Archived
1
0
Fork 0

describe mounting a USB device

This commit is contained in:
remotenemesis 2019-01-28 21:55:31 -08:00
parent 195f3047af
commit 55684d7423
4 changed files with 71 additions and 6 deletions

View File

@ -51,7 +51,7 @@ If you're not using the [link for beginners](for-beginners/README.md), the follo
## Additional Services
- [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
- [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
- [Monitoring](armbian/monitoring.md): basic system monitoring
- [NextCloud](services/nextcloud.md): file syncing, calendar syncing, contact syncing; an alternative to Dropbox and iCloud
- [Syncthing](services/syncthing.md): sync for large numbers or large sized files, an alternative to NextCloud

View File

@ -0,0 +1,55 @@
# Using USB Drives for Storage
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.
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.
## Identify Device
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.
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.
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.
If you are unsure whether you have identified the correct device, remove the USB drive and repeat these steps.
## Reformat
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!
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.
To format your device using the EXT4 filesystem:
``` bash
sudo mkfs.ext4 /dev/{device-id}
```
## Mount Device
To be usable, you must *mount* your device into the filesystem of your computer.
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*):
``` bash
sudo chown -R pi:pi {mount-point}
```
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*):
``` bash
id -u {user-name}
id -g {user-name}
```
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:
``` bash
UUID={device-uuid} {mount-point} auto nofail,uid={user-uid},gid={user-gid},noatime 0 0
```
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}`.
If successful, now would be a good time to reboot your computer to ensure the device is mounted on boot: `sudo reboot`

View File

@ -2,7 +2,7 @@
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.
*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*
*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*
## Inspiration / Sources

View File

@ -4,10 +4,14 @@ A database for all those awesome services you'll be running.
## Install / Update / Run Script
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.
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.
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.
``` bash
# Create directory for postgres to store data.
# Alternatively, create a directory on a USB drive
mkdir -p /var/postgres/data
cat > /scratch/docker/postgres.sh << EOF
@ -17,7 +21,7 @@ VERSION=""
ARCH=\`arch\`
# Cleanup arch/container image here
# Cleanup arch/container image here.
if [ \$ARCH == "aarch64" ]
then
echo "64bit arm"
@ -29,11 +33,16 @@ fi
docker pull \$VERSION
# Cleanup existing container
# Cleanup existing container.
docker stop postgres
docker rm postgres
# Re-run/create container with latest image
# Re-run/create container with latest image.
# Don't forget to change the volume mount path
# if you changed it above.
#
# Please change user and password below to something
# approrpriate to your installation.
docker run \\
--name postgres \\
--restart unless-stopped \\
@ -41,6 +50,7 @@ docker run \\
--ip 172.30.12.12 \\
-e TZ=UTC \\
-e DEBUG=1 \\
-e POSTGRES_USER=mypostgres
-e POSTGRES_PASSWORD=test1234 \\
-v /var/postgres/data:/var/lib/postgresql/data \\
\$VERSION