将 Ubuntu 迁移到另一个平台时如何保留已安装的应用程序?

发布于 2024-07-06 14:33:28 字数 171 浏览 16 评论 0原文

我正在考虑从较旧的 AMD64 迁移到新的 32 位 Intel 双核。 安装没有问题,但我可以转移所有已安装的应用程序吗? 我没去过 到目前为止,除了迁移到类似的平台和文件系统之外,我们无法在 Google 上找到任何内容。 我不会更改文件系统,但平台会有所不同。 Gentoo 中的“World”文件有什么内容吗?

I'm looking at maybe moving from an older AMD64 to a new Intel dual-core which is 32 bit. Installation isn't a problem but can I transfer all the installed apps? I haven't been
able to find anything so far on Google except where the migration is to a similar platform and file-system. I won't change the filesystem but the platform will be different. Is there something on the lines of the "World" file in Gentoo?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

爱给你人给你 2024-07-13 14:33:28

您可以轻松保存软件包列表:请参阅“man dpkg”并搜索 --set-selections 和 --get-selections。

不过,其基本原理是保存软件包列表:

dpkg --get-selections > package_list

要在另一个系统上恢复该列表:

cat package_list | sudo dpkg --set-selections && sudo apt-get dselect-upgrade

跨架构移动意味着会有一些软件包不可用。 他们会被忽视; 例如,ia32-libs 无法安装在 32 位系统上。 如果您从 x86-64 迁移到 x86,该选择将被忽略。

You can save your list of packages easily: see "man dpkg" and search for --set-selections and --get-selections.

The basic of it, though is that to save the list of packages:

dpkg --get-selections > package_list

To restore that list on another system:

cat package_list | sudo dpkg --set-selections && sudo apt-get dselect-upgrade

Moving across architectures means that there will be some packages unavailable. They will be ignored; for example, ia32-libs will not be installable on a 32-bit system. That selection will be ignored if you're moving from x86-64 to x86.

画中仙 2024-07-13 14:33:28

有趣的是,在这里我使用SO作为howto存储库(写一个问题,然后选择我自己的答案),但是在我写自己的答案的时候,我被打败了三次!

无论如何,这是我的记录:

使用 dpkg 的 --get-selections 和 --set-selections 选项来捕获并选择当前安装的软件包。

首先,导出旧系统上当前的软件包列表:

sudo dpkg --get-selections > mypackages.txt

然后选择此列表作为要在新系统上安装的软件包:(

sudo dpkg --set-selections < mypackages.txt

为了获得额外的积分,请复制您的 apt 缓存目录以最大程度地减少下载:/var/cache/apt )

最后,告诉 apt 下载并安装所选的软件包:

sudo apt-get dselect-upgrade

Funny, here I was using SO as a howto repository (write a question and then select my own answer), but in the time that it took me to write my own answer, I was beaten to the punch thrice!

Anyway, here's my take for the record:

Use dpkg's --get-selections and --set-selections options to capture and select your currently installed packages.

First, export your current package list on your old system:

sudo dpkg --get-selections > mypackages.txt

Then select this list as the packages to install on your new system:

sudo dpkg --set-selections < mypackages.txt

(For extra credit, copy your apt cache directory over to minimize downloads: /var/cache/apt)

Finally, tell apt to download and install the selected packages:

sudo apt-get dselect-upgrade
萌能量女王 2024-07-13 14:33:28

对于您使用 apt-get 安装的所有内容,如果您想创建已安装内容的记录,请运行以下命令:

dpkg -l|awk '/^ii\s*(.*)\s*/ {print $2}'|packages.txt

这将创建一个包含您已安装的所有软件包的文本文件。 然后,完成安装后,创建并运行包含以下内容的脚本:

#!/bin/sh
for p in $(cat packages.txt); do apt-get install $p; done

注意:
1) 由于您要从 64 位迁移到 32 位,因此某些软件包可能不兼容。 在运行上面的脚本之前,我会 grep packages.txt 查找“64”,并在需要时查找替代方案。
2) 您从源代码安装的任何内容,您都必须记下并再次从源代码安装。

祝您好运!

For everything you've used apt-get to install, if you want to create a record of what's installed run the following:

dpkg -l|awk '/^ii\s*(.*)\s*/ {print $2}'|packages.txt

This will create a text file with all the packages you have installed. Then after you do the install, create and run a script with the following:

#!/bin/sh
for p in $(cat packages.txt); do apt-get install $p; done

Notes:
1) Since you're moving from 64 bit to 32 bit, some of the packages might not be compatible. I would grep packages.txt for '64' before running the script above and find alternatives if they are needed.
2) Anything you've installed from source, you'll have to make a note of and install from source again.

Good luck!

就像说晚安 2024-07-13 14:33:28

我不确定这是否是一个答案,但我刚刚发现命令 aptitude-create-state-bundle 的存在。 是的,这是一个命令。 查看手册页。

I'm not sure if this is an answer, but I just discovered the existence of the command aptitude-create-state-bundle. Yes, that's one command. Check out the man page.

不即不离 2024-07-13 14:33:28

如果(像我一样)你在弄乱系统之前没有这样做,你可以启动到 live-cd 或其他安装,并使用 chroot 来获取此信息。

sudo chroot /path/to/old/system /bin/bash

然后执行dpkg --get-selections 舞蹈,您可以使用生成的文件来设置新系统。

If (like me) you didn't do this before you messed up your system, you can boot into a live-cd or another install, and use chroot to get at this info.

sudo chroot /path/to/old/system /bin/bash

Then do the dpkg --get-selections dance, and you can use the resulting file to setup your new system.

想念有你 2024-07-13 14:33:28

这是我通常用来解决类似问题的方法(多次迁移到新笔记本电脑)。

这个问题的其他答案还有两个补充,这也会移动您的 update-alternatives 和 debconf 设置,这总是需要很长时间才能意识到这些设置没有被转移。

在旧系统上备份:

sudo apt-get install dselect debconf-utils
mkdir system-selections
update-alternatives --get-selections > system-selections/alternatives-selections
dpkg --get-selections '*' > system-selections/dpkg-selections
sudo debconf-get-selections > system-selections/debconf-selections

将配置目录复制到新系统(“scp -r oldsystem:system-selections ~”):

sudo apt-get install dselect debconf-utils
sudo dselect update
sudo dpkg --set-selections  < system-selections/dpkg-selections
sudo debconf-set-selections < system-selections/debconf-selections
sudo apt-get -u dselect-upgrade
sudo update-alternatives --set-selections < system-selections/alternatives-selections

此外,您还可以使用相同的方法定期备份主目录和>system-selections(如上所述)到远程存储。 因此,如果您的笔记本电脑损坏/被盗,构建类似的系统非常快。

This is what I generally do to solve similar problem (migrated to a new laptop several times).

There is two addition to the other answers to this question, this will also move your update-alternatives and debconf settings, which always takes a long time to realize those were not transferred.

Backup on old system:

sudo apt-get install dselect debconf-utils
mkdir system-selections
update-alternatives --get-selections > system-selections/alternatives-selections
dpkg --get-selections '*' > system-selections/dpkg-selections
sudo debconf-get-selections > system-selections/debconf-selections

Copy config directory to the newsystem ("scp -r oldsystem:system-selections ~"):

sudo apt-get install dselect debconf-utils
sudo dselect update
sudo dpkg --set-selections  < system-selections/dpkg-selections
sudo debconf-set-selections < system-selections/debconf-selections
sudo apt-get -u dselect-upgrade
sudo update-alternatives --set-selections < system-selections/alternatives-selections

Also, you can use same method to regularly take backups of your home directory and system-selections (mentioned above) to a remote storage. So in case of your laptop broken/stolen, building a similar system is pretty fast.

野稚 2024-07-13 14:33:28

我能想到的最好方法是备份当前系统上已安装软件包的列表,然后使用该列表来设置要在新系统上安装的软件包。 有关如何备份和恢复软件包选择的一般说明:

安装工具

sudo apt-get install dselect

备份软件包列表

dpkg --get-selections | grep -v deinstall > ubuntu-files

恢复软件包选择

sudo apt-get update
sudo apt-get dist-upgrade
dpkg --set-selections < ubuntu-files
sudo dselect

这将打开 dselect 会话。 输入“I”并允许 dselect
安装 ubuntu 文件中列出的软件包。
完成后,输入“Q”并按 ENTER 键退出 dselect。

The best way I can think of to go about this is to back up the list of installed packages on your current system and then use that list to set what packages to install on the new system. General instructions on how to backup and restore your package selections:

Install tools

sudo apt-get install dselect

Backup Package List

dpkg --get-selections | grep -v deinstall > ubuntu-files

Restore Package Selections

sudo apt-get update
sudo apt-get dist-upgrade
dpkg --set-selections < ubuntu-files
sudo dselect

This will open up a dselect session. Type ‘I‘ and allow dselect to
install of the the packages listed in your ubuntu-files document.
When it’s finished, type ‘Q‘ and hit the ENTER key to exit dselect.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文