Answer the question
In order to leave comments, you need to log in
How to determine the block device name from a folder?
How can I determine by the /home/test/ folder which block device it belongs to?
tried like this. but not in all cases it is suitable:
I would like to get the name of the block device and not uuid
Tell me a command that is not too long to determine ...
Answer the question
In order to leave comments, you need to log in
jcmvbkbc Thanks for the tip on the stat
program
here is the solution:
mount | grep " $(stat -c%m /home/dimon/win/) " | awk '{print $1}'
#!/bin/bash
# в качестве параметра скрипта указываем папку
# берем результат работы в переменную
BLOCK=$(df $1 | awk '/dev/ {print $1}')
# если в строке содержится "by-uuid" то ...
if ;
then
# обрабатываем одним способом
blkid -U $(echo $BLOCK | cut -d/ -f5)
else
# если "by-uuid" нет, то просто выводим.
echo $BLOCK
fi
find /dev -type b -print0 | xargs -0 stat -c '%02t%02T %n' | grep ^`stat -c %D <имя каталога>`
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question