Move snap packages to another location/directory
I want to move installed snap packages to home directory. Snap packages are slightly larger than .deb packages thus they take space in my root partition. I know packages are located in /var/lib/snapd/snaps
and they are working with mounting the package to /snap/app_dir
. I tried to simlinked, But it didn't work.
snap 18.04
add a comment |
I want to move installed snap packages to home directory. Snap packages are slightly larger than .deb packages thus they take space in my root partition. I know packages are located in /var/lib/snapd/snaps
and they are working with mounting the package to /snap/app_dir
. I tried to simlinked, But it didn't work.
snap 18.04
add a comment |
I want to move installed snap packages to home directory. Snap packages are slightly larger than .deb packages thus they take space in my root partition. I know packages are located in /var/lib/snapd/snaps
and they are working with mounting the package to /snap/app_dir
. I tried to simlinked, But it didn't work.
snap 18.04
I want to move installed snap packages to home directory. Snap packages are slightly larger than .deb packages thus they take space in my root partition. I know packages are located in /var/lib/snapd/snaps
and they are working with mounting the package to /snap/app_dir
. I tried to simlinked, But it didn't work.
snap 18.04
snap 18.04
asked Apr 29 '18 at 7:17
ultimatexultimatex
390121
390121
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Change snaps installation directory
This is a common issue that many asks for it, it seems snap developers are not intended to solve it soon, so some solutions was suggested as I search.
The first solution that was strongly refused by the community,but I didn't try, is to use symbolic link to link the directories which leads to snaps, this method seems not to work as the community replies asy that apparmom not working with symbolic links.
The Second solution is mount --bind
the directory /val/lib/snapd/snaps
which works fine for me with the already installed applications but failed to install new applications because I was moving the directory to another partition. That gave me an error about hard linking the snap application with the cache directory which is located in /var/lib/snapd/cache
. I don't know if this solution may work if the location are in the same partition or not; but this is the reason why I am moving the snap directory to free some space from partition to another one.
Third and working option is to move the /var/lib/snapd
directory as a whole then mount --bind
to it from another location and that worked for me and here is the steps.
Just a small note ,you already know, After the rsync is done in the below steps, you can backup the data inside /var/lib/snapd
to another location until the whole process is successfully done then you can remove the backup data if you want to free more space.
##############################################################################
# Take Care this section may break the System !!!
##############################################################################
##Move snap folder to Home instead of root.
#Create the directory : you can change the location
mkdir /home/$USER/snap/snapd
#Copy the data
sudo rsync -avzP /var/lib/snapd/ /home/$USER/snap/snapd/
#Do backups
sudo mv /var/lib/snapd /var/lib/snapd.bak
sudo cp /etc/fstab /etc/fstab.bak
#Change fstab (Change $USER with your name or change the path totally)
echo "/home/$USER/snap/snapd /var/lib/snapd none bind 0 0" | sudo tee -a /etc/fstab
#remount fstab Or reboot.
sudo mount -a
if ls /var/lib/snapd/ | grep snaps
then
echo "Re-mounting snapd folder is done successfully. !!!!"
sudo rm -rf /var/lib/snapd.bak
else
echo "WARNING : Re-mounting snapd folder failed, please revert !!!!! "
echo "WARNING : Re-mounting snapd folder failed, please revert !!!!! "
echo "WARNING : Re-mounting snapd folder failed, please revert !!!!! "
echo "WARNING : Re-mounting snapd folder failed, please revert !!!!! "
echo "WARNING : Re-mounting snapd folder failed, please revert !!!!! "
# Trying to revert automatically
sudo cp /etc/fstab.bak /etc/fstab
sudo mount -a
sudo umount /var/lib/snapd
sudo mv /var/lib/snapd.bak /var/lib/snapd
echo "Files located at ~/snap/snapd should be removed, but it keeped for
recovery until you ,manually, reboot the system and make sure the service
is running correctly then manually you can remove that folder ~/snap/snapd
!!!!!!!!!!!!!!, you should do that manually."
fi
##############################################################################
# Take Care the pervious section may break the System !!!
##############################################################################
References
Custom disk location for certain snaps issue- ask ubuntu Question (Not best solution) Link
- Suggestion to use bind mount instead of symbolic links in moving snap directories Link
- Differences between bind mount and symbolic links Link
- Make bind mount permenant
add a comment |
I finally found a way.
- First move the snap package to desired location. Let
snap_app.snap
as the app you want to move. Move the package from/var/lib/snapd/snaps/snap_app.snap
to~/snaps/snap_app.snap
. - Then you have to change mount option in
/etc/systemd/system/snap-snap_app-90.mount
,number in the file name may be vary. It has directiveWhat=/snap_app_loaction
under[Mount]
. Change it to your new snap package location. - Finally you have to symlink the snap package to
/var/lib/snapd/snaps/
.
Ex:
ln -s /var/lib/snapd/snaps/snap_app ~/snaps/snap_app.snap
Snap package is originally mount in to /snap/snap_app
directory. you can check it with mount
. Reboot your machine and you are all done.
add a comment |
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1029562%2fmove-snap-packages-to-another-location-directory%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Change snaps installation directory
This is a common issue that many asks for it, it seems snap developers are not intended to solve it soon, so some solutions was suggested as I search.
The first solution that was strongly refused by the community,but I didn't try, is to use symbolic link to link the directories which leads to snaps, this method seems not to work as the community replies asy that apparmom not working with symbolic links.
The Second solution is mount --bind
the directory /val/lib/snapd/snaps
which works fine for me with the already installed applications but failed to install new applications because I was moving the directory to another partition. That gave me an error about hard linking the snap application with the cache directory which is located in /var/lib/snapd/cache
. I don't know if this solution may work if the location are in the same partition or not; but this is the reason why I am moving the snap directory to free some space from partition to another one.
Third and working option is to move the /var/lib/snapd
directory as a whole then mount --bind
to it from another location and that worked for me and here is the steps.
Just a small note ,you already know, After the rsync is done in the below steps, you can backup the data inside /var/lib/snapd
to another location until the whole process is successfully done then you can remove the backup data if you want to free more space.
##############################################################################
# Take Care this section may break the System !!!
##############################################################################
##Move snap folder to Home instead of root.
#Create the directory : you can change the location
mkdir /home/$USER/snap/snapd
#Copy the data
sudo rsync -avzP /var/lib/snapd/ /home/$USER/snap/snapd/
#Do backups
sudo mv /var/lib/snapd /var/lib/snapd.bak
sudo cp /etc/fstab /etc/fstab.bak
#Change fstab (Change $USER with your name or change the path totally)
echo "/home/$USER/snap/snapd /var/lib/snapd none bind 0 0" | sudo tee -a /etc/fstab
#remount fstab Or reboot.
sudo mount -a
if ls /var/lib/snapd/ | grep snaps
then
echo "Re-mounting snapd folder is done successfully. !!!!"
sudo rm -rf /var/lib/snapd.bak
else
echo "WARNING : Re-mounting snapd folder failed, please revert !!!!! "
echo "WARNING : Re-mounting snapd folder failed, please revert !!!!! "
echo "WARNING : Re-mounting snapd folder failed, please revert !!!!! "
echo "WARNING : Re-mounting snapd folder failed, please revert !!!!! "
echo "WARNING : Re-mounting snapd folder failed, please revert !!!!! "
# Trying to revert automatically
sudo cp /etc/fstab.bak /etc/fstab
sudo mount -a
sudo umount /var/lib/snapd
sudo mv /var/lib/snapd.bak /var/lib/snapd
echo "Files located at ~/snap/snapd should be removed, but it keeped for
recovery until you ,manually, reboot the system and make sure the service
is running correctly then manually you can remove that folder ~/snap/snapd
!!!!!!!!!!!!!!, you should do that manually."
fi
##############################################################################
# Take Care the pervious section may break the System !!!
##############################################################################
References
Custom disk location for certain snaps issue- ask ubuntu Question (Not best solution) Link
- Suggestion to use bind mount instead of symbolic links in moving snap directories Link
- Differences between bind mount and symbolic links Link
- Make bind mount permenant
add a comment |
Change snaps installation directory
This is a common issue that many asks for it, it seems snap developers are not intended to solve it soon, so some solutions was suggested as I search.
The first solution that was strongly refused by the community,but I didn't try, is to use symbolic link to link the directories which leads to snaps, this method seems not to work as the community replies asy that apparmom not working with symbolic links.
The Second solution is mount --bind
the directory /val/lib/snapd/snaps
which works fine for me with the already installed applications but failed to install new applications because I was moving the directory to another partition. That gave me an error about hard linking the snap application with the cache directory which is located in /var/lib/snapd/cache
. I don't know if this solution may work if the location are in the same partition or not; but this is the reason why I am moving the snap directory to free some space from partition to another one.
Third and working option is to move the /var/lib/snapd
directory as a whole then mount --bind
to it from another location and that worked for me and here is the steps.
Just a small note ,you already know, After the rsync is done in the below steps, you can backup the data inside /var/lib/snapd
to another location until the whole process is successfully done then you can remove the backup data if you want to free more space.
##############################################################################
# Take Care this section may break the System !!!
##############################################################################
##Move snap folder to Home instead of root.
#Create the directory : you can change the location
mkdir /home/$USER/snap/snapd
#Copy the data
sudo rsync -avzP /var/lib/snapd/ /home/$USER/snap/snapd/
#Do backups
sudo mv /var/lib/snapd /var/lib/snapd.bak
sudo cp /etc/fstab /etc/fstab.bak
#Change fstab (Change $USER with your name or change the path totally)
echo "/home/$USER/snap/snapd /var/lib/snapd none bind 0 0" | sudo tee -a /etc/fstab
#remount fstab Or reboot.
sudo mount -a
if ls /var/lib/snapd/ | grep snaps
then
echo "Re-mounting snapd folder is done successfully. !!!!"
sudo rm -rf /var/lib/snapd.bak
else
echo "WARNING : Re-mounting snapd folder failed, please revert !!!!! "
echo "WARNING : Re-mounting snapd folder failed, please revert !!!!! "
echo "WARNING : Re-mounting snapd folder failed, please revert !!!!! "
echo "WARNING : Re-mounting snapd folder failed, please revert !!!!! "
echo "WARNING : Re-mounting snapd folder failed, please revert !!!!! "
# Trying to revert automatically
sudo cp /etc/fstab.bak /etc/fstab
sudo mount -a
sudo umount /var/lib/snapd
sudo mv /var/lib/snapd.bak /var/lib/snapd
echo "Files located at ~/snap/snapd should be removed, but it keeped for
recovery until you ,manually, reboot the system and make sure the service
is running correctly then manually you can remove that folder ~/snap/snapd
!!!!!!!!!!!!!!, you should do that manually."
fi
##############################################################################
# Take Care the pervious section may break the System !!!
##############################################################################
References
Custom disk location for certain snaps issue- ask ubuntu Question (Not best solution) Link
- Suggestion to use bind mount instead of symbolic links in moving snap directories Link
- Differences between bind mount and symbolic links Link
- Make bind mount permenant
add a comment |
Change snaps installation directory
This is a common issue that many asks for it, it seems snap developers are not intended to solve it soon, so some solutions was suggested as I search.
The first solution that was strongly refused by the community,but I didn't try, is to use symbolic link to link the directories which leads to snaps, this method seems not to work as the community replies asy that apparmom not working with symbolic links.
The Second solution is mount --bind
the directory /val/lib/snapd/snaps
which works fine for me with the already installed applications but failed to install new applications because I was moving the directory to another partition. That gave me an error about hard linking the snap application with the cache directory which is located in /var/lib/snapd/cache
. I don't know if this solution may work if the location are in the same partition or not; but this is the reason why I am moving the snap directory to free some space from partition to another one.
Third and working option is to move the /var/lib/snapd
directory as a whole then mount --bind
to it from another location and that worked for me and here is the steps.
Just a small note ,you already know, After the rsync is done in the below steps, you can backup the data inside /var/lib/snapd
to another location until the whole process is successfully done then you can remove the backup data if you want to free more space.
##############################################################################
# Take Care this section may break the System !!!
##############################################################################
##Move snap folder to Home instead of root.
#Create the directory : you can change the location
mkdir /home/$USER/snap/snapd
#Copy the data
sudo rsync -avzP /var/lib/snapd/ /home/$USER/snap/snapd/
#Do backups
sudo mv /var/lib/snapd /var/lib/snapd.bak
sudo cp /etc/fstab /etc/fstab.bak
#Change fstab (Change $USER with your name or change the path totally)
echo "/home/$USER/snap/snapd /var/lib/snapd none bind 0 0" | sudo tee -a /etc/fstab
#remount fstab Or reboot.
sudo mount -a
if ls /var/lib/snapd/ | grep snaps
then
echo "Re-mounting snapd folder is done successfully. !!!!"
sudo rm -rf /var/lib/snapd.bak
else
echo "WARNING : Re-mounting snapd folder failed, please revert !!!!! "
echo "WARNING : Re-mounting snapd folder failed, please revert !!!!! "
echo "WARNING : Re-mounting snapd folder failed, please revert !!!!! "
echo "WARNING : Re-mounting snapd folder failed, please revert !!!!! "
echo "WARNING : Re-mounting snapd folder failed, please revert !!!!! "
# Trying to revert automatically
sudo cp /etc/fstab.bak /etc/fstab
sudo mount -a
sudo umount /var/lib/snapd
sudo mv /var/lib/snapd.bak /var/lib/snapd
echo "Files located at ~/snap/snapd should be removed, but it keeped for
recovery until you ,manually, reboot the system and make sure the service
is running correctly then manually you can remove that folder ~/snap/snapd
!!!!!!!!!!!!!!, you should do that manually."
fi
##############################################################################
# Take Care the pervious section may break the System !!!
##############################################################################
References
Custom disk location for certain snaps issue- ask ubuntu Question (Not best solution) Link
- Suggestion to use bind mount instead of symbolic links in moving snap directories Link
- Differences between bind mount and symbolic links Link
- Make bind mount permenant
Change snaps installation directory
This is a common issue that many asks for it, it seems snap developers are not intended to solve it soon, so some solutions was suggested as I search.
The first solution that was strongly refused by the community,but I didn't try, is to use symbolic link to link the directories which leads to snaps, this method seems not to work as the community replies asy that apparmom not working with symbolic links.
The Second solution is mount --bind
the directory /val/lib/snapd/snaps
which works fine for me with the already installed applications but failed to install new applications because I was moving the directory to another partition. That gave me an error about hard linking the snap application with the cache directory which is located in /var/lib/snapd/cache
. I don't know if this solution may work if the location are in the same partition or not; but this is the reason why I am moving the snap directory to free some space from partition to another one.
Third and working option is to move the /var/lib/snapd
directory as a whole then mount --bind
to it from another location and that worked for me and here is the steps.
Just a small note ,you already know, After the rsync is done in the below steps, you can backup the data inside /var/lib/snapd
to another location until the whole process is successfully done then you can remove the backup data if you want to free more space.
##############################################################################
# Take Care this section may break the System !!!
##############################################################################
##Move snap folder to Home instead of root.
#Create the directory : you can change the location
mkdir /home/$USER/snap/snapd
#Copy the data
sudo rsync -avzP /var/lib/snapd/ /home/$USER/snap/snapd/
#Do backups
sudo mv /var/lib/snapd /var/lib/snapd.bak
sudo cp /etc/fstab /etc/fstab.bak
#Change fstab (Change $USER with your name or change the path totally)
echo "/home/$USER/snap/snapd /var/lib/snapd none bind 0 0" | sudo tee -a /etc/fstab
#remount fstab Or reboot.
sudo mount -a
if ls /var/lib/snapd/ | grep snaps
then
echo "Re-mounting snapd folder is done successfully. !!!!"
sudo rm -rf /var/lib/snapd.bak
else
echo "WARNING : Re-mounting snapd folder failed, please revert !!!!! "
echo "WARNING : Re-mounting snapd folder failed, please revert !!!!! "
echo "WARNING : Re-mounting snapd folder failed, please revert !!!!! "
echo "WARNING : Re-mounting snapd folder failed, please revert !!!!! "
echo "WARNING : Re-mounting snapd folder failed, please revert !!!!! "
# Trying to revert automatically
sudo cp /etc/fstab.bak /etc/fstab
sudo mount -a
sudo umount /var/lib/snapd
sudo mv /var/lib/snapd.bak /var/lib/snapd
echo "Files located at ~/snap/snapd should be removed, but it keeped for
recovery until you ,manually, reboot the system and make sure the service
is running correctly then manually you can remove that folder ~/snap/snapd
!!!!!!!!!!!!!!, you should do that manually."
fi
##############################################################################
# Take Care the pervious section may break the System !!!
##############################################################################
References
Custom disk location for certain snaps issue- ask ubuntu Question (Not best solution) Link
- Suggestion to use bind mount instead of symbolic links in moving snap directories Link
- Differences between bind mount and symbolic links Link
- Make bind mount permenant
edited Mar 19 at 12:48
answered Aug 30 '18 at 20:40
Muhammad YusufMuhammad Yusuf
5115
5115
add a comment |
add a comment |
I finally found a way.
- First move the snap package to desired location. Let
snap_app.snap
as the app you want to move. Move the package from/var/lib/snapd/snaps/snap_app.snap
to~/snaps/snap_app.snap
. - Then you have to change mount option in
/etc/systemd/system/snap-snap_app-90.mount
,number in the file name may be vary. It has directiveWhat=/snap_app_loaction
under[Mount]
. Change it to your new snap package location. - Finally you have to symlink the snap package to
/var/lib/snapd/snaps/
.
Ex:
ln -s /var/lib/snapd/snaps/snap_app ~/snaps/snap_app.snap
Snap package is originally mount in to /snap/snap_app
directory. you can check it with mount
. Reboot your machine and you are all done.
add a comment |
I finally found a way.
- First move the snap package to desired location. Let
snap_app.snap
as the app you want to move. Move the package from/var/lib/snapd/snaps/snap_app.snap
to~/snaps/snap_app.snap
. - Then you have to change mount option in
/etc/systemd/system/snap-snap_app-90.mount
,number in the file name may be vary. It has directiveWhat=/snap_app_loaction
under[Mount]
. Change it to your new snap package location. - Finally you have to symlink the snap package to
/var/lib/snapd/snaps/
.
Ex:
ln -s /var/lib/snapd/snaps/snap_app ~/snaps/snap_app.snap
Snap package is originally mount in to /snap/snap_app
directory. you can check it with mount
. Reboot your machine and you are all done.
add a comment |
I finally found a way.
- First move the snap package to desired location. Let
snap_app.snap
as the app you want to move. Move the package from/var/lib/snapd/snaps/snap_app.snap
to~/snaps/snap_app.snap
. - Then you have to change mount option in
/etc/systemd/system/snap-snap_app-90.mount
,number in the file name may be vary. It has directiveWhat=/snap_app_loaction
under[Mount]
. Change it to your new snap package location. - Finally you have to symlink the snap package to
/var/lib/snapd/snaps/
.
Ex:
ln -s /var/lib/snapd/snaps/snap_app ~/snaps/snap_app.snap
Snap package is originally mount in to /snap/snap_app
directory. you can check it with mount
. Reboot your machine and you are all done.
I finally found a way.
- First move the snap package to desired location. Let
snap_app.snap
as the app you want to move. Move the package from/var/lib/snapd/snaps/snap_app.snap
to~/snaps/snap_app.snap
. - Then you have to change mount option in
/etc/systemd/system/snap-snap_app-90.mount
,number in the file name may be vary. It has directiveWhat=/snap_app_loaction
under[Mount]
. Change it to your new snap package location. - Finally you have to symlink the snap package to
/var/lib/snapd/snaps/
.
Ex:
ln -s /var/lib/snapd/snaps/snap_app ~/snaps/snap_app.snap
Snap package is originally mount in to /snap/snap_app
directory. you can check it with mount
. Reboot your machine and you are all done.
edited May 13 '18 at 17:43
user829468
answered Apr 30 '18 at 5:13
ultimatexultimatex
390121
390121
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1029562%2fmove-snap-packages-to-another-location-directory%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown