View previous topic :: View next topic |
Author |
Message |
creaker l33t
Joined: 14 Jul 2012 Posts: 651
|
Posted: Sat Nov 02, 2013 3:56 am Post subject: sudo blkid is slow on first call |
|
|
sudo blkid takes up to 5 or 6 seconds when running first time after boot.
If I running some other command via sudo, e.g. sudo fdisk -l, it takes 1.5-2 secs.
These commands running much more faster if I issue them from root account:
blkid - 0.6 secs
fdisk -l - about 0.2 secs
If I issued these commands few times, time reduces to 0.01 - 0.02 secs
It seems the most part of this time eats sudo. How do I get it faster? The most obvious way is put something like "echo sudo blkid > /dev/null" in dummy script and call it at startup, but I think should be some another way. |
|
Back to top |
|
|
Gusar Advocate
Joined: 09 Apr 2005 Posts: 2665 Location: Slovenia
|
Posted: Sat Nov 02, 2013 10:36 am Post subject: |
|
|
It's not sudo that eats the time, it's blkid itself. When it runs for the first time, it scans all devices and creates a cache (/run/blkid/blkid.tab). That's why subsequent calls are faster, they don't need to scan anymore, they just read the cache.
Use lsblk instead of blkid, that one takes data from udev, so no need for a scan. It also does not need root privileges, so no need for sudo. |
|
Back to top |
|
|
creaker l33t
Joined: 14 Jul 2012 Posts: 651
|
Posted: Sun Nov 03, 2013 4:19 am Post subject: |
|
|
lsblk takes about 1.5 sec on every call (for my devices configuration). It is too much. And lsblk requires sudo because because being started from user lsblk doesn't shows some info (UUID, LABEL, FSTYPE). Probably for secure reasons. So lsblk is not suitable for me.
I prefer to have it slow at first call (sudo blkid) than to have it slow on every call (lsblk) |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|