I installed DietPi on a VM with Debian Bookworm installed on it, which had shared directories from a Windows PC mounted on the VM. After installation, the contents of these directories were deleted. I assume this is because the directories were not unmounted during the installation.
Where were the folders mounted to?
Why not using our VM images?
hi,
the folders was mounted on the host machine, and after install, i seen than the files was deleted
Because, i wanted to try the install script !
I don’t find where this problem occured…But it’s easy to reproduce this !
Have a nice day
which folder? where? exact mount point?
it’s with this script i wrote :
#!/bin/bash
# This script allows mounting and unmounting shared directories on Raspbian in a VMware VM
# Display the user's home directory path
REPERTOIRE_UTILISATEUR="$HOME"
# Generic function to display messages
MessageBox() {
whiptail --title "Shared Directory Management" --msgbox "$1" 10 60
}
# Function to display mounted directories and select one to unmount
selectionner_repertoire_a_demonter() {
# Get the list of mounted directories using vmhgfs
REPERTOIRES_MONTES=$(mount | grep vmhgfs | awk '{print $3}')
# Check if no directories are mounted
if [ -z "$REPERTOIRES_MONTES" ]; then
MessageBox "No mounted shared directories found."
return
fi
# Let the user select a directory to unmount
REPERTOIRE_SELECTIONNE=$(whiptail --title "Select a Directory" --menu "Choose a mounted directory to unmount:" 20 60 10 $(echo "$REPERTOIRES_MONTES" | nl) 3>&1 1>&2 2>&3)
# Check if no directory was selected
if [ -z "$REPERTOIRE_SELECTIONNE" ]; then
MessageBox "No directory selected.\nOperation canceled."
return
fi
# Get the selected directory path
REPERTOIRE_A_DEMONTER=$(echo "$REPERTOIRES_MONTES" | sed -n "${REPERTOIRE_SELECTIONNE}p")
confirmer_demonter "$REPERTOIRE_A_DEMONTER"
}
# Function to confirm unmounting
confirmer_demonter() {
REPERTOIRE=$1
# Ask for confirmation before unmounting
whiptail --yesno "Are you sure you want to unmount $REPERTOIRE?" 10 60
if [ $? -eq 0 ]; then
# Unmount the directory
sudo umount "$REPERTOIRE"
if [ $? -eq 0 ]; then
MessageBox "$REPERTOIRE has been successfully unmounted."
else
MessageBox "Failed to unmount $REPERTOIRE.\nPlease check and try again."
fi
else
MessageBox "Unmount operation canceled."
fi
}
# Main menu
menu_principal() {
while true; do
# Display the main menu and get user choice
CHOIX=$(whiptail --title "Shared Directory Management" \
--menu "\nChoose an option:\n -User Directory: $REPERTOIRE_UTILISATEUR" 15 60 4 \
"1" "Create and mount a shared directory" \
"2" "Unmount a shared directory" \
"3" "Exit" 3>&1 1>&2 2>&3)
case "$CHOIX" in
1) creer_repertoire_partage ;; # Call function to create and mount a shared directory
2) selectionner_repertoire_a_demonter ;; # Call function to unmount a shared directory
3) MessageBox "Thank you for using this script!"; exit 0 ;; # Exit the script
*) MessageBox "Invalid choice." ;; # Handle invalid choices
esac
done
}
# Function to create a shared directory
creer_repertoire_partage() {
# Prompt the user to enter the name of the new shared directory
NOM_REPERTOIRE=$(whiptail --inputbox "Enter the name of the new shared directory:" --title "Shared Directory Management" 10 60 3>&1 1>&2 2>&3)
# Check if the directory name is empty
if [ -z "$NOM_REPERTOIRE" ]; then
MessageBox "The directory name cannot be empty.\nOperation canceled."
return
fi
# Check if the directory already exists
if [ ! -d "$HOME/$NOM_REPERTOIRE" ]; then
mkdir -p "$HOME/$NOM_REPERTOIRE"
fi
# Check if the directory is already shared
if mount | grep "$HOME/$NOM_REPERTOIRE" > /dev/null; then
MessageBox "The directory $NOM_REPERTOIRE is already shared."
else
# Enable user_allow_other in fuse.conf
sudo sed -i 's/#user_allow_other/user_allow_other/' /etc/fuse.conf
# Mount the shared directory using vmhgfs-fuse
sudo vmhgfs-fuse .host:/ "$HOME/$NOM_REPERTOIRE" -o subtype=vmhgfs-fuse,allow_other
# Check if the operation was successful
if [ $? -eq 0 ]; then
MessageBox "The directory $NOM_REPERTOIRE has been successfully created and shared in\n $REPERTOIRE_UTILISATEUR."
else
MessageBox "Failed to create or share the directory."
fi
fi
}
# Launch the main menu
menu_principal
so they are mounted to /home
? I mean, you could just say what the mount point is without me having to read through some scripts first.
Yes they are mounted to /home
Sorry, i believe that can help you to have the script i used
ok I guess this one might be responsible for your situation
It’s going to clean user home directory as part of the general clean up
Hi
I don’t know if it’s necessary to clean the home directory (and mounted path too ) but as they are not warning before it will be a problem in some case !
A minimum thing would be to unmount all shared path before run steps script.
Happy to find this “bug” (and sorry if i do mistake on translation but with the script you seen than i’m french )
Have a nice day and thanks for dietpi !
well the system will be cleaned up completely. We remove all software title as well as all users. This is how it is intended.
something that could certainly be included
Ok, perhaps a warning message to indicate that it’s necessary to backup datas before launch dietpi installation…
i just lost few data because i done backup one hour before and now i know but for others it will be most secure
well, it is rather a rare case that a user configures his system, mounts things and only then executes the install script. And even with a warning, there are certainly still users who ignore it. But yes, we will take it into consideration
Thanks
Have a nice day
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.