Preserve your path through DSM updates

Questions about IPKG can go here!
Forum rules
1) This is a user forum for Synology users to share experience/help out each other: if you need direct assistance from the Synology technical support team, please use the following form: ... p?lang=enu

2) To avoid putting users' DiskStation at risk, please don't paste links to any patches provided by our Support team as we will systematically remove them. Our Support team will provide the correct patch for your DiskStation model.
User avatar
I'm New!
I'm New!
Posts: 5
Joined: Fri Jan 16, 2015 9:19 am
Location: DK

Preserve your path through DSM updates

Unread post by fhdk » Fri Jan 16, 2015 10:29 am

A lot of people have experienced that ipkg/opkg stops working after DSM updates. This is due to DSM updates rewriting the path to the defaults. Nothing wrong about that.

If - however - you're keen to keep your path, then try this tip.

My bootstrapping has survived since early DSM4 and I think yours will too. Of course Synology could change that so no guaranties.

Always remember
Trust is good - verification is better
EDIT: apply to /root/.profile as well

Use your favorite ssh-client to connect to your diskstation as root

Code: Select all

ssh root@your-ds

Code: Select all

cp /etc/profile /etc/
vi /etc/profile
if you mess up in vi - it took me years to learn vi and I, occationally still screw up - use Esc:q! to save your b... and start vi again
Find the line reading

Code: Select all

Place the cursor under the first slash '/' and press i to insert text.

Modify path according to your environment

Press Esc to go back to command mode and then press uppercase Z twice to save and close vi.

For good measure - verify the changes you made

Code: Select all

cat /etc/profile
Activate the path modification by sourcing profile

Code: Select all

source /etc/profile
If using ipkg

Code: Select all

ipkg -v 
cp /etc/profile /etc/profile.pkg
If using opkg

Code: Select all

opkg -v 
cp /etc/profile /etc/profile.pkg
During the next DSM update your profile will probably be replaced by the update process and to prevent that you can make the file readonly by doing

Code: Select all

chmod 0444 /etc/profile
or next time your path fails do

Code: Select all

chmod 0644 /etc/profile 
cp /etc/profile.pkg /etc/profile
source /etc/profile
chmod 0444 /etc/profile
Frede H.

Preserve your path across DSM updates

I'm New!
I'm New!
Posts: 2
Joined: Wed Feb 03, 2016 11:26 pm

Re: Preserve your path through DSM updates

Unread post by Usagi » Wed Feb 03, 2016 11:55 pm

Great advice! One suggestion: move the location of ipkg further down the path. Something like:


It's important; it's the order that directories are looked at when you execute a path without specifying where, e.g.

Code: Select all

ls -la
Which one is picked up? And it's no good saying scripts should use absolute paths, because users install new packages in different places. Which is another reason for a good PATH setup.
  • All sbin folders should be for root-only use. A root version of a tool (in an sbin) should be used in preference to a user one
  • Except for /bin, which has most common, essential tools. You don't want to not use those by accident!
  • And /opt is less secure (you never know what a malicious ipkg install will drop in), so it shouldn't be looked at first
  • But Synology install some optional packages under various /usr locations, which you do want to override (e.g. php), so opt should come before those.
The precedence of /usr/bin <- /usr/syno/bin <- /usr/local/bin tells us that Synology see their versions of files as more important than user-installed versions (that's what "local" is for), which is why we need to put our more-important-than-Synology's files in yet another path, making us all confused as heck. There are a lot of pages on the web discussing what these directories are for, and suggested precedence.

Note as well that a non-root user shouldn't have sbin in their path.

Post Reply

Return to “IPKG”