Setting a user and group for Samba drives

April 14, 2018

The last time I tried to set a user and password on my Samba drive, I ran into a strange problem: even though my credentials were correct, I was still using the user and group I was logged in as, rather than the one I’d stored with the Samba config.

Luckily, these days there’s an easy way around it in /etc/fstab:

//mysvr/music /music cifs uid=1000,gid=1000,credentials=/etc/samba/credentials/mysvr

 

Simply adding the uid= and gid= lines fixed up the problem for me.

Advertisements

What the hell, Gnome? Canonical?

January 1, 2018

Today when I started working on my desktop, I saw a crash in gom-media-tracker. What? Why is there a media tracker on my desktop?

I learned this is part of Gnome (what? Why is there a media tracker in Gnome?) and it’s included in Ubuntu 16.04 LTS (why is Canonical including tracking software in Ubuntu?)

Screw that. I removed it.

$ sudo apt remove gnome-online-miners
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  gnome-documents gnome-online-miners gnome-photos ubuntu-gnome-desktop
0 upgraded, 0 newly installed, 4 to remove and 0 not upgraded.
After this operation, 6,472 kB disk space will be freed.
Do you want to continue? [Y/n] y
dpkg: warning: files list file for package 'fonts-gfs-complutum' missing; assuming package has no files currently installed
(Reading database ... 493027 files and directories currently installed.)
Removing ubuntu-gnome-desktop (0.58.3) ...
Removing gnome-documents (3.18.3-0ubuntu0.16.04.1) ...
Removing gnome-photos (3.18.2-1) ...
Removing gnome-online-miners (3.14.3-1ubuntu2) ...
Processing triggers for libglib2.0-0:amd64 (2.48.2-0ubuntu1) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for hicolor-icon-theme (0.15-0ubuntu1) ...
Processing triggers for gnome-menus (3.13.3-6ubuntu3.1) ...
Processing triggers for desktop-file-utils (0.22-1ubuntu5.1) ...
Processing triggers for bamfdaemon (0.5.3~bzr0+16.04.20160824-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for mime-support (3.59ubuntu1) ...
$ 

Now that I’ve done that, I don’t appear to have lost anything I use. (Why is an optional packages forcing other packages out?)

I don’t want random tracking software on my machine.

wiki.gnome.org/Projects/Tracker, you suck. Gnome, you suck. Canonical, you suck.


Upgrading Mythbuntu from Trusty to Xenial

June 25, 2017

Yesterday I took the plunge and upgraded my Mythbuntu install from Trusty to Xenial. Except for a few heart-stopping moments, it went smoothly.

Things I wish I’d known about the upgrade

  • There’s a bug with upgrading MySQL when you have the Mythbuntu tweaks installed. As a result, the upgrade fails to install MySQL properly – and then everything looks broken. Ouch. You can find out more about the defect here. The symptom is the message “[ERROR] unknown variable ‘table_cache=128’ ” which scrolls off the screen when you do an upgrade (or dpkg –configure -a). The fix is to change
table_cache = 128

to

table_open_cache = 128

in /etc/mysql/conf.d/mythtv-tweaks.cnf.

  • During the upgrade, I got prompted for which user to use for the database. (With the recommendation to use “root” if you don’t thoroughly understand the permissions models.) But of course “root” didn’t work. What did work was the default, debian-sys-maint.
  • After install, lirc didn’t work. I uninstalled lirc using Mythbuntu Control Center and rebooted; that appeared to fix things and now my Streamzap remote is being detected as a keyboard device with the appropriate mappings. (I get a warning about a plugin using MCC, but hey, it seems to work.)
  • Next, I got warnings using apt. Probably due to the upgrade failure, I had a file called 50unattended-upgrades.ucf-old left over in /etc/apt/apt.conf.d. Nuking that fixed things.
  • It looks as if mythfrontend and mythbackend are using different users now. I’m not sure why, but some day I’ll need to go through and fix permissions / unify those two users.
  • I had to go into mythtv-setup and assign directories for music and music art. (Since I didn’t have an art directory, I created one under my music directory. That seems to work.)
  • Probably as a result of the botched upgrade, mythweb was broken. I installed php7.0-mysql, then removed/installed mythweb and it was working again.
  • Finally, I tried to look into mythconverg. In this release the admin user is debian-sys-maint, and the password for that user is stored in /etc/mysql/debian.cnf.

Ubuntu 16.04.1 – cron mail not working

September 19, 2016

I recently ran into a strange issue. I wasn’t getting mail from cron – even though I could mail myself locally without incident. My cron daemon was running fine, and I had MAILTO=user specified in the crontab.

The first piece of advice everyone says when you search about this is “make sure you can send mail to yourself.” And I could – using mail or mailx and sending to andrew. And if you try searching for help after that, you get lost in the weeds of people trying to send mail to Gmail, and setting up postfix, and going insane.

After a little poking around, I noticed this in my /var/log/mail.log:

Sep 12 04:28:01 myserver postfix/qmgr[2902]: A292710059B: 
   from=<root@myserver.mydomain.com>, size=800, nrcpt=1 (queue active)
Sep 12 04:28:01 myserver postfix/error[20839]: A292710059B:
   to=<andrew@myserver.mydomain.com>, orig_to=<andrew>, relay=none, delay=1.4,
   delays=1/0.12/0/0.25, dsn=5.0.0, status=bounced (myserver.mydomain.com)

I’ve been faking my domain name and it looks like when I upgraded to Ubuntu 16.04.1 things stopped working. (I have a sneaking suspicion that the upgrade process yanked the domain address out of /etc/hosts. But maybe cron changed and started using my FQDN instead of my local mail address.)

But even after changing my hosts file from:

127.0.1.1 myserver

to:

127.0.1.1 myserver myserver.mydomain.com

things weren’t mailing again. I finally changed my crontab to MAILTO=andrew@localhost instead. But that seems kind of bogus. If you’ve got better ideas (/etc/mailname maybe?) let me know.


Formatting an SD card as exfat

December 17, 2015

On Android, by default SD cards with 64M or more on them are formatted as exfat, while smaller cards are formatted as fat32. But what if you want to force an SD card to be exfat? Here’s how to do it. You’ll need a Linux box.

  1. sudo apt-get install fuse-exfat exfat-utils
  2. Partition the card if it’s not already partitioned
  3. sudo mkfs -texfat /dev/sdf1

Mostly this post is to remind me that the new format is called exfat, since I keep forgetting that.


Rescuing a hard drive with ddrescue

November 5, 2015

A while ago, one of my Windows hard drives gave up the ghost. Unfortunately, the last backup I’d done on it was a while ago. Lesson #1: Don’t forget to back things up.

The hard drive had been staring at me on my desk for a while, so I decided to see what I could do about it. My searches led me to CGSecurity and two pages on their website: TestDisk and the Damaged Hard Disk page. They in turn led me to ddrescue.

Here’s what I’ve done so far:

  1. Have a nice server that has a motherboard advanced enough to hot-mount SATA drives. This is very useful if the disk disappears now and then and needs to be remounted.
  2. Mount the drive in a spare slot in the server.
  3. sudo apt-get install lzip because ddrescue is stored in lzip archives
  4. Grab the latest stable build from the ddrescue download directory. (I used version 1.20.)
  5. lzip -d then extract the ddrescue tar file.
  6. cd into the ddrescue directory and configure; make
  7. Next I tried plain ddrescue: sudo ./ddrescue -n /dev/sde /data/sde_rescue sde_map
  8. That seemed to be having trouble, so I reversed direction: sudo ./ddrescue -n -R /dev/sde /data/sde_rescue sde_map
  9. That whirred for a few days. Next I decided to try mounting as a raw device, on the theory that the kernel cache might be obscuring things.
  10. sudo /sbin/modprobe raw
  11. sudo raw /dev/raw/raw1 /dev/sde
  12. sudo ./ddrescue -n -R /dev/raw/raw1 /data/sde_rescue sde_map

So far I’ve theoretically recovered 130M of my 500M disk. When reading the raw device, I don’t get an estimate of time remaining (which was about a year). It will be interesting to see if this actually gets recovered, or if I’m just grabbing random numbers at this point.


Changing user and group ID on Unix

May 2, 2015

Recently I’ve set up a file server for both Windows and Linux. When I went to mount the file system on Linux, things were broken – because I hadn’t paid attention to user ID and group ID when I created users on my different Unix machines.

So I needed to change the UID and GID of a user, then update the files. Luckily, someone had already done the work:

https://muffinresearch.co.uk/linux-changing-uids-and-gids-for-user/

In short:

usermod -u <NEWUID> <LOGIN>    
groupmod -g <NEWGID> <GROUP>
find / -user <OLDUID> -exec chown -h <NEWUID> {} \;
find / -group <OLDGID> -exec chgrp -h <NEWGID> {} \;
usermod -g <NEWGID> <LOGIN>

One wrinkle that I wasn’t expecting: you can’t change the user ID of a user who has a running process. So I had to create a second user with adduser, add that user as in /etc/groups for sudo, log in as that user, and then change the user ID of the original user.

When I ran this on Ubuntu and Raspbian, I saw about 4 errors in /proc which I ignored. There’s probably a faster way to do to this using xargs rather than running -exec each time, but I was a little worried I might exceed what I could pass in on a command line (I had hundreds of thousands of files) so I let it do its thing.