Answer the question
In order to leave comments, you need to log in
How to write a script to unmount disks in bash?
Good afternoon! The situation is this - there is a directory / media , flash drives inserted by users are automatically connected to it via pmount. When you connect a flash drive, a directory with the name of the flash drive is created.
It is necessary that when this machine is turned off, the pumount command is executed for each directory
[[email protected] media]# ls /media
Nomi_i184 UBUNTU
From here it is necessary that the following commands be executed when the machine is turned off
pumount --yes-I-really-want-lazy-unmount /media /Nomi_i184
pumount --yes-I-really-want-lazy-unmount /media/Ubuntu
How to implement this in bash?
Answer the question
In order to leave comments, you need to log in
Decided:
#!/bin/bash
for D in /media/*; do
if [ -d "${D}" ]; then
pumount --yes-I-really-want-lazy-unmount "${D}"
fi
done
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question