Skip to content

Instantly share code, notes, and snippets.

@YUChoe
Created December 9, 2019 03:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YUChoe/e9c58adf8f95e22c1ca0c733a99e5fe6 to your computer and use it in GitHub Desktop.
Save YUChoe/e9c58adf8f95e22c1ca0c733a99e5fe6 to your computer and use it in GitHub Desktop.
python 2.4 remount external usb
#!/usr/bin/python
import os
import time
def get_cmd_output(cmd):
tmp_fn = "/tmp/mnt_check.tmp"
os.system('%s > %s' % (cmd, tmp_fn))
fp = open(tmp_fn, 'r')
out = fp.read()
fp.close()
os.remove(tmp_fn)
return out
mp = get_cmd_output("cat /proc/mounts |grep /root/mnt")
if mp:
mp = mp.split()[0] # ex. /dev/sdc1
if not os.path.exists(mp):
os.system('umount /root/mnt')
os.system('mount %s /root/mnt' % mp)
fp = open('/var/log/remount.log' , 'a')
fp.write(time.asctime() + ' remount /root/mnt as ' + mp + '\n')
fp .close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment