在SSD安装Ubuntu并将HDD用作Home分区时,如何将deb包与Flatpak软件安装至SSD的问题咨询
Hey Emir, let's work through this step by step—since DEB packages and Flatpaks handle storage differently, we'll tackle them separately:
DEB Packages
First off, a quick clarification: by default, DEB packages are installed directly to your system's root partition (/), which is your SSD (since that's where you installed Ubuntu). What you're probably seeing is user-specific data or configurations (like browser profiles, app settings) ending up in your /home directory (on the HDD). If you want those bulk data files on the SSD instead, here's how to fix it:
- For apps that let you pick an install location during setup: Look for a "custom path" option in their installation wizard, and point it to a folder you create on your SSD (like
/opt/my-appsor a dedicated/ssd-app-datadirectory). - For apps that don't offer this choice: You can move their data folders from your
/hometo the SSD, then create a symbolic link so the app still finds it at the original path. For example, with Firefox:- Create a folder on your SSD (replace
your-userwith your actual username):sudo mkdir /ssd-data/firefox sudo chown your-user:your-user /ssd-data/firefox - Move your existing Firefox profile data:
mv ~/.mozilla/firefox /ssd-data/ - Link it back to the original location:
ln -s /ssd-data/firefox ~/.mozilla/firefox
~/.config/or~/.local/share/and repeat the process. - Create a folder on your SSD (replace
Flatpaks
Flatpaks have two main storage areas: system-wide app files live in /var/lib/flatpak/ (which is already on your SSD, since /var is part of the root partition) and user-specific data (like app settings, caches) goes to ~/.var/app/ (your HDD, since /home is there). If you want that user-specific data on the SSD instead, here's what to do:
- Create a dedicated folder on your SSD for Flatpak user data:
sudo mkdir /ssd-flatpak-user sudo chown your-user:your-user /ssd-flatpak-user - Move your existing Flatpak user data over:
mv ~/.var/app /ssd-flatpak-user/ - Create a symbolic link so Flatpak still looks in the right place:
ln -s /ssd-flatpak-user/app ~/.var/app
Alternatively, if you want to set this up for new Flatpaks without moving existing data, add this line to your ~/.bashrc or ~/.profile file to set an environment variable:
export FLATPAK_USER_DIR="/ssd-flatpak-user"
Log out and back in, and any new Flatpaks you install will store their user data on the SSD.
One quick check to confirm: run df -h / in the terminal to make sure your root partition (/) is indeed mounted on your SSD. The output will show the device path (something like /dev/nvme0n1p2 for an SSD) next to the / mount point.
备注:内容来源于stack exchange,提问作者Emir

