• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

umount

Cleanup CVS Snapshot Volumes

August 30, 2022

How to unmount CVS snapshot volumes all at once using a Bash script. I ran into a scenario where I had to unmount 115 volumes. Instead of manually running umount on each one, I use the script below to unmount all 115 volumes. The script performs a grep for ‘.snapshot’ and then writes the results to a file. I then read the file line by line and perform unmount on each one.

#!/bin/bash
file='/tmp/snapshots.txt'
df -h | grep .snapshot | awk '{print $6}' > $file
while IFS= read -r line; do
  echo 'unmounting '$line
  umount $line
done < $file

#!/bin/bash file='/tmp/snapshots.txt' df -h | grep .snapshot | awk '{print $6}' > $file while IFS= read -r line; do echo 'unmounting '$line umount $line done < $file

Filed Under: Linux Tagged With: bash, cvs, snapshots, umount

GCS Fuse

December 21, 2021

GCS Fuse allows you to mount a Google bucket as a file system. It’s similar to S3FS.

Setup repo

sudo tee /etc/yum.repos.d/gcsfuse.repo > /dev/null <<EOF
[gcsfuse]
name=gcsfuse (packages.cloud.google.com)
baseurl=https://packages.cloud.google.com/yum/repos/gcsfuse-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=0
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
       https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF

sudo tee /etc/yum.repos.d/gcsfuse.repo > /dev/null <<EOF [gcsfuse] name=gcsfuse (packages.cloud.google.com) baseurl=https://packages.cloud.google.com/yum/repos/gcsfuse-el7-x86_64 enabled=1 gpgcheck=1 repo_gpgcheck=0 gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg EOF

Yum install

sudo yum install gcsfuse

sudo yum install gcsfuse

Login to GCP and mount. Run as a user and not root.

gcloud auth login
gcsfuse my-bucket /path/to/mount

gcloud auth login gcsfuse my-bucket /path/to/mount

Unmount

fusermount -u /path/to/mount

fusermount -u /path/to/mount

Filed Under: Cloud, Linux Tagged With: bucket, fuse, gcp, gcs, mount, s3fs, umount

Force Umount if Busy

September 16, 2019

If device is busy and you can’t umount it, try it with -l option (lazy unmount). Or you can force it.

# standard
umount /mnt/data
# lazy umount
umount -l /mnt/data
# force
umount -f /mnt/data

# standard umount /mnt/data # lazy umount umount -l /mnt/data # force umount -f /mnt/data

Lazy unmount is safer since it will detach immediately and clean up all references to the file system. Force is a bit more drastic.

Filed Under: Linux Tagged With: busy, device, force, lazy, umount, unable

Mount and Unmount EFS

February 1, 2019

Here’s the command to mount and unmount AWS EFS. Assuming the EFS IP address is 10.0.0.23.

Mount:

mount -t nfs -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport 10.0.0.23:/ /efs

mount -t nfs -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport 10.0.0.23:/ /efs

Umount:

# lazy unmount
umount -l /efs
# force unmount
umount -f /efs

# lazy unmount umount -l /efs # force unmount umount -f /efs

You may have to force it if it’s busy.

Filed Under: Linux Tagged With: efs, mount, umount

  • Home
  • About
  • Archives

Copyright © 2023