How to mount a USB to store the waveform archiveΒΆ

This brief tutorial explains how to mount your SeisComP Data Structure (SDS) continuous miniSEED waveform archive on an external USB stick. In this example, we use ext4 but you can use any file system that your OS supports.

Why you might be interested in using this configuration:

  • You need more space than the microSD card allows (currently, SLC microSD cards max out at 4 GB and MLC at 8 GB)
  • You want to be able to recover the waveform data even if the microSD card fails, so you have purchased an industrial USB to ensure data recovery
  • You want to limit writes to the microSD in order to lower chances of microSD card failure
  • Some combination of the above or something we have not thought of yet

To mount the waveform file directory to the USB, follow these steps:

  1. Plug your USB into your Raspberry Shake

  2. SSH into your Raspberry Shake and run this command to discover if your USB was recognized by Raspberry Shake’s OS:

    $ sudo dmesg -T
    

At the end of the output you should see something like:

mon may 28 19:37:48 2018] sd 4:0:0:3: [sda] Attached SCSI removable disk
mon may 28 19:37:48 2018]  sda: sda1

The output will be different according to your USB, RPi model and/ or the USB port that are you using.

  1. Now you need to create a partition for this USB.

The following commands will erase all of your USB data / partitions

$ sudo fdisk /dev/sda

Welcome to fdisk (util-linux 2.25.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

$ Command (m for help):

Now, press the ‘o’ key

$ Command (m for help): o
Created a new DOS disklabel with disk identifier 0x00000000.

Now we will create a new primary partition, using the ‘n’ key.

$ Command (m for help): n
 Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)

Choose ‘p’ primary partition.

$ Select (default p): p

Now the partition number. Use default 1.

$ Partition number (1-4, default 1): 1

Now press ‘enter’ twice or you can adjust the size of your partition.

First sector (2048-15728639, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-15728639, default 15728639):

Created a new partition 1 of type 'Linux' and of size 7.5 GiB.

Now we need to write ‘w’ the changes to the USB

$ Command (m for help): w
  The partition table has been altered.
  Calling ioctl() to re-read partition table.
  Syncing disks.

The partition is now ready. We can proceed to format the partition,

$  sudo mkfs.ext4 /dev/sda1

Now the system will format the partition. You should see something like:

Creating filesystem with 1965824 4k blocks and 491520 inodes
Filesystem UUID: 7dc7d63f-9fe0-4d27-bf31-8e14459d460f
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information:
done
  1. The next step will be tuning the microSD card performance using this commands

    $ sudo tune2fs -o journal_data_writeback /dev/sda1
    

The output should be:

tune2fs 1.42.12 (29-Aug-2014)

Now,

$ sudo tune2fs -O ^has_journal /dev/sda1

The output should be:

tune2fs 1.42.12 (29-Aug-2014)

Now,

$ sudo e2fsck -f /dev/sda1

And the output:

e2fsck 1.42.12 (29-Aug-2014)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sda1: 11/491520 files (0.0% non-contiguous), 35175/1965824 blocks
  1. Your USB is ready for action. To mount the USB, we need to stop the Raspberry Shake software services:

    $ sudo systemctl stop rsh-data-producer.service
    $ sudo systemctl stop rsh-data-consumer.service
    

Then, to mount the USB to where the waveform SDS archive lives (/opt/data/archive):

$ sudo mount -t ext4 -O noatime,data=writeback /dev/sda1 /opt/data/archive

Now check to see if the partition was mounted successfully:

$ df -h | grep sda1

The output should be like:

$ /dev/sda1       7.4G   17M  7.0G   1% /opt/data/archive
  1. Now we need to start Raspberry Shake software services:

    $ sudo systemctl start rsh-data-producer.service
    $ sudo systemctl start rsh-data-consumer.service
    
If you do not see any “err” message, then the procedure was successful.
  1. To automate the mounting of the waveform archive to the USB at startup, you need to adjust /etc/fstab:

    $ sudo nano /etc/fstab
    

At the end of the file put the string

/dev/sda1       /opt/data/archive       ext4    noatime,data=writeback

Now reboot:

$ sudo reboot

That’s all. The waveform archive will now be stored on the USB.

Warning

If you need to extract the USB, please stop the software services and unmount the USB first:

$ sudo systemctl stop rsh-data-consumer.service
$ sudo systemctl stop rsh-data-producer.service
$ sudo umount /opt/data/archive
$ sudo reboot