Futurama

Quote

Professor: Being captain is about intuition and heart. A good captain can’t have either one. That’s why cold, logical Bender is perfect for the job.

Bender: Well, I do think of human life as expendable.

Dad Strikes Again

I’ll be honest, this post is mostly to gloat.

The night after the other parental unit’s disastrous night in the tent, I offered the kids a second camping trip to the back yard.

Alpha slept all night… in the tent.  (willingly!)

Beta slept all night… in the tent.

I slept all night… in the tent.

I was the last one to nod off, and that was before eleven p.m.  And we all slept until after sunrise.

Working with hidden files and directories

I had a problem.  My home directory is huge – 9 gigs – but I don’t know what’s taking up all that room. My porn stash is on another partition where my wife doesn’t know to look, so something is taking up a lot of room and I want to know what and why.

Oh yeah, I know how to check the size of a directory – use du ('du -sh .') for the usage of current directory (including all sub directories).  And, to see the size for every individual directory in the current directory, 'du -sh *'.  Easy peasy.

But that didn’t tell me what I needed to know, since the total size of all visible directories was less than a quarter of the used space.  That’s where hidden directories come into play.

Now, in the unix world, there isn’t a special file permission to hide a file or directory.  You just name it with a leading dot, like '.my_hidden_stuff', and most utilities won’t display it.  There’s nothing intrinsically hidden about it, though.  You can view them easily enough, e.g. 'ls -a' will show everything, including the “hidden” stuff.

What if you want to see just the hidden stuff?  It’s not as simple as saying 'ls -a .*', since that includes '.' (the current directory) and '..' (the parent directory), too.  Some utilities, like du, will then combine arguments with a common root, which means you get the summary for the current directory, but none of the hidden files broken out.

Solution

In bash, at least, you can include simple regular expressions on the command line.  (Remember, in unix, your command line is pre-processed by the shell (bash, csh, tcsh, etc.) and the expanded items are given to the program. DOS/Windows, by contrast, the expansion and processing is the responsibility of the program and command.com (or cmd.exe) does little processing itself.

The regex for all dot files, minus ‘.’ and ‘..’, is '.[^.]*' (which basically says, “start with a dot, and the next character must exist but cannot be a dot, and then anything goes after that”).

So, my command to see how much space each of my hidden directories are using, is

du -shx .[^.]*

Five cents

I have ‘fortune’ run at login for all of my machines.  These are the fortunes I saw, one right after the other, while hopping from machine to another:

Our country has plenty of good five-cent cigars, but the trouble is they charge fifteen cents for them.

Then, when I connected to the next machine…

What this country needs is a good five cent ANYTHING!

My computers are getting better at coordination.  I had best keep them happy.

Device is being exclusively used by the host computer

I say:

$ VBoxManage controlvm <vbox uuid> usbattach <device uuid>

VirtualBox says:

VBoxManage: error: USB device '<device>' with UUID <uuid> is being exclusively used by the host computer

I say:

$ gpasswd -a <vbox user> plugdev

and log out the vbox user completely (no vms running, no logged-in shell).

And now the device is available and add-able.

“device is busy…”

I’m working on a fun little project to set up a custom-made bootable usb key. But I ran into a little trouble after using a chroot, due to /dev and mount --rbind.

# mount -t proc none /mnt/gentoo/proc
# mount --rbind /sys /mnt/gentoo/sys
# mount --rbind /dev /mnt/gentoo/dev
# mount -t tmpfs tmpfs /mnt/gentoo/tmp
# mount -t tmpfs tmpfs /mnt/gentoo/var/tmp
# mount -t tmpfs tmpfs /mnt/gentoo/usr/src
# mount | grep gentoo
/dev/sde1 on /mnt/gentoo type ext2 (rw)
none on /mnt/gentoo/proc type proc (rw)
/sys on /mnt/gentoo/sys type none (rw,bind,rbind)
/dev on /mnt/gentoo/dev type none (rw,bind,rbind)
tmpfs on /mnt/gentoo/tmp type tmpfs (rw)
tmpfs on /mnt/gentoo/var/tmp type tmpfs (rw)
tmpfs on /mnt/gentoo/usr/src type tmpfs (rw)
# chroot /mnt/gentoo

All’s well, until it’s time to exit the chroot and unmount everything..

# umount /mnt/gentoo/usr/src /mnt/gentoo/var/tmp \
/mnt/gentoo/tmp /mnt/gentoo/sys /mnt/gentoo/proc \
/mnt/gentoo/dev /mnt/gentoo
umount: /mnt/gentoo/dev: device is busy.
       (In some cases useful info about processes that use
        the device is found by lsof(8) or fuser(1))

I don’t see anything mounted under there. Fuuuu…

# mount | grep gentoo
/dev/sde1 on /mnt/gentoo type ext2 (rw)
# lsof|grep gentoo
# fuser -m /mnt/gentoo
/mnt/gentoo:
#

Rebooting at this stage is inconvenient, but will certainly solve the problem. But what is left using /mnt/gentoo/dev?
Googling around, and seeing some people with similar problems, finally lit a light bulb above my head:

# cat /proc/mounts | awk '{print $2}' | grep gentoo
/mnt/gentoo
/mnt/gentoo/dev
/mnt/gentoo/dev/pts
/mnt/gentoo/dev/shm

So mount --rbind worked as advertised and recursively mounted /dev and everything sub-mounted. And I didn’t realize that udev mounted other things under /dev without updating /etc/mtab. Sigh.

# umount /mnt/gentoo/dev/shm /mnt/gentoo/dev/pts /mnt/gentoo/dev /mnt/gentoo
#

And now I can get on with my life.

And another birthday down

Alpha child vacillated on how to celebrate her birthday.  (Giving her a choice was mistake.)  Four days before, we finally settled on a simple party at the local, recently-opened mini-golf course.

It might be worth mentioning that Alpha has been officially diagnosed with Asperger’s (that’s worth a whole bunch of posts on it’s own), so a party with a “script” to follow is a very, very good idea.

So mini-golf has a implicit script – everyone knows what to do, there’s something to keep busy with at every turn, and it’s easy to avoid uncomfortable moments.  The party worked.  We met a couple of Alpha’s friends from school, everyone had a good time, and we ended the day on a high note.  Plus, it turns out that Alpha loves laser tag – also offered at the place.  Beta and her friend kept busy too.

And a shout out to our friends Sam and Joanne, who came in from out of state with their son and were most helpful.  I suck with unfamiliar kids, but Sam is actually quite effective with them.

Pics to come later.  Maybe M has a few, I never remember to take snapshots.