Giter Site home page Giter Site logo

Comments (21)

probonopd avatar probonopd commented on September 24, 2024

We are after the Volume label specifically.

https://en.wikipedia.org/wiki/Volume_(computing)#Volume_label

from filer.

grahamperrin avatar grahamperrin commented on September 24, 2024

How, precisely, was the disk formatted? Using what tool(s)?

from filer.

probonopd avatar probonopd commented on September 24, 2024

I don't remember. Possibly on a Mac with Disk Utility.

from filer.

grahamperrin avatar grahamperrin commented on September 24, 2024
  1. gpart show da0
  2. lsblk da0
  3. sudo gdisk /dev/da0

from filer.

probonopd avatar probonopd commented on September 24, 2024
% sudo hexdump -C /dev/da0 | grep FAT                 
00007e20  96 7b 0f 00 80 01 29 fb  07 d5 1d 46 41 54 20 20  |.{....)....FAT  |

from filer.

probonopd avatar probonopd commented on September 24, 2024
% gpart show da0
=>     32  1014752  da0  MBR  (496M)
       32       31       - free -  (16K)
       63  1014678    1  fat32  (495M)
  1014741       43       - free -  (22K)

% lsblk da0
DEVICE         MAJ:MIN SIZE TYPE                              LABEL MOUNT
da0              0:160 496M MBR                                   - -
  <FREE>         -:-    16K -                                     - -
  da0s1          0:161 495M fat32                                 - /media/da0s1
  <FREE>         -:-    22K -                                     - -

% sudo gdisk /dev/da0
sudo: gdisk: command not found

from filer.

probonopd avatar probonopd commented on September 24, 2024

This does the trick but for whatever reason needs sudo:

% fstyp -l /dev/da0s1 
fstyp: /dev/da0s1: Permission denied

% sudo fstyp -l /dev/da0s1
msdosfs FAT

Maybe @trasz knows why one needs sudo to find out the Volume label on FreeBSD...

from filer.

probonopd avatar probonopd commented on September 24, 2024

On the Mac, these "Volume labels" are used as the directory names for the mountpoints as well, unlike what we currently have:

image

If there is more than one disk with the same "Volume label" attached at the same time, then the Mac adds an appendix to the name of the mount point.

And the directories for the mount points get automatically deleted after unmounting so that the directory does not get cluttered up.

Something we should consider as well @vermaden?

from filer.

grahamperrin avatar grahamperrin commented on September 24, 2024

fstyp(8)

https://man.freebsd.org/fstyp(8)

If required: https://cgit.freebsd.org/src/tree/usr.sbin/fstyp

from filer.

grahamperrin avatar grahamperrin commented on September 24, 2024

glabel(8)

https://man.freebsd.org/glabel(8)

glabel list

… and so on.

Hint: you'll not get the label whilst the file system is mounted.

from filer.

probonopd avatar probonopd commented on September 24, 2024

Hint: you'll not get the label whilst the file system is mounted.

That kinda defeats the purpose then. After all we want Filer to display the "Volume labels" (LIVE, FAT,...) instead of those cryptic device names.

With sudo fstyp it works but I wonder why it needs sudo.

image

@DamjanJovanovic is this something bsdisks could help us with?

from filer.

DamjanJovanovic avatar DamjanJovanovic commented on September 24, 2024

bsdisks already uses fstyp to find the filesystem type, so it knows which mount command to use, but there's no -l. It uses the GEOM label, but maybe should use something else, for the "IdLabel" property in:

sudo dbus-send --system --print-reply \
--dest=org.freedesktop.UDisks2 \
/org/freedesktop/UDisks2/block_devices/da1 \
org.freedesktop.DBus.Properties.GetAll \
string:org.freedesktop.UDisks2.Block

I'll do some further tests and let you know.

from filer.

DamjanJovanovic avatar DamjanJovanovic commented on September 24, 2024

GEOM does expose the volume label, parse the XML output of sysctl kern.geom.confxml and look under the "LABEL" class. A "MYUSB" label on /dev/da1 has the form:

<class id="0xffffffff81afcda0">
    <name>LABEL</name>
    <geom id="0xfffff800c9aa9800">
        <name>da1</name>
        <provider id="0xfffff800ca320a00">
          <name>msdosfs/MYUSB</name>
          ...
        </provider>
        ...
    </geom>
    ...
</class>

Note that apart from trimming the filesystem prefix and slash, the label from GEOM has to be URL-decoded (unless your XML library already did that for you).

However that disappears when the filesystem is mounted.

bsdisks also exposes it over D-Bus, obtained from GEOM before mounting (for the filesystems it manages, anyway):

sudo dbus-send --system --print-reply \
--dest=org.freedesktop.UDisks2 \
/org/freedesktop/UDisks2/block_devices/da1 \
org.freedesktop.DBus.Properties.Get \
string:org.freedesktop.UDisks2.Block \
string:IdLabel

If you need the label of a mounted filesystem even when unmanaged by bsdisks, I think fstyp -l is the only way.

ZFS volumes don't have labels, and their dataset names (eg. zroot/var/log) seem to come from the first string in the output of zfs get -H canmount instead.

from filer.

grahamperrin avatar grahamperrin commented on September 24, 2024

A PCManFM-Qt view of a non-mounted ZFS file system in my copperbowl pool:

PCManFM-Qt

  • an unusual example, in that the icon for the device must not be clicked
  • I later set canmount to off to prevent mounting.

Ambiguity can be problematic:

image

  • each of the six / bookmarks was for a separate location
  • none refers to /

from filer.

probonopd avatar probonopd commented on September 24, 2024

@DamjanJovanovic unfortunately this does not work for me:

% sysctl kern.geom.confxml | grep '<label'    
            <label></label>
            <label>zfs0</label>
            <label>gptboot0</label>
            <label>efiboot0</label>

% sudo dbus-send --system --print-reply \
--dest=org.freedesktop.UDisks2 \
/org/freedesktop/UDisks2/block_devices/da0s1 \
org.freedesktop.DBus.Properties.GetAll \
string:org.freedesktop.UDisks2.Block
method return time=1617007998.984579 sender=:1.14 -> destination=:1.16 serial=23 reply_serial=2
   array [
      dict entry(
         string "Configuration"
         variant             array [
            ]
      )
      dict entry(
         string "CryptoBackingDevice"
         variant             object path "/"
      )
      dict entry(
         string "Device"
         variant             array of bytes "/dev/da0s1"
      )
      dict entry(
         string "DeviceNumber"
         variant             uint64 0
      )
      dict entry(
         string "Drive"
         variant             object path "/org/freedesktop/UDisks2/drives/da0"
      )
      dict entry(
         string "HintAuto"
         variant             boolean false
      )
      dict entry(
         string "HintIconName"
         variant             string ""
      )
      dict entry(
         string "HintIgnore"
         variant             boolean false
      )
      dict entry(
         string "HintName"
         variant             string ""
      )
      dict entry(
         string "HintPartitionable"
         variant             boolean false
      )
      dict entry(
         string "HintSymbolicIconName"
         variant             string ""
      )
      dict entry(
         string "HintSystem"
         variant             boolean false
      )
      dict entry(
         string "Id"
         variant             string "0000000000000000000"
      )
      dict entry(
         string "IdLabel"
         variant             string ""
      )
      dict entry(
         string "IdType"
         variant             string "vfat"
      )
      dict entry(
         string "IdUUID"
         variant             string ""
      )
      dict entry(
         string "IdUsage"
         variant             string "filesystem"
      )
      dict entry(
         string "IdVersion"
         variant             string ""
      )
      dict entry(
         string "MDRaid"
         variant             object path "/"
      )
      dict entry(
         string "MDRaidMember"
         variant             object path "/"
      )
      dict entry(
         string "PreferredDevice"
         variant             array of bytes "/dev/da0s1"
      )
      dict entry(
         string "ReadOnly"
         variant             boolean false
      )
      dict entry(
         string "Size"
         variant             uint64 519515136
      )
      dict entry(
         string "Symlinks"
         variant             array [
            ]
      )
   ]

This does:

% sudo fstyp -l /dev/da0s1
msdosfs FAT

The label is FAT.

from filer.

probonopd avatar probonopd commented on September 24, 2024

According to @crees

fstyp -l /dev/disk gets you the label
but you will have to be in group operator
or just put in devfs rules to give 644 rather than just 640 on drive nodes are you're all good

So changing to 644 in https://github.com/helloSystem/ISO/blob/experimental/overlays/uzip/furybsd-settings/files/etc/devfs.rules should do the trick?

ls -l /dev/da0* should be or crw-r--r---

Also see https://www.youtube.com/watch?v=U1fzMjj4Gv8

Trying 0666, sudo /etc/rc.d/devfs restart, re-plug USB drive, ls -h still shows crw-r----- :-(

from filer.

vermaden avatar vermaden commented on September 24, 2024

I am using device nodes as mount point as its consistent and I that way each devices behaves the same.

Remember that:

  • many removable devices does not have labels for filesystems
  • you can also use device model as mount point but with many partitions you must 'artificially' enumerate these partitions
  • you also need to make sure that all those labels and model names are sanitized ... tr -c -d comes handy here

I have better proposal ... leave the 'technical' mount points as they are now - they are sure to work properly - and change these names in the graphical/presentation layer. For example you can display different names (labels or model) on the desktop then the actual mountpoint. You can also leave current device naming and add caption (text displayed after on-mounse-over a device) with its label and/or model.

from filer.

probonopd avatar probonopd commented on September 24, 2024

Needed to run sudo devfs ruleset 10, now I get

% fstyp -l /dev/da0s1
msdosfs FAT

from filer.

probonopd avatar probonopd commented on September 24, 2024

Need in /etc/rc.conf:

devfs_load_rulesets="YES"
devfs_system_ruleset="system"

Then the following seems to work: /etc/devfs.rules

[system=10]
add path 'acd*'         mode 0644 group operator
add path 'cd*'          mode 0644 group operator
add path 'da*'          mode 0644 group operator
add path 'pass*'        mode 0644 group operator
add path 'xpt*'         mode 0644 group operator
add path 'fd*'          mode 0644 group operator
add path 'md*'          mode 0644 group operator
add path 'uscanner*'    mode 0644 group operator
add path 'ugen*'        mode 0644 group operator
add path 'video*'       mode 0644 group operator
add path 'cuse*'        mode 0644 group operator
add path 'usb*'        mode 0644 group operator
# https://www.freebsd.org/doc/en_US.ISO8859-1/articles/cups/printing-cups-configuring-server.html
add path 'lpt*'         mode 0644 group cups
add path 'ulpt*'        mode 0644 group cups
add path 'unlpt*'       mode 0644 group cups

Is this the correct way to do this?

from filer.

probonopd avatar probonopd commented on September 24, 2024

In perparation for this, I committed

Possibly we also need to edit

from filer.

probonopd avatar probonopd commented on September 24, 2024

We are getting somewhere.

image

from filer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.