Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
sudo blkid is slow on first call
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
creaker
l33t
l33t


Joined: 14 Jul 2012
Posts: 651

PostPosted: Sat Nov 02, 2013 3:56 am    Post subject: sudo blkid is slow on first call Reply with quote

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
View user's profile Send private message
Gusar
Advocate
Advocate


Joined: 09 Apr 2005
Posts: 2665
Location: Slovenia

PostPosted: Sat Nov 02, 2013 10:36 am    Post subject: Reply with quote

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
View user's profile Send private message
creaker
l33t
l33t


Joined: 14 Jul 2012
Posts: 651

PostPosted: Sun Nov 03, 2013 4:19 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
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