def set_disk_usage(self, total_size, path=None):
        """Changes the total size of the file system, preserving the used space.
        Example usage: set the size of an auto-mounted Windows drive.

        Args:
            total_size: The new total size of the filesystem in bytes.

            path: The disk space is changed for the file system device where
                `path` resides.
                Defaults to the root path (e.g. '/' on Unix systems).

        Raises:
            IOError: if the new space is smaller than the used size.
        """
        if path is None:
            path = self.root.name
        mount_point = self._mount_point_for_path(path)
        if (mount_point['total_size'] is not None and
                mount_point['used_size'] > total_size):
            self.raise_io_error(errno.ENOSPC, path)
        mount_point['total_size'] = total_size