Selective filesystem remount
Use case, I want to remount certain fileysystems with additional options enabled. I used this to enable acls on all mounted ext[34] filesystems.
for mntpnt in $(grep -v "none" /proc/mounts | grep -e "ext[34]" | cut -f2 -d ' '); do sudo mount -o remount,acl,noatime,defaults ${mntpnt}; done
Within the subshell, the first grep removes any lines with "none" in them, getting rid of filesystems that aren't a block device, the second one searches for ext3 or ext4, and the cut returns just the mount point, which is the second column in the space separated output.
The output of the subshell is passed to mount, which is remounting the filesystem using the remount option and adding any other options in the comma separated list. Note that there are no spaces after the commas.
Written by Ali Asad Lotia
Related protips
1 Response
Simple but effective :-).