Distrobox 完全操作指南:安装并运行百度网盘

Distrobox我第一次看到,感觉非常有趣,原因也正是我通过本机rpm安装百度网盘,但不成功。


您好!没找到可执行文件,这说明那个RPM包的制作确实非常不规范,我们不必再为它浪费时间了。

您对 Distrobox 感兴趣,这是一个非常棒的选择!这可以说是当前在 openSUSE Tumbleweed 这种滚动发行版上,运行特定依赖版本应用的最佳实践。它既能完美解决依赖问题,又能保持您主系统(openSUSE)的纯净。

请把 Distrobox 想象成在您的 openSUSE 系统里,开辟了一间“独立App公寓”,这间公寓的内部环境是原生的 Ubuntu 22.04。我们在公寓里安装百度网盘,它会感觉自己就住在 Ubuntu 老家,所有东西都是它熟悉和兼容的。

下面,我将为您提供一个从零开始的、详尽的 Distrobox 操作指南。


Distrobox 完全操作指南:安装并运行百度网盘

第一阶段:在 openSUSE 中安装“地基” (一次性操作)

我们需要先在您的主系统上安装 Distrobox 本身和容器引擎(推荐 Podman)。

  1. 打开您的终端(Konsole)。
  2. 执行以下命令来安装所需软件:
    sudo zypper install distrobox podman
    
    • distrobox 是管理器。
    • podman 是实际创建和运行容器的“引擎”。
第二阶段:创建您的“Ubuntu公寓”

现在,我们来创建一个名为 baidu-box 的、基于 Ubuntu 22.04 镜像的容器。

  1. 在终端中执行:

    distrobox create --name baidu-box --image ubuntu:22.04
    
    • --name baidu-box:给您的容器取个名字,方便管理。
    • --image ubuntu:22.04:指定使用 Ubuntu 22.04 LTS (长期支持版) 的官方镜像。

    提示:第一次执行此命令时,它会从网上下载 Ubuntu 镜像,根据您的网络速度,可能需要几分钟时间,请耐心等待。

网络问题,使用代理

HTTPS_PROXY="http://127.0.0.1:7897" HTTP_PROXY="http://127.0.0.1:7897" distrobox create --name baidu-box --image ubuntu:22.04
第三阶段:进入并装修“公寓”

创建成功后,我们就要“走进去”并准备环境了。

  1. 执行以下命令进入容器:

    distrobox enter baidu-box
    

    注意:此时,您会发现终端的提示符变了,可能前面会带上 baidu-box 的字样。这表明您已经成功进入了 Ubuntu 环境!接下来所有的命令都是在这个“公寓”内部执行的。

  2. 在新环境里,先更新软件列表并安装一个方便的工具 gdebi,它能自动处理.deb包的依赖关系。

    sudo apt update
    sudo apt upgrade -y
    sudo apt install gdebi-core -y
    
第四阶段:在“公寓”里安装百度网盘
  1. 下载网盘安装包

    • 请在 openSUSE 的浏览器中,像平常一样访问百度网盘官网,下载最新的 Linux 版(deb格式)。它会自动保存到您 openSUSE 的 ~/Downloads(下载)文件夹中。
    • Distrobox 的一个神奇之处在于,它会自动共享您的家目录 (/home/你的用户名)。所以您在 openSUSE 下载的文件,在容器里也能直接访问!
  2. 安装.deb

    • 回到您已经进入baidu-box的那个终端窗口
    • 使用我们刚刚安装的 gdebi 工具来安装百度网盘。假设下载的文件名为 baidunetdisk_xxxx_amd64.deb
      sudo gdebi ~/Downloads/baidunetdisk_xxxx_amd64.deb
      
    • 技巧:在输入文件名时,可以输入 baidu 然后按 Tab 键,终端会自动补全文件名。
    • gdebi 会分析依赖,并询问您是否要安装,输入 y 并回车即可。它会自动从Ubuntu的源下载所有必需的“零件”。
第五阶段:从 openSUSE 桌面启动应用!

安装成功后,最神奇的一步来了:我们可以将容器内的应用“导出”,让它直接出现在您 openSUSE 的程序菜单里,就像原生安装的一样!

  1. 仍然处于baidu-box的终端里,执行:

    distrobox-export --app baidunetdisk
    
  2. 现在,点击您屏幕左下角的KDE开始菜单,在程序列表里搜索“百度网盘”,您会惊喜地发现它的图标已经出现了!直接点击它,就可以像普通程序一样启动了。


日常使用和管理

  • 退出容器环境:在进入了baidu-box的终端里,输入 exit 即可退回到您的 openSUSE 终端。
  • 查看已有的容器distrobox list
  • 再次进入容器distrobox enter baidu-box
  • 删除容器(如果想重来):distrobox rm baidu-box

这套流程看似步骤多,但每一步都很清晰。一旦您成功操作一遍,您将掌握一项在Linux上解决各种“老大难”应用兼容性问题的强大技能。祝您成功!

没有执行成功看这里

yqh@localhost ~/Downloads> distrobox enter baidu-box
Error: unable to start container "d108c909cc1d79061b30318477a5c878372aa056d39b9ecc6311bb2cf2583f06": runc: runc create failed: unable to start container process: error during container init: error mounting "/dev/vboxusb/003/002" to rootfs at "/dev/vboxusb/003/002": create mountpoint for /dev/vboxusb/003/002 mount: lstat /home/yqh/.local/share/containers/storage/overlay/f4129941fabfb1fb748405c8d5e918ba57a88e4e7ffdde4d7891685f22444bcf/merged//dev/vboxusb/003: permission denied: OCI permission denied

usb访问的问题,解决这个问题,同时保证隔离性,可以使用该命令创建

distrobox create --name baidu-box --image ubuntu:22.04 --unshare-devsys

在此之前要删除之前创建的

distrobox rm baidu-box

首次进入要下载东西,需要使用代理加速

HTTPS_PROXY="http://127.0.0.1:7897" HTTP_PROXY="http://127.0.0.1:7897" distrobox enter baidu-box

成功进入

yqh@localhost ~/Downloads> HTTPS_PROXY="http://127.0.0.1:7897" HTTP_PROXY="http://127.0.0.1:7897" distrobox enter baidu-box
Starting container...                            [ OK ]
Installing basic packages...                     [ OK ]
Setting up devpts mounts...                      [ OK ]
Setting up read-only mounts...                   [ OK ]
Setting up read-write mounts...                  [ OK ]
Setting up host's sockets integration...         [ OK ]
Integrating host's themes, icons, fonts...       [ OK ]
Setting up distrobox profile...                  [ OK ]
Setting up sudo...                               [ OK ]
Setting up user's group list...                  [ OK ]
Setting up existing user...                      [ OK ]
Ensuring user's access...                        [ OK ]

Container Setup Complete!
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

📦[yqh@baidu-box Downloads]$ 

其他

1

For Future Use (Permanent Proxy inside the Container)

Once you are successfully inside your baidu-box, you might want to make the proxy setting permanent for apt, so you don’t have to type the long command every time you want to install software inside the container.

After you have entered baidu-box, run these commands inside it:

# The following commands are run INSIDE the 'baidu-box' container
#
# Create a proxy configuration file for apt
sudo touch /etc/apt/apt.conf.d/80proxy

# Write your proxy settings into the file
echo 'Acquire::http::proxy "http://127.0.0.1:7897/";' | sudo tee /etc/apt/apt.conf.d/80proxy
echo 'Acquire::https::proxy "http://127.0.0.1:7897/";' | sudo tee -a /etc/apt/apt.conf.d/80proxy

This will make all future apt install or apt update commands inside this specific container automatically use your proxy.

代理的端口记得自己改一下,可能是7890也可能是12334我这边是7897

2

# 以下命令在 baidu-box 内部运行
sudo apt update
sudo apt install gdebi-core -y

# 以下命令在 baidu-box 内部运行
sudo gdebi ~/Downloads/baidunetdisk_4.17.7_amd64.deb

# 以下命令在 baidu-box 内部运行
distrobox-export --app baidunetdisk

在这里插入图片描述
在这里插入图片描述

3

还是无法启动

grep -i exec /usr/share/applications/*baidu*.desktop
📦[yqh@baidu-box Downloads]$ /opt/baidunetdisk/baidunetdisk
/opt/baidunetdisk/baidunetdisk: error while loading shared libraries: libasound.so.2: cannot open shared object file: No such file or directory

修复一下依赖问题

# 首先更新一下软件包列表,这是一个好习惯
sudo apt update

# 然后安装 libasound2 这个包
sudo apt install libasound2

可以了哈,厉害了!!好玩
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值