Created
December 9, 2019 03:09
-
-
Save YUChoe/e9c58adf8f95e22c1ca0c733a99e5fe6 to your computer and use it in GitHub Desktop.
python 2.4 remount external usb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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