1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

volman: an experimental FreeBSD volume manager

Discussion in 'Porting New Software' started by aragon, Oct 24, 2011.

  1. aragon

    aragon New Member

    Messages:
    2,031
    Thanks Received:
    252
    Hi,

    A while ago I wrote [thread=23105]an elaborate shell script[/thread] to provide HAL-style disk mounting in Openbox (still my favourite WM btw). Personally it's been really successful for my own use, and I get the impression others have liked it too. Well I've been tweaking it here and there, and it's now an even more elaborate shell script, but it's at the point where I think it can serve as a generic FreeBSD volume manager for more than just Openbox.

    It still lacks a client for KDE/Gnome/XFCE type environments, but I decided to put up what I've written so far in the hope someone will write a client for the above. I haven't used those desktop environments for a while, and don't plan to anytime soon, so I figured it's best someone else called the shots on how such a client should work!

    The CLI and Openbox clients are rewritten for the new client/server architecture, and they function in much the same way as before. And yes, I changed the name of it again! I felt the old name was too misleading as this technically is not an auto-mounting thingie. (unless someone writes a client to do just that)

    It's in the PR database for now: PR ports/161977.

    Hopefully this one will get committed!

    In addition to the new architecture, NTFS3G aka read/write NTFS support is now done! Sudo is also no longer needed, and a configuration file with some options has been added. In total this supports UFS, EXT2, FAT32, and NTFS. Only USB based storage devices have been tested by me.
     
    martino, brigante, swa and 6 others thank for this.
  2. aragon

    aragon New Member

    Messages:
    2,031
    Thanks Received:
    252
    [reserved for documentation]
     
  3. wblock@

    wblock@ Administrator Staff Member Administrator Moderator Developer

    Messages:
    11,556
    Thanks Received:
    2,223
  4. G_Nerc

    G_Nerc New Member

    Messages:
    122
    Thanks Received:
    11
    Aragon, thanks a lot for your script!
    But i can't understand how it setup to work properly.
    I do:
    extract ports/161977 in /usr/ports/sysutils
    # cd /usr/ports/sysutils/volman && make install clean
    After install i'm add to rc.conf
    Code:
    volmand_enable="YES"

    and
    # cp /usr/local/etc/volman.conf.example /usr/local/etc/volman.conf
    and edit it:
    Code:
    # What device names amountd must look for.
    DEVMATCH="^(da|mmcsd)"
    
    # What label names amountd must look for.
    LABELMATCH="^(msdosfs|ntfs|ufs)/"
    
    # Base directory into which volumes will be mounted.
    MNTPREFIX=/media
    
    # If YES, subdirectories below MNTPREFIX will always match the device name.
    # Otherwise the volume's label will be used if it exists.
    DEVMPOINT=NO
    
    # Where amount keeps all its working data and FIFOs.
    WRKDIR=/var/tmp/volman
    

    after that i'm do
    # /usr/local/etc/rc.d/volmand start
    and insert flash disk
    # tail /var/log/messages
    Code:
    Nov  5 00:11:13 OLD-BSD volmand: CREATE da1
    Nov  5 00:11:13 OLD-BSD kernel: ugen0.5: <vendor 0x13fe> at usbus0
    Nov  5 00:11:13 OLD-BSD kernel: umass1: <vendor 0x13fe USB DISK 2.0, class 0/0, rev 2.00/1.00, addr 5> on usbus0
    Nov  5 00:11:13 OLD-BSD kernel: da1 at umass-sim1 bus 1 scbus7 target 0 lun 0
    Nov  5 00:11:13 OLD-BSD kernel: da1: < USB DISK 2.0 PMAP> Removable Direct Access SCSI-0 device 
    Nov  5 00:11:13 OLD-BSD kernel: da1: 1.000MB/s transfers
    Nov  5 00:11:13 OLD-BSD kernel: da1: 3825MB (7834944 512 byte sectors: 255H 63S/T 487C)
    Nov  5 00:11:14 OLD-BSD volmand: CREATE da1s1
    

    but not in /media or anywhere else and in output of df not appears new device.
    I have a
    Code:
    vfs.usermount=1
    what i do wrong?
    Maybe problem in that my flash disk uses FAT32 with locale CP1251, or it LABEL have cyrillic symbols in that codepage?

    My OS is FreeBSD 9.0 RC1
     
  5. aragon

    aragon New Member

    Messages:
    2,031
    Thanks Received:
    252
    Usermount not needed.


    Type vmount. It should show you a list of devices that have been detected, and their mount status. Once you see the one you want to mount:

    $ vmount da1s1

    And the same when you want to umount it.


    See what happens, and let us know. :)
     
  6. G_Nerc

    G_Nerc New Member

    Messages:
    122
    Thanks Received:
    11
    Yes it works! Thanks a lot!
    But i have some request :)
    1. Maybe add in conf file option with ability to automount devices?
    2. And add options like mount_script [script to execute when mounts new device] (for example with that script will be easy integrate volman with idesk & fluxbox. Insert flash and icons for it appears), similar with umount_script
    3. And option to set prefered codepage. Because my flash disk after $ vmount da1s1 shows files in russian like ???????.pdf (Without volman i use for mounting such command # mount_msdosfs -L ru_RU.UTF-8 -D CP866 /dev/da0s1 /mnt/flash)
     
  7. aragon

    aragon New Member

    Messages:
    2,031
    Thanks Received:
    252
    Great! Welcome.

    For it to work that way would violate volman's design, and probably break things. The same can be achieved by writing a client daemon that does all that with the help of volman's API, which I'll hopefully get around to documenting soon. :p

    I'll try hoof that into the API in the next version, but the client implementation I'm not sure about. How would you want to specify the code page?
     
  8. G_Nerc

    G_Nerc New Member

    Messages:
    122
    Thanks Received:
    11
    I think it is need such options (as i see in volman script it will be one more option ${MNTOPTS_${3}} (-L ${LOCAL_CODEPAGE} -D ${FAT32_CODEPAGE} in my example with my FAT32 flash) for every mounted entry like ${MNTCMD_${3}})
    Code:
    LOCAL_CODEPAGE=ru_RU.UTF-8 (codepage for local system UTF-8 by default)
    FAT32_CODEPAGE=CP866 (preferred codepage for mounted FAT32 disks)
    NTFS_CODEPAGE=CP1251 (preferred codepage for mounted NTFS disks)
    and etc for other supported FS

    Maybe sorry for my piece of nonsense with option description :))
     
  9. plamaiziere

    plamaiziere New Member

    Messages:
    184
    Thanks Received:
    39
    Code:
    XMNTCMD_msdosfs="mount_msdosfs -m 666 -M 777"
    XMNTCMD_ext2fs="mount -t ext2fs"
    XMNTCMD_ufs="mount -t ufs"
    


    You should auto-mount external storages with nosuid at least.

    I don't think it's safe to auto-mount without checking that the user is able to do this (may be via a group ?)

    Regards
     
  10. aragon

    aragon New Member

    Messages:
    2,031
    Thanks Received:
    252
    Added to my todo list. :)


    I need to nitpick and say that no auto mounting is taking place. It's all manual. The only difference is that it's abstracted away into a highly simplified command.

    But I agree there might be room for loss of security. I don't know if I will implement authorization checks though. It's a simple fix to a simple problem and is a 3rd party port with an appropriate disclaimer that'll be installed by FreeBSD users with enough savvy to configure an X11 setup from scratch.
     
  11. bigtoque

    bigtoque New Member

    Messages:
    75
    Thanks Received:
    5
    The script seems to work quite well. Many thanks!

    One thing I've noticed (in openbox at least) is that if the device is connected when the system boots, the openbox menu just shows "No devices". If you unplug the device and plug it back in, the device is shown in the menu.

    There is nothing listed If you type vmount

    I assume this is due to there not being an event for attaching a device because the device is already attached at boot.
     
  12. aragon

    aragon New Member

    Messages:
    2,031
    Thanks Received:
    252
    Correct.

    Volman doesn't consider what bus storage devices are attached to, so even hotplug SATA disks should get picked up by it. The only reason your fixed disks don't appear in its volume listing is because there's also no attachment event for them.
     
  13. SNK

    SNK Member

    Messages:
    130
    Thanks Received:
    32
    Great, it seems that eadler@ picked it up. Hopefully it will committed soon.
     
    zeissoctopus thanks for this.
  14. SNK

    SNK Member

    Messages:
    130
    Thanks Received:
    32
    zeissoctopus thanks for this.
  15. zeissoctopus

    zeissoctopus Member

    Messages:
    149
    Thanks Received:
    29
    Many thanks to aragon as well as all contributors.
     
  16. unull

    unull New Member

    Messages:
    11
    Thanks Received:
    2

    Attached Files:

    zeissoctopus thanks for this.
  17. femc7488

    femc7488 New Member

    Messages:
    16
    Thanks Received:
    1
    Thanks, volman is useful. I love it.