Код: Выделить всё
import os
import ctypes
def mount(source, target, fs, options=''):
ret = ctypes.CDLL('libc.so.6', use_errno=True).mount(source, target, fs, 0, options)
if ret < 0:
errno = ctypes.get_errno()
raise RuntimeError("Error mounting {} ({}) on {} with options '{}': {}".
format(source, fs, target, options, os.strerror(errno)))
def unmount(device, options=0):
ret = ctypes.CDLL('libc.so.6', use_errno=True).umount2(device, options)
if ret < 0:
errno = ctypes.get_errno()
raise RuntimeError("Error umounting {} with options '{}': {}".format(device, options, os.strerror(errno)))
Код: Выделить всё
unmount('/dev/sdb', 0)
Код: Выделить всё
unmount('/dev/sdb', 1)
Код: Выделить всё
Traceback (most recent call last):
File "./BuildAndInstallXSystem.py", line 265, in
prepare_root_device()
File "./BuildAndInstallXSystem.py", line 159, in prepare_root_device
unmount('/dev/sdb', 0)
File "./BuildAndInstallXSystem.py", line 137, in unmount
raise RuntimeError("Error umounting {} with options '{}': {}".format(device, options, os.strerror(errno)))
RuntimeError: Error umounting /dev/sdb with options '0': Device or resource busy
Код: Выделить всё
unmount('/dev/sdb', 2)
Все это по-прежнему применяется, даже если я заменяю номер устройства конкретным разделом:
Код: Выделить всё
/dev/sdb -> /dev/sdb1
Подробнее здесь: https://stackoverflow.com/questions/453 ... and-umount