如何更改 apt-get 安装目录

发布于 2024-12-21 21:38:11 字数 1549 浏览 2 评论 0原文

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

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

发布评论

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

评论(2

九命猫 2024-12-28 21:38:11

我能想到的最好方法是使用符号链接

,请注意,并非所有程序都安装到同一目录,并且 /opt 可能不是最好的移动方式。 (请参阅末尾,了解仅移动一个文件夹/程序的示例)

这是我使用 EasyPeasy (Ubuntu 10.04) 所做的

。请仔细遵循此代码,如果使用不正确,某些命令可能会删除重要文件。

首先,您需要确保 /opt (或您的发行版默认 apt-get 安装目录)为空。如果您的 opt 文件夹中有数据(您很可能这样做),您可以先将其移动到其他位置以进行安全保存:

sudo mkdir /New_Location/newtmp                                      # Generates Temporary Folder for Programs 
sudo cp -a /opt/* /New_Location/newtmp                               # Moves Programs to Temp folder

备份后,您可以删除原始目录:

sudo rm -rf /opt/                                                    # Removes opt directory

然后您可以在驱动器中创建新的 Program Files 文件夹大量空间并创建符号链接:

sudo mkdir /New_Location/Program-Files                               # Generates New Program Directory
sudo ln -s /New_Location/Program-Files /opt                          # Creates Symbolic Link

最后将所有旧程序文件移动到新文件夹并清理临时数据:

sudo cp -a /New_Location/newtmp/* /New_Location/Program-Files        # Moves Programs to Program Files Folder 
sudo rm -rf /New_Location/newtmp/                                    # Removes Temp folder

如果您只想移动一个占用大量空间的程序,您可以使用相同的方法过程。

例如:
要移动 Java(JVM 约 300MB),请执行以下操作。
使用磁盘使用分析器检查 java 目录。
我的是 /usr/lib/jvm

sudo mkdir /New_Location/Program-Files/Java                          # Generates New Program Directory
sudo cp -a /usr/lib/jvm/* /New_Location/Program-Files/Java            # Moves Program to new folder
sudo rm -rf /usr/lib/jvm                                             # Removes opt directory
sudo ln -s /New_Location/Program-Files/Java /usr/lib/jvm             # Creates Symbolic Link

此时最好重新启动,这应该会清除缓存。

Best way I can think of is to use a symbolic link

note that not all programmes are installed to the same directory and /opt may not be the best thing to move. (see end for example of moving only one folder/program)

This is what I did with EasyPeasy (Ubuntu 10.04)

Follow this code carefully some of the commands can delete important files if used incorrectly.

First you need to make sure /opt (or your distros default apt-get install directory) is empty. If you have data in the opt folder, which you most likely do, you can move it to somewhere else first for safe keeping:

sudo mkdir /New_Location/newtmp                                      # Generates Temporary Folder for Programs 
sudo cp -a /opt/* /New_Location/newtmp                               # Moves Programs to Temp folder

Once backed up you can remove the original directory:

sudo rm -rf /opt/                                                    # Removes opt directory

You can then create your new Program Files folder in a drive with lots of space and create a symbolic link:

sudo mkdir /New_Location/Program-Files                               # Generates New Program Directory
sudo ln -s /New_Location/Program-Files /opt                          # Creates Symbolic Link

Finally move all your old program files to your new folder and clean up the temporary data:

sudo cp -a /New_Location/newtmp/* /New_Location/Program-Files        # Moves Programs to Program Files Folder 
sudo rm -rf /New_Location/newtmp/                                    # Removes Temp folder

If you only wanted to move a single program which is taking up a hunk of your space you could use the same process.

eg:
to move Java (JVM approx 300MB) do the following.
check directory of java using disk usage analyser.
mine is /usr/lib/jvm

sudo mkdir /New_Location/Program-Files/Java                          # Generates New Program Directory
sudo cp -a /usr/lib/jvm/* /New_Location/Program-Files/Java            # Moves Program to new folder
sudo rm -rf /usr/lib/jvm                                             # Removes opt directory
sudo ln -s /New_Location/Program-Files/Java /usr/lib/jvm             # Creates Symbolic Link

Its best at this point to do a restart which should clear the cache.

对岸观火 2024-12-28 21:38:11

你不能:安装路径是硬编码在包中的(例如: http://packages.ubuntu.com/oneiric/i386/mono-runtime/filelist)。该路径通常是 /usr 而不是 /opt,但这取决于软件包。如果要覆盖默认目录,则必须手动提取包的内容。但是,它无法工作:配置文件,有时甚至是二进制文件,将继续使用旧路径。因此,您必须更新它们才能使软件包正常工作。

You can't: the installation path is hard-coded in packages (see for example: http://packages.ubuntu.com/oneiric/i386/mono-runtime/filelist). This path is usually /usr instead of /opt, but it depends of the packages. If you want to override the default directory, you must extract manually the content of the packages. But, it can not work: config files, even binary files sometimes, will continue to use the old path. So you must update them in order for the packages to work correctly.

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