Some linux FS management tips

A few days back, I decided to upgrade from Fedora 19, to 24, and decided to do so using a usb stick. I downloaded the installer, and copied into the usb stick using dd.

A couple of days later, when I wanted to use that usb stick, I found out I could do nothing with it since its file system was write-protected. Trying to format the device did not work for the same reason. Using the disks utility in Fedora 24 showed 3 partitions in the usb stick, but trying to delete them would result in an error related to block size. The driver reported one size, but linux reported another. After a bit of searching, I came to an ask ubuntu answer that recommended using mkfs.vfat to solve the problem.

  • You can use mkfs.vfat, or one of the other mkfs.* programs to format a stubborn drive, or any other drive for that matter.

Being able to fix this problem, I decided to try with an old usb stick I got at a meet up back when Barnes & Noble were preparing to launch their android-based reader NOOK. The usb stick has never worked. It doesn’t mount, and reviewing it, there is no partition in it, let along a file system. I tried making a partition using the disk utility, but failed. I decided to use parted in the command line, but no luck, the device was write-protected. After a bit of searching, I found out you can use hdparm on write-protected devices to make them writeable. This did not work on my usb stick, which leaves me thinking that the device is just damaged.

  • You can use parted to make partitions in a device
  • You can use hdparm to set various option on drives, like write-protection.

Speaking about partitions, having a usb stick with more than one partition in it can be quite useful, and cool. Just remember that dumb windows doesn’t mount all of them, only the first one.

Other tips:

  • Use mount to find out how a device is mounted.
  • Use dosfsck to check and repair DOS file systems

I hope these tips prove useful at some point in your life as they have done in mine. Thanks to all that share wisdom around the net, what would we do without them…

Fixing Fedora 24 dnf problems.

The short story:

If you are getting the following error when trying to install software using dnf in fedora 24:

python3: /builddir/build/BUILD/hawkey-0.6.3/src/python/exception-py.c:101: ret2e: Assertion `0′ failed.

You may try doing:

dnf --disablerepo=updates <package>

Where <package> is the thing you are trying to install.

The long story:

Today, I was working on a site on my newly installed Fedora 24, but the drupal-based site failed to show anything after I updated a block. All non-admin pages would just show blank. So I started tracking code, and at some point it occurred to me that maybe I had to run the update script, which fixed the problem. I still don’t know why updating the content of a block would cause the site to break, but my guess is that it has to do with drupal caches. This because the function that failed is called “block_page_build”. Anyway, before I could run the update script, drupal was complaining about some missing php components, so I wanted to install them.

I went ahead and did

dnf install php-xml

but that returned an error (see the short story above). I didn’t know what to do, so I started searching the web, but found nothing. Then I turned to the dnf manual. In there I saw you can add -v to get a more verbose output. Running dnf with -v got me this:

cachedir: /var/cache/dnf
 Loaded plugins: config-manager, protected_packages, generate_completion_cache, Query, builddep, langpacks, debuginfo-install, download, needs-restarting, playground, reposync, noroot, copr
 langpacks: No languages are enabled
 Error reading file : /var/lib/dnf/plugins/langpacks/installed_langpacks as it does not exist
 initialized Langpacks plugin
 DNF version: 1.1.10
 repo: using cache for: fedora
 not found deltainfo for: Fedora 24 - x86_64
 not found updateinfo for: Fedora 24 - x86_64
 repo: using cache for: google-chrome
 not found deltainfo for: google-chrome
 not found updateinfo for: google-chrome
 repo: using cache for: updates
 python3: /builddir/build/BUILD/hawkey-0.6.3/src/python/exception-py.c:101: ret2e: Assertion `0' failed.

Look at that! the problem happens right after trying to use the updates repo.

I had read in the dnf man page that there is a location where the repo files are kept, so I went and moved all update repos out of the directory where they are kept, and run dnf install again. It worked.

Well, all that was left to do was find a proper way to ignore repos when doing installs, and the man page had the answer: –disablerepo

So, that is the story. Keep coding kids.

Quick Linux Notes

It’s been a while since I wrote anything here. Today I want to leave a few pieces of wisdom for those who like pocking around their computers; specifically linux systems.

Yesterday, after trying to change the applications menu in LXDE, I ended up learning a few things about linux. Just to be clear about my current setup, I am using Fedora 20, with LXDE. That should be all that matters here. If you are using anything else, you may want to see if these bits of knowledge apply for your system as well.

1) It is not that easy to edit the applications menu. By application menu, I mean the little menu with the fedora logo that by default shows on the left end of the panel in LXDE. I remember that in ubuntu, or more specifically in Gnome classic, you had Applications, System, and Places. You could right-click on Applications, and there would be an option there to edit the menu. In LXDE, that does not exist.

According to the Main Menu documentation in the LXDE website, since version 1.2.0 of PCManFM, you can use this file browser to edit the menu by editing the Applications folder. I tried it, all I got was a message saying the operation is not supported. It may be necessary to open it as admin, but I didn’t try.

Apparently, this menu is built from .desktop entries on certain locations.The previously mentioned documentation says that one of those places is ~/.local/share/applications, so I decided to create a new entry there. The same documentation says that you have to delete the .cache/menus/* files. It doesn’t really say it, but it gives you a script that does just that. After doing that, my menu just disappeared, and trying to access the Applications folder in PCManFM would give a menu cache error. I had to restart the computer so that the menu would show up again. After restarting the computer, my new entry was added to the menu. Odly enough, after I restarted the computer, the item I was trying to add was already there, and my entry was too, so the item was duplicated. I think it was there all along, I just didn’t see it…

If you want to understand exactly how the applications menu is built, you can try to take a look at the source code for the lxdepanel menu plugin.

You can also open ~/.config/lxpanel/LXDE/panels/panel. This is the config file for the panel, but it is recommended that you don’t edit that file directly. I did though, and nothing broke.

2) Restoring default Launchbar. A few days ago, I was playing with the settings on the lxdepanel. To open up these settings, just right-click on the panel, and select the Add/Remove Panel Items option. That time I removed the last application launcher, which has the logout button, and the lock screen button. In my opinion, without those two buttons, the panel looks “naked”. It bothered me at the beginning, but then I decided to just leave it like that after trying to find those buttons again without any luck. Yesterday, I stumbled upon the default menu settings. Just open /usr/share/lxpanel/profile/LXDE/panels/panel and you will see the default settings there. From that point, it was just a matter of copying and pasting the last item on to my profile’s panel config file.

3) Read some good python. If you go to /usr/lib/python2.7/ you can read the python library. I think it is nice to be able to just read and learn from the official library. In my computer there is also a python3.3 directory next to the puthon2.7 one.

4) Find your trash directory. A few years ago, digging around an old computer, I found the trash directory, but since then I’d forgotten its location. More recently, I had been wondering how the restore functionality works — If you open the Trash Can in PCManFM, and right-click on an element there, you will see an option that says Restore. I wanted to know how the computer knew where the item was taken from. Now I know.

If you go to ~/.local/share/Trash/ You will see 3 directories there. We are interested in two of them:

The files directory keeps the actual files that have been moved to the trash. When you right-click a file, and choose the Delete option, you are just basically moving the file to this directory.

The info directory keeps an info file for each file in the files directory. This info file has two pieces of information: the path where it came from, and the deletion date. It is that simple. When you restore an item, the system simply reads the info file, finds where it came from, and moves it back there again. Then it deletes its info file.

Never be afraid to dig around your computer. There are many goodies waiting to be discovered. Follow one simple rule, don’t modify anything that you don’t understand, and you should be OK. If you have a spare computer, you should install some linux disto and experiment there knowing that if you break it, nothing is lost.

Finally, here is a list of documents you may want to read (some of them are gnome related):

Fixing Monitors in LXDE

Since I installed Fedora, I’ve been unable to run the computer with both, the external monitor, and the laptop monitor at the same time. So, I’ve decided to just run the external monitor, since it is bigger. I haven’t really spent too much time looking for a solution to this problem, but the times I’ve tried fixing it, I haven’t had any success.

Earlier this week, after getting tired of seeing a high amount or RAM usage, I decided to stop using GNOME, and use OpenBox without a desktop environment instead. This was easy to do. In the log screen, there is an option on the bottom where I have the options to use GNOME, LXDE, and OpenBox. I simply chose OpenBox. However, despite seeing a huge improvement on memory consumption, I was rather soon disappointed by the amount of configuration I had to do every time I turned the computer on. Sometimes I would have to log out, log into LXDE, change the monitor settings there, and see if that would work. The problem was that OpenBox would try to use both monitors, even when the external monitor was not plugged in! This cause me to not be able to see the windows, which by default would get placed in the area of the external monitor, but this would not get any signal.

As you may imagine, this quickly became too much trouble. Especially since there were no actual memory problems while running GNOME, I was just simply trying to reduce memory consumption.

Motivated by these inconveniences, I decided to give LXDE a try. LXDE also uses OpenBox as the window manager, but LXDE is a desktop environment, which means there is a lot of added benefit, such as a desktop, and a panel. All of this, while keeping memory consumption surprisingly low.

However, I made a mistake. I opened the Monitor Settings, and set the laptop monitor off by default, and the external monitor on by default. This had the same effect as OpenBox did. This time, however, I could not log into LXDE to fix it, since I was already in LXDE. I was effectively unable to see anything, since the output was being sent to the external monitor, but the monitor was receiving no signal.

Knowing that the settings must be saved somewhere, I decided to look into it. I opened the tty (ctrl+alt+F1), which fortunately runs on the laptop monitor, logged in, and decided to look in the ~/.config directory. I reviewed a couple of files before I decided to open ~/.config/autostart/lxrandr-autostart.desktop

This file has settings to start xrandr. Once I opened this file, it was just a matter of turning off the VGA-0 monitor, and turning on the LVDS monitor, which was turned off. Once I did this, I restarted the computer (sudo shutdown -r now), and I was able to login with a desktop. Then I opened the Monitor Settings again, and set the monitors to show only the external one, and apply the settings, but not save them.

I think I will have to do this every time I turn the computer on, but it may be worth it.

I still need to look for a solution that allows me to have both monitors at the same time, but for now that is not something I want to spend a lot of time on.

Scanning with Canon N1220U on Fedora 18

I needed to scan a document today. Scanning is something I do very rarely, so I don’t need to buy a fancy scanner. I have a Canon N1220U that I got from my father over 6 years ago. I don’t know how long he had it for before passing it on, but it works well. It has decent quality image, and it is not bulky, so I can easily put it away in a little box. I used it a few times back when I was using ubuntu on my Dell laptop. It just worked out of the box, or at least that is what I remember.

However, today, when I tried to used it it would not work. Fedora comes with simple scan, which is the same applications I used in Ubuntu, but simple scan was not detecting the device. I decided to open the console and fire up a search for scan utilities:

yum search scanner

I got back a bunch of results. The promising one was sane-backends-drivers-scanners.x86_64, so I did a sudo yum install, but that reported that the package was already installed, and up to date. There was nothing to do.

I decided to do a quick search, and I found this: but I didn’t think it would help so I skipped it and went back to the terminal. I decided to see what packages were available by the sane package, so I typed san and then hit tab twice. I got this list:

sanbox saned sane-find-scanner

I decided to give sane-find-scanner a try. sane was detecting the scanner, so the problem should be somewhere else. I decided to install another package from the list I got when I did the yum search.

sudo yum install xsane.x86_64

This installs the xsane package and the dependency xsane-common. I had tried xsane before, although at the moment I didn’t remember it. xsane is insane. It has lots of options, and getting the document to scan cleanly can be hard, you may need to play around with the contrast, and light settings. Heck, xsane even has histograms!

xsane is great if you are doing some high quality scanning, but if you just want to scan a document to email it, xsane is a bit of an overkill. I decided to give simple scan another try. I opened it again, hit scan, and it worked. Why? I don’t know. It thought maybe something to do with xsane, but it continued working even after xsane and its dependency were uninstalled, so I don’t know what made it work, but I’m glad that it works now.