Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: command to know at which partition label is mounted /

  1. #1

    Default command to know at which partition label is mounted /

    is there a command to know at which partition label is mounted /
    for example my / is mounted at partition with label "suse1", how can I get "suse1"??
    manythanks, ciao, pier :-)

  2. #2
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    25,155

    Default Re: command to know at which partition label is mounted /

    Do you mean that he file system that is mounted at / has the (volume) label suse1?

    You could use
    Code:
    ls -l /dev/disk/by-label
    because the system (udev) creates there links to the device files with names of the labels it found.
    Henk van Velden

  3. #3

    Default Re: command to know at which partition label is mounted /

    Quote Originally Posted by hcvv View Post
    Do you mean that he file system that is mounted at / has the (volume) label suse1?

    You could use
    Code:
    ls -l /dev/disk/by-label
    because the system (udev) creates there links to the device files with names of the labels it found.
    yes, I can see the label associated with /sdaX, but in the output I cannot find any association between "/" and where it is mounted, and this I need :-)
    Code:
    pla@pla-3-TW:~> ls -l /dev/disk/by-label
    total 0
    lrwxrwxrwx 1 root root 10 Aug 28 17:10 dati -> ../../sda8
    lrwxrwxrwx 1 root root 10 Aug 28 17:10 home1 -> ../../sda5
    lrwxrwxrwx 1 root root 10 Aug 28 17:10 home2 -> ../../sda7
    lrwxrwxrwx 1 root root 15 Aug 28 17:09 SDCARD116G -> ../../mmcblk0p1
    lrwxrwxrwx 1 root root 10 Aug 28 17:10 suse1 -> ../../sda3
    lrwxrwxrwx 1 root root 10 Aug 28 17:10 suse2 -> ../../sda6
    lrwxrwxrwx 1 root root 10 Aug 28 17:10 swap -> ../../sda2
    pla@pla-3-TW:~>

  4. #4
    Join Date
    May 2012
    Location
    Finland
    Posts
    2,004

    Default Re: command to know at which partition label is mounted /

    Code:
    lsblk -f
    /10char
    .: miuku #suse @ irc.freenode.net
    :: miuku@opensuse.org

    .: h​ttps://download.opensuse.org/repositories/home:/Miuku/

  5. #5
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    25,155

    Default Re: command to know at which partition label is mounted /

    Quote Originally Posted by pier_andreit View Post
    yes, I can see the label associated with /sdaX, but in the output I cannot find any association between "/" and where it is mounted, and this I need :-)
    Code:
    pla@pla-3-TW:~> ls -l /dev/disk/by-label
    total 0
    lrwxrwxrwx 1 root root 10 Aug 28 17:10 dati -> ../../sda8
    lrwxrwxrwx 1 root root 10 Aug 28 17:10 home1 -> ../../sda5
    lrwxrwxrwx 1 root root 10 Aug 28 17:10 home2 -> ../../sda7
    lrwxrwxrwx 1 root root 15 Aug 28 17:09 SDCARD116G -> ../../mmcblk0p1
    lrwxrwxrwx 1 root root 10 Aug 28 17:10 suse1 -> ../../sda3
    lrwxrwxrwx 1 root root 10 Aug 28 17:10 suse2 -> ../../sda6
    lrwxrwxrwx 1 root root 10 Aug 28 17:10 swap -> ../../sda2
    pla@pla-3-TW:~>
    / is not mounted. A file system is mounted on /. Exactly the other way around as you seem to think.

    And because a file system is stored on some volume of mass storage and because very often this mass storage volume is in the form of a partition, to keep things short, many people talk about "a partition is mounted on a directory" (and that directory then becomes a mount point by definition).

    When you want to know what is mounted where:
    Code:
    mount
    But I admit that nowadays the output is rather bewildering because all sorts of mounting is done for special purposes (like Btrfs snapshotting).
    But the following must single out / :
    Code:
    mount | grep ' / '
    Henk van Velden

  6. #6

    Default Re: command to know at which partition label is mounted /

    manythanks
    / is not mounted. A file system is mounted on /. Exactly the other way around as you seem to think.
    yes, you are right, mine is a wrong "way-to-say" (I don't know if it is correct, it is a literal traduction of italian "modo di dire" :-) )
    ...I think that a combination of yours suggestions will lead me to a solution :-)
    this
    Code:
    pla@pla-3-TW:~> lsblk -f
    NAME        FSTYPE LABEL UUID MOUNTPOINT
    sda                           
    ├─sda1                        
    ├─sda2                        [SWAP]
    ├─sda3                        /suse-other
    ├─sda4                        
    ├─sda5                        /home-other
    ├─sda6                        /
    ├─sda7                        /home
    └─sda8                        /dati
    and this better
    Code:
    pla@pla-3-TW:~> mount | grep ' / '
    /dev/sda6 on / type ext3 (rw,relatime,data=ordered)                                                                                                                                                    
    pla@pla-3-TW:~>
    gives me an association between / and /dev/sdaX

    and this
    Code:
    pla@pla-3-TW:~> ls -l /dev/disk/by-label
    total 0
    lrwxrwxrwx 1 root root 10 Aug 28 17:10 dati -> ../../sda8
    lrwxrwxrwx 1 root root 10 Aug 28 17:10 home1 -> ../../sda5
    lrwxrwxrwx 1 root root 10 Aug 28 17:10 home2 -> ../../sda7
    lrwxrwxrwx 1 root root 15 Aug 28 17:09 SDCARD116G -> ../../mmcblk0p1
    lrwxrwxrwx 1 root root 10 Aug 28 17:10 suse1 -> ../../sda3
    lrwxrwxrwx 1 root root 10 Aug 28 17:10 suse2 -> ../../sda6
    lrwxrwxrwx 1 root root 10 Aug 28 17:10 swap -> ../../sda2
    pla@pla-3-TW:~>
    an association between /sdaX and label
    ...I will try with cat and sed to get something, ...in case of fail I'll ask :-)

  7. #7
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    26,846
    Blog Entries
    15

    Default Re: command to know at which partition label is mounted /

    Hi
    You need to be root user for lsblk -f, there is also blkid. Both will show labels for mounted and unmounted partitions.
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  8. #8

    Default Re: command to know at which partition label is mounted /

    Quote Originally Posted by malcolmlewis View Post
    Hi
    You need to be root user for lsblk -f, there is also blkid. Both will show labels for mounted and unmounted partitions.
    thank you, the lsblk as root gives me all the associations.
    but I don't know how to use root automatically without password, so for now, in my very newbby way I used this:
    Code:
    strZ=`mount | grep " / "` && strX=`echo ${strZ:4:5}` && strW=`ls -l /dev/disk/by-label | grep $strX` && numB=`expr index "$strW" ":"` && numA=`expr index "$strW" ">"` && echo ${strW:$((numB+3)):$((numA-numB-3-3))}
    and seems to works

  9. #9
    Join Date
    Feb 2010
    Location
    Germany
    Posts
    2,559

    Default Re: command to know at which partition label is mounted /

    Quote Originally Posted by pier_andreit View Post
    but I don't know how to use root automatically without password
    Normally, in a sane, well managed, dependable, Linux and UNIX® world, the user "root" is ** NEVER ** "automatically used".

    If, there are some "privileged" scenarios which need the privileges of the user "root" which some users frequently need to execute then, it'll pay to setup "sudo" to allow those users which need to (usually system administrators and/or personnel who are charged with the responsibility to backup systems), to execute the scripts which call the commands which need the privileges of the user "root".

  10. #10
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    25,155

    Default Re: command to know at which partition label is mounted /

    Quote Originally Posted by dcurtisfra View Post
    Normally, in a sane, well managed, dependable, Linux and UNIX® world, the user "root" is ** NEVER ** "automatically used".

    If, there are some "privileged" scenarios which need the privileges of the user "root" which some users frequently need to execute then, it'll pay to setup "sudo" to allow those users which need to (usually system administrators and/or personnel who are charged with the responsibility to backup systems), to execute the scripts which call the commands which need the privileges of the user "root".
    And to that not only belongs a meticulous configuring of sudo, but also a correct place for such a script with the correct ownership and permissions and likewise for the directories in the path leading to it. It might be even a good questions if such an executable may be in the form of a script or that it better should be a binary program. Of course such a program may not have any features that allow e.g. to escape to a shell.
    Henk van Velden

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •