I have made a simple script to mount a DATA partition in order to fuel my distro hopping fever. I am not completely replacing /home
with this partition, just replacing a few folders so I can have my files through multiple installs.
I was trying to streamline the code for other users but really don't have much experience. I am using a variable so a user can add their own name for the data partition. However, when it comes time to editing fstab
it won't put in the correct name unless I reassign the variable within the if ... else
statement. I will leave out my UUID to make it shorter. $name
refers to the variable set at the beginning of the script $name=DATA
echo "Adding DATA part UUID to fstab"
if grep -Fxq "UUID=xxx /mnt/$name ext4 defaults,noatime 0 2" /etc/fstab; then
echo "Already in fstab"
else
name=DATA #If I dont put this line in then fstab is edited with '$name' instead of actually putting the variable in.
sudo echo "UUID=xxx /mnt/$name ext4 defaults,noatime 0 2" >> /etc/fstab
fi
This is my first post on Stack Exchange so please let me know if this is not formatted correctly.