by Pedro M. S. Oliveira | Jun 19, 2016 | Daily life, Linux
I use digiKam as my primary photo manager, it’s a great professional tool for those work with media. Maybe you are one of these and you didn’t even noticed, look at your mobile phone probably you have hundreds (maybe even thousands) of pictures on it. If you sum the ones you take with your camera it will be even more, so after a few years some of us may have more than 100.000 pictures.

This is why you need a photo manager and I would strongly recommend digiKam. I’ve been using it for years and I love it.
One part of taking pictures is be able to share them, digiKam supports exports to several social media web sites; Facebook, Igmur, Twitter, Flickr, etc.
Nevertheless the integration with Facebook is not working properly, and I doubt that the digiKam developers can do something here as it looks more of a Facebook issue. I’ve came out with a workaround that may help go around this issue if want to use the Facebook export function. Just follow these easy steps (I’ve done this with digiKam v5, but it will also work on v4):
- With your default browser log in to Facebook.
- Open digiKam from a console, just type digiKam on the command line.
- Inside digiKam go to menu export, choose export to Facebook.
- On the export dialog press change account.
- You’ll see that in the browser it just states success, nevertheless you don’t see the authentication link that you need to use to paste into the plugin dialogue.
- On the console where you started digiKam you have some of the debugging info of what is happening
- digiKam uses OAuth to authenticate with Facebook so look for a line like:
- OAuth URL: QUrl(“https://www.facebook.com/dialog/oauth?xxxxxxxxxxxxx
- Copy the content of that line starting on “https://…token” (without the quotes)
- Enable debug mode on your browser (I use Firefox CTRL+SHIFT+C or F12)
- On the debug window select network and persistent, see selected options on image bellow:

- Paste the URL that you got on this list step 7 on the browser
- On the debug window you should be able to see an entry like the one bellow, with a right click choose copy location

- Go to the digiKam Facebook export plugin window and just paste.
- YOU’RE DONE
Now you can share all those pictures to world 🙂
Just select the pictures you want, use the export plugin, choose your Facebook album (or create a new one within digiKam), choose to resize (or not the images). If you create a new album be careful with the the permissions you wish for the album, on the Add Album option you’ll be able to select who do you wish to share your pictures. By default all your friends will be able too see it, but this may not be right for all the albums so just choose careful your options, usually I choose only me and then on Facebook page I add who I want to share it with.
More about digiKam
- A professional digital photo management application for KDE (it will work on Linux, Windows and MacOS), which makes importing and organizing digital photos a “snap”. The photos are organized in albums which can be sorted chronologically, by folder layout or by custom collections
- Powerful, fast and automated tagging
- An easy-to-use interface is provided that enables you to connect your camera directly and preview, download and/or delete your images
- A Light Table function is provided. This tool assists artists and photographers with reviewing their work ensuring the highest quality only
- Common filters are available out of the box, with side by side previews
- Extensible by the use of plugins and recipes
Hope you enjoy this tool as much as I do.
Have fun,
Pedro Oliveira
by Pedro M. S. Oliveira | Feb 29, 2016 | Linux
Sometimes a software/hardware error will lock your SATA device/controller. You may just reboot your OS and wish for the best, but you may also only reset the affected device, not the full system, bellow is how you can achieve this.
Before you apply the following commands make sure you are not using the SATA/SCSI devices (ex. mounted filesystem, part of a RAID, LVM, BTRFS or ZFS volume). If the device is still in use please take action to stop it before you delete the device node or reset the SATA bus.
A device name of /dev/sdb
is assumed.
- Find out which controller the device is attached to (we’ll need this later):
# readlink /sys/block/sdb/device
../../../1:0:0:0
The interesting part if the answer is host1
, which identifies the controller.
# echo 1 > /sys/block/sdb/device/delete
This will remove the device from the bus (logically). Look in dmesg
for confirmation.
# echo "- - -" > /sys/class/scsi_host/host1/scan
host1
is the identifier from step one. Again, dmesg
should show the device being rediscovered.
Have fun,
Pedro Oliveira
by Pedro M. S. Oliveira | Mar 13, 2015 | Linux

Several time I’ve been asked how to rename a network card label on a Linux system, this can be achieve by following the steps mentioned bellow.
Stop networking
service networking stop
The network kernel module needs to be removed, but first you need to identify the right kernel module
sudo lspci -k | grep -i -A4
ethernet 04:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 07) Subsystem: Sony Corporation Device 9099
Kernel driver in use: r8169
Kernel modules: r8169
Reload rules
udevadm control –reload-rules
Edit udev rules by editing the /etc/udev/rules.d/*persistent-net.rules, in the example bellow we will set previous eth0 to eth5
# PCI device 0x10ec:0x8168 (r8169)
SUBSYSTEM==”net”, ACTION==”add”, DRIVERS==”?*”, ATTR{address}==”d4:3d:7e:xx:xx:xx”, ATTR{dev_id}==”0x0″, ATTR{type}==”1″, KERNEL==”eth*”, NAME=”eth5″
Remove the module in question
rmmod r8169
I’m using an realtek chip on my Vaio laptop, you should replace r8169 with the module in your system
Request device events from the kernel
udevadm trigger
Start network
service network restart
Et voila! You should have now a network card named eth5 on your system.
If you want to learn more about udev and udevadm check the info here or just type man udevadm on the command line.
Have fun,
Pedro Oliveira
by Pedro M. S. Oliveira | Sep 1, 2014 | Linux

If you see that your server is running out of swap you should add more RAM, nevertheless this is not always possible or maybe you need that extra amount for a very specific usage.
If this is the case you just need to add some more swap to your system. There are several usage cases I’ll just cover the 2 most common ones, with and without LVM.
Adding swap space without LVM
If you’re not using LVM and you don’t have any other location to put your new swap partition you can do it in one of the file systems available in the system.
-
Create a file that can be use as swap, if you have more than one file system available choose the one with best performance, in this case we will use /, the file will have 16GB and it will be called extra_swap.fs.
dd if=/dev/zero of=/extra_swap.fs count=16000 bs=1048576
mkswap /extra_swap.fs
-
Set the right permissions the file
chmod 600 /extra_swap.fs; chown root:root /extra_swap.fs
swapon /extra_swap.fs
-
Make it permanent (if needed)
echo “/extra_swap swap swap defaults 0 0 ” >> /etc/fstab
Adding swap space with LVM (method 1)
This method applies if you have LVM and you’re not able to disable swap (for instance production servers that have a high system load and memory usage)
-
Add a new volume with 16G (on volume called VolumeGroupName, you will need to adjust this to the desired volume group)
lvcreate -n extra_swap_lv -L16G VolumeGroupName
mkswap /dev/VolumeGroupName/extra_swap_lv
swapon /dev/VolumeGroupName/extra_swap_lv
-
Make it permanent (if needed)
echo ” /dev/VolumeGroupName/extra_swap_lv swap swap defaults 0 0 ” >> /etc/fstab
Adding swap space with LVM (method2)
If you are able to disable swap for a while (<10minutes) this is the recommended method.
-
Disable your current swap volume (please take in consideration that this can have a negative impact on performance, use with caution).
swapoff swap_volume_name
-
Expand your current volume, by adding 16GB to the volume swap_volume_name ( you will need to adjust this to the desired logical volume)
lvextend -L+16G swap_volume_name
mkswap /dev/VolumeGroupName/swap_volume_name
swapon /dev/VolumeGroupName/swap_volume_name
References
Check the excellent REHL manual about swap.
I hope you don’t have to go through this, as said before the best is to buy some new ram.
Cheers,
Pedro M. S. Oliveira
by Pedro M. S. Oliveira | Aug 20, 2014 | Linux

When you have large deployments with thousands of SSDs and spinning disks megacli utility provides a great help by having all the features and options available in a way that can be easily scripted and therefore automated.
This usage listing just has the most used and therefore limited set of options, but many more exist, please check the bottom for references.
Here are a few of those I find more useful, this will only apply to LSI Raid controllers.
Info:
This will list all the physical devices on adapter 0, if you have more than 1 controller in your server you may use -aAll.
megacli -PDList -a0
The same as above but it will be easy to find if you have 1 slot with errors.
megacli -PDList -a0 | grep “Slot\|Error”
This will display all the settings for the logical device 1 on controller 0.
megacli -LDInfo -L1 -a0
It will display the Consistency of the logical device 1 on controller 0.
megacli -LDGetProp Consistency -L1 -a0
Show rebuild progress on logical device 2 on adapter 0.
megacli -LDRecon ShowProg L2 -a0
List the cache status on adapter 0.
megacli -GetPreservedCacheList -a0
Display auto rebuild state on adapter 0.
megacli -AdpAutoRbld -Dsply -a0
Display missing physical devices on controller 0.
megacli -PdGetMissing -a0
Create a file called megacli_events_since_reboot that will contain all the events logged by all the controllers, this will include warnings, info messages and errors since last reboot.
megacli -AdpEventLog -GetSinceReboot -f megacli_events_since_reboot -aALL
Create a file called megacli_events_since_shutdown that will contain all the events logged by all the controllers, this will include warnings, info messages and errors since last shutdown.
megacli -AdpEventLog -GetSinceShutdown -f megacli_events_since_shutdown -aALL
Show the rebuild progress for the drive in slot 21, enclosure 32, all adapters (you can use -a0 if you just have one adapter).
megacli -pdrbld -showprog -physdrv[32:21] -aALL
Add/alter settings:
Set rebuild rate to 60% (1-100), this will mean that rebuild has higher priority than SO calls.
megacli -AdpSetProp RebuildRate 60 -a0
Discard the preserved cache for all logical devices on adapter 0.
megacli -DiscardPreservedCache -Lall -a0
Turn off device on slot 2 on enclosure 32, adapter 0.
megacli -PDOffline -PhysDrv [32:2] -a0
Turn on device on slot 2, enclosure 32, adapter 0.
megacli -PDOnline -PhysDrv [32:2] -a0
Flag the the device on slot 2, enclosure 32, adapter 0 as good to be used.
megacli -PDMakeGood -PhysDrv[32:2] -a0
Mark as missing drive on slote 2, enclosure 32 adapter 0
MegaCli -PDMarkMissing -PhysDrv [32:2] -a0
Prepare for removal drive on slote 2, enclosure 32 adapter 0
MegaCli -PdPrpRmv -PhysDrv [32:2] -a0
Replace the missing physical drive on slot 2, enclosure 32 on array 2, row 2, adapter 0.
You may find more information on the missing drive with the option -PdGetMissing (explained above).
megacli -PdReplaceMissing -physdrv [32:2] -Array=2 -row=2 -a0
Initial rebuild on slot 2, enclosure 32, adapter 0.
megacli -PDRbld -Start -PhysDrv[32:2] -a0
Create a logical device with raid 0 on physical device on slot 5, enclosure 32, adapter 0.
megacli -CfgLdAdd -r0[32:5] -a0
Set a dedicated hotspare device on logical device 1 (here it’s called array) using device on slot 18, on enclosure 32, adapter 0.
megacli -PDHSP -Set -Dedicated -Array1 -PhysDrv[32:18] -a0
Remove hotspare located on slot 6, enclosure 32, adapter 0.
megacli -PDHSP -Rmv -PhysDrv[32:6] -a0
Make drive on slot 18, enclosure 32, adapter 0 offline.
megacli -PDOffline -PhysDrv [32:18] -a0
Add 8 drives to an existing raid 6, in this case we are adding it to the logical volume 2 on adapter 0.
megacli -LDRecon start r6 -Add-PhysDrv[32:14,32:15,32:16,32:17,32:18,32:19,32:20,32:21] L2 -a0
Drive firmware update procedure:
* firmware upgrade can brick your device, first make your drive offline, this is MANDATORY if the drive is online
Make drive on slot 18, enclosure 32, adapter 0 offline
megacli -PDOffline -PhysDrv [1:18] -a0
Update firmware on drive at slot 18, enclosure 32 adapter 0, with binary file called fw.binary
megacli -PdFwDownload -PhysDrv[32:18] -f fw.bin -a0
Put drive back online.
megacli -PDOnline -PhysDrv [32:18] -a0
OS rescan logical device
After adding/removing/editing the logical volume, please note that you need to do this to all block devices you changed, in this case /dev/sda
echo 1 > /sys/block/sdx/device/rescan
More information:
http://hwraid.le-vert.net/wiki/LSIMegaRAIDSAS
http://mycusthelp.info/LSI/_cs/AnswerPreview.aspx?sSessionID=&inc=8275
http://artipc10.vub.ac.be/wordpress/2011/09/12/megacli-useful-commands/
Megacli official manual (PDF)
Cheers,
Pedro M. S. Oliveira