Backport ubuntu patches

@zhangcheng please review it thanks