Uploading tracks via ftp/sftp

Suggestions/requests/ideas for RuneAudio core features and functions

Uploading tracks via ftp/sftp

Postby davidemania » 14 Dec 2014, 17:33

Is it possible to upload (and manage) tracks to an USB mass memory device via FTP or SFTP? I tried but it seems the device (in my case a 16GB USB stick) is mounted in read only, and I couldn't modify anything on it.

It would be nice to be able to manage the music library without having to open the box and physically remove the stick from the board (a raspberry Pi) and connect it to a computer. I tried to unmount the USB drive from the UI but apparently nothing happens after trying that.

I am quite new to rune audio so may be I am just missing something obvious. Any hint?

thanks
Davide
Last edited by davidemania on 15 Dec 2014, 14:28, edited 1 time in total.
davidemania
 
Posts: 22
Joined: 14 Dec 2014, 17:26

Re: Uploading tracks via fts/sftp

Postby ACX » 14 Dec 2014, 18:22

A slightly dirty but effective way to achieve that in the current state of our implementation is to create a dir inside /mnt/MPD/USB and put your media files inside there via SFTP. After you update MPD's database, the folder will be listed clicking on the "USB storage" block in the Library home screen.
User avatar
ACX
RuneAudio co-founder
 
Posts: 1685
Joined: 29 Nov 2013, 02:25
Location: Udine, Italy

Re: Uploading tracks via fts/sftp

Postby davidemania » 14 Dec 2014, 20:39

I'll try that, but where will the files go? On the USB stick? And what if I have more than one?

By the way, since there is lot of free space on the main SD card (mine actually is a 16GB one), is it possible to put it to a good use and load some music there?
davidemania
 
Posts: 22
Joined: 14 Dec 2014, 17:26

Re: Uploading tracks via fts/sftp

Postby ACX » 15 Dec 2014, 02:38

The solution I suggested you is meant for placing files on the SD, you only have to create the new dir in /mnt/MPD/USB to be able to browse it through the UI then (at least with the current implementation).
User avatar
ACX
RuneAudio co-founder
 
Posts: 1685
Joined: 29 Nov 2013, 02:25
Location: Udine, Italy

Re: Uploading tracks via fts/sftp

Postby davidemania » 15 Dec 2014, 11:15

OK this works, and looks like the perfect solution to both problems. But the bulk of SD card is not allocated to any partition (I have a small 94,4MB FAT partition, a 1,78GB one that's the main one with the OS and 13,84GB of unallocated space).

Here are the steps I had to follow in order to make the free space accessible:

1) Remove the SD and using gparted on a linux PC format the partition (I used ext2 but other formats should be fine too). I am quite sure that this could also be done with mkfs via ssh without removing the SD, but did not try that.

2) insert the SD and have a look at the partition table with fdisk -l

Code: Select all
[root@runeaudio ~]# fdisk -l     

Disk /dev/mmcblk0: 14.7 GiB, 15720251392 bytes, 30703616 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00083364

Device         Boot   Start      End  Sectors  Size Id Type
/dev/mmcblk0p1         2048   186367   184320   90M  c W95 FAT32 (LBA)
/dev/mmcblk0p2       186368  3667967  3481600  1.7G  5 Extended
/dev/mmcblk0p3      3667968 30703615 27035648 12.9G 83 Linux
/dev/mmcblk0p5       188416  3667967  3479552  1.7G 83 Linux


Note which one is the partition you just created, here the Device Name is "/dev/mmcblk0p3"

3) Create a mountpoint for the new partition, like this

Code: Select all
mkdir /mnt/MPD/USB/SD\ Card/


4) Modify /etc/fstab to make the new partition mount at boot

write
Code: Select all
nano /etc/fstab


then add the following line

Code: Select all
/dev/mmcblk0p3  /mnt/MPD/USB/SD\040Card ext2       noatime,rw          0       0


check that the name "mmcblk0p3" name matches with the one we got at step 2, to be sure we are mounting the correct partition

Note: the \040 is the octal code to use in place of "space" in files or directory names while in fstab.

exit from nano (ctrl-X, y to save) then reboot (just type "reboot") and wait. You should be able to see the new partition listed under USB STORAGE in RuneUI. Now you can upload and manage audio files over wi-fi or wired network using any SFTP/SCP client. I succesfully used Cyberduck.

Do not forget to click "Update this folder" in RuneUI after you uploaded/changed your files.

The picture shows the new folder in RuneUI, "XVI GIGA" is a USB stick. It is now possible to flawlessly use both storages. May be you could try formatting the partition using FAT in place of ext2, to be able to write to it using windows. Should work, in theory.

Schermata 2014-12-15 alle 11.11.43.png
Schermata 2014-12-15 alle 11.11.43.png (44.8 KiB) Viewed 6121 times
davidemania
 
Posts: 22
Joined: 14 Dec 2014, 17:26

Re: Uploading tracks via fts/sftp

Postby ACX » 15 Dec 2014, 13:34

Thank you for reporting the detailed steps you followed, which could be useful for future readers.
User avatar
ACX
RuneAudio co-founder
 
Posts: 1685
Joined: 29 Nov 2013, 02:25
Location: Udine, Italy

Re: Uploading tracks via ftp/sftp

Postby hondagx35 » 15 Dec 2014, 21:48

Hi davidemania,

thank you for the detailed how-to.
There is also a hidden feature in RuneAudio that may be interesting in this context.

Mount your new partition under the folder "LocalStorage"
Code: Select all
/dev/mmcblk0p3  /mnt/MPD/LocalStorage ext2       noatime,rw          0       0

and you'll get a new entry in your library page.

1.jpg
1.jpg (91.13 KiB) Viewed 6106 times
User avatar
hondagx35
 
Posts: 3039
Joined: 11 Sep 2014, 22:06
Location: Germany

Re: Uploading tracks via ftp/sftp

Postby davidemania » 16 Dec 2014, 13:31

cool :)
davidemania
 
Posts: 22
Joined: 14 Dec 2014, 17:26

Re: Uploading tracks via ftp/sftp

Postby davidemania » 27 Dec 2014, 14:03

I am also using a workaround to write to the USB stick via wi-fi. Not the cleanest way I am afraid but it works, and saves me from opening the box, unplugging the stick etcetera ;)

First boot the system, but make sure there is no Rune UI client connected (ie no active browsers talking with Rune Audio), then login via ssh as usual

Then check the name currently being use for your stick, like this:

Code: Select all
[root@runeaudio ~]# mount
.....
/dev/sda1 on /mnt/MPD/USB/MUSICA type vfat (ro,nosuid,nodev,noexec,noatime,uid=45,gid=45,fmask=0022,dmask=0022,codepage=437,iocharset=utf8,shortname=mixed,errors=remount-ro)


as you can see it is mounted as a readonly file system ("ro"). Unmount the stick

Code: Select all
 umount /dev/sda1


then remount it in read/write mode

mount --rw /dev/sda1 /mnt/MPD/USB/MUSICA/


of course changing the paths to match your filenames. Check that the stick is now writeable:

Code: Select all
[root@runeaudio ~]# mount
....
/dev/sda1 on /mnt/MPD/USB/MUSICA type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)


It should now be possible to upload new files with your favorite sftp client as we did for the internal SD storage. Update the folder via RuneUI and enjoy your music :)

Eventually it won't hurt to umount the stick and remount it readonly as it was before, or just wait until next reboot

May be there is a quicker/simpler way for the whole process but not that I'm aware of. Could be handy to put the abovementioned commands into a script to speed up things if you need it frequently. A question for the devs: are the other settings (nosuid,nodev,noexec,noatime,uid=45,gid=45,fmask=0022,dmask=0022,codepage=437,iocharset=utf8,shortname=mixed,errors=remount-ro) mandatory? If so they can be included in the mount command, and in any case a reboot should reset them.
davidemania
 
Posts: 22
Joined: 14 Dec 2014, 17:26

Re: Uploading tracks via ftp/sftp

Postby aj78 » 27 Dec 2014, 19:16

Another command which may be of interest to make use of unused space on the SD card is resize2fs. This resizes the filesystem, and can be used while the filesystem is online (i.e. no need to unmount it). First you have to use fdisk to resize the partition to fill the whole SD card. You can do this by doing "fdisk /dev/mmcblk0". Press "p" to show the current partitions and note down the details of the main one that RuneOS is on. Then delete it! (Press "d" and choose the relevant partition number.) Then press "n" to make a new partition, and "p" to select a primary partition. Enter the same start block that you wrote down above, and allow it to use the default end block (the last block available on the device). Now press "t" and enter the value "82" to mark it as a Linux partition. Finally press "w" to write changes and exit. You may have to reboot after this for changes to be registered. This has resized the partition, but not yet the filesystem.

Next, use the command "resize2fs /dev/mmcblk0p0" (or /dev/mmcblk0p1 if the main RuneOS partition was mmcblk0p1). This will resize the filesystem to fill the whole partition, and hey presto you have a lot more space available for stuff.
aj78
 
Posts: 51
Joined: 29 Oct 2014, 20:42

support RuneAudio Donate with PayPal

Next

Return to Feature request

Who is online

Users browsing this forum: No registered users and 0 guests