Sunday, September 4, 2016

Saving and restoring bash "shopt" options

Saving and restoring bash "shopt" options

The following command prints out a series of shopt commands to restore your current options.

shopt -p 

as a a series of shopt commands like so

shopt -s xxx
shopt -u yyy
shopt -u zzz

commands.  One minor problem is these commands are newline separated.   

opts=$(shopt -p)
echo $opts     # BAD ack newlines get converted to spaces
echo "$opts"   # GOOD double quotes keep the newlines.

In trying to use $opts, bash does word splitting and turns the newlines into spaces because consecutive newlines, spaces and tabs are converted into a single space.  However enclosing $opts in double quotes preserves the newlines.

someBashFn() {
  local prevOpts=$(shopt -p)

  ... your code which uses shopt ...

  eval "$prevOpts"   # restore the options
}

Thursday, August 25, 2016

Formatting large hard drives (2+ TB) in linux

There are two steps
  • create a partition using parted  (the key is to use the -a optimized flag)
  • make the filesystem using mke2fs (or mke4fs or mkfs.e4fs)
The venerable fdisk does not handle disks larger than 2TB so you must use parted.

Parted

Here's what we will do
  1. find the name of the disk you want to format with fdisk
  2. use parted to 
    • create a partition table (which is called a "label" in parted, ugh) of type gpt 
    • make the partition (which only reserves space on the disk)
    • (optional) name the partition in the partition table
  3. format the partition 
    • show options to get the most space out of the partition
Here are the commands:

  $ sudo bash       # become root, avoid all the sudo prefixing

  # fdisk -l        # find the disk you want to partition
     ... find the disk you want to partition 
     ... if it is new, there will be no partitions associated with it
     ... lets assume the desired disk is /dev/sdY


// Next, It is important to use -a optimized, other wise you will get the dreaded
// Warning: The resulting partition is not properly aligned for best performance.
// You can try to calculate how to align the partitions but it is 10 minutes of digging around 
// disk specs and worse, none of the advice worked from various web sites (and here).
// Instead let parted do the work.
// Printing the start and end of the disk showed an offset remains a mystery to me,

  # parted -a optimized /dev/sdY
    // Create the partition table of type gpt
 (parted) mklabel gpt

    // Create a primary partition from the first sector to the last.
    // It is important to use 1 not 0 as the first partition if you want "optimal alignment"

 (parted) part primary 1 -1
  // The next step is optional - give your partition a name.  The name is solely for
    // your convenience.  It is only visible in parted (and possiblly fdisk)
  (parted) name 1 your-name-of-your-partition
  (parted) print

  (parted) quit

mke2fs or mke4fs

The default parameters to mke2fs are very outdated for 
  1. reserving emergency administrator space (the -m flag) and 
  2. the bookkeeping for files (the -i flag which is the avg file size for each inode)
These values assumes files are small text and disks are smaller than 10GB (!).

With a 2+TB disk, 1% space for admin is enough (20 GB) and the average file size is at least 16KB (think of all the photos, videos, music and PDFs).

    # mkfs.ext4 -m 1 -i 16384 dev/sdY

If you want to squeeze very last bit of space out of your disk and you mostly have large files, say averaging 64KB) and you do not use extended file attributes then you can use

    # mkfs.ext4 -m 0 -i 65536 -I 128 dev/sdY

Details: In modern linux kernels the default inode is 256 bytes.  The file system needs one inode per file and the inodes are reserved when you format the partition.  If you run out of inodes, you cannot create any new files (the disk will appear to be "full").  However, inodes use space.  E.g. if you use the default of an inode (256B) for every 4K of data, then 1/17 ~ 6% of your space is used for inodes.  On a 4TB disk, this is enough inodes for 1 billion files.

If we reserve an 256-byte inode for every 64K then only 256/(256+64K) = 1/257 = 0.5% of disk is spent on inodes.

Finally, the -I flag indicates to use the old inode size of 128, in which case you lose the ability to set extended Linux file attributes which are rarely used, thus reducing the inode overhead by half again.  


Sunday, March 2, 2014

Mac OS X - fix boot problem due to hard disk errors

Returning from a 2 week trip to the Singapore and Myanmar (aka Burma), my Mac Book Pro 13 which had sat at home powered off the whole time, refused to boot.  About 15% throught the progress bar when booting, the Mac would power off.

Looking up keyboard shortcuts, I held down the 'd' key to show diagnostics, which indicated the mac was failing during the automatic fsck (disk drive file system check).

The solution:

  1. Boot to single user, by holding the 's' key once the startup gong sounds.
  2. Try /sbin/fsck -fy which forces a fix answering "yes" to all questions.  Repeat this command until no errors are reported.
  3. In my case, the "catalog" tree structure was broken enough that fsck stopped without fixing the problem.
  4. I ran fsck_hfs directly which has additional options not supported by the generic fsck, shown by man fsck_hfs.  In the following command, I used the raw device (/dev/rdisk0s2, for my laptop, yours maybe different) for my hard drive that the previous fsck had shown in step 2:
       /sbin/fsck_hfs -Rc /dev/rdisk0s2After this I reran /sbin/fsck -fy to verify the disk had been reconstructed.
  5. Restart the computer by exiting out of single user mode:  exit

Saturday, February 1, 2014

Linux: Samba starts before eth0 is up and will not serve... ack.

My main SMB server, call it sammy, was upgraded to Linux Mint 13 system, but it was not serving.

I noticed that after I started the system (sammy), but before I had logged in, I could not ssh into sammy.  After logging in to sammy on the console, I was able to ssh into it.  It was a surprise to not find it from other SMB clients.

After much debugging, the main clue came when I was on the SMB server, sammy.  Connecting via localhost loopback IP address, I see the SMB service fine when I ran
  smbclient -L localhost -N
but when I tried to connect via the ether IP address, nothing showed up 
  smbclient -L sammy -N   I

The long and short of it was samba was starting before the ethernet interface was getting assigned, so the smb server was unaware of that interface.  Restarting samba solved the problem via
   service smbd restart
   service nmbd restart

Saturday, January 25, 2014

Transfer files off your Android phone: use Droid NAS as an SMB server with a Mac or Linux

If you are getting a getting rid of an Android phone  or device, it's best to make a full backup before you factory reset it.   While, there are many ways to transfer files off of your Android device, I wanted to get everything by viewing my Android files from another "client" computer (which is where I'll copy the Android data).  The steps are:
  1. Export the Android files via the SMB/ CIFS protocol (which is how Windows shares files across computers)
  2. Mount the exported Android  "shares" (the root folders/directories) on a client computer, which can be either Mac or Linux, so you can see the Android files.  (It has been reported that windows will not work as Droid NAS exports via a non standard port; I have not verified if there is a workaround.)  Note: to use Linux you need to be able to run programs as root via sudo.
  3. Copy the files on the client from the Android device to your client computer, using rsync.
(1) Export or expose your Android data to another computer.
There are many Android programs that run as an SMB server.  The one I used is Droid NAS.   After starting the server in Droid NAS, it shows the IP of the Android device and a port, for example 7777, which is the value I will use in the following examples.  There are three profiles "Home", "Work", and "Cafe".  I chose "Home".  I also went to Settings (the gear icon on the bottom left) and specified the wi-fi network on which to export, and I added a user and password, which I'll assume are "uuu" and "pppp" in the examples.  To get these new settings applied, I stopped the server and restarted it.

(2) To see the Android files do either of the following:
On a Mac, in the finder, you should see the Android device in the Shared Section.
Since we added a user and password, you'll have to connect as user uuu with your password pppp.  The finder should show several "shares" that you can "connect" or "mount" on your Mac.

On my phone, I had four shares: Camera, Downloads, Photos and SD Card.  You may have more or fewer shares.

On a linux machine: Verify your linux kernel supports cifs.  You should see a line with cifs when you run
  % grep cifs /proc/filesystems
If you don't see anything, try using smbfs instead of cifs.  If you still don't see anything, you need a newer kernel.  Stop now.

(Optionally, though I never got this to work) verify you can see the Droid NAS as an SMB server:
 % smbclient -L Android-IP-address -p port -U uuu

Mount a share on the linux client.  First make a directory on the Linux cilent where the Android files will be mounted, say /mnt/Android/Camera.
  % sudo mkdir -p /mnt/Android/Camera

 Mount the Android share via the following command.
  % sudo mount -o ro,port=7777 -t cifs -o username=uuu,password=ppp //Android-IP-address/Camera /mnt/Android/Camera

(3)  Copy the files to your client computer.
On the mac:
  (a)  drag the Android shares where you want to copy them.  If this does not work, perhaps because you have too many files and the finder seems to time out getting all the files to copy
  (b) Open a terminal on your Mac and type
   % df
  See where the Android shares are mounted (look in the last column), e.g. /Volumes/Camera
  Copy each share them with rsync via
  % rsync -axv /Volumes/Camera /folder/holding/the/backup

On the linux machine, run rsync
  % rsync -axv /mnt/Android/Camera /folder/holding/the/backup

Sunday, February 24, 2013

Upgrading your TiVo HD hard drive with a bigger HD

TL;DR:

For Tivo HD (652160) and Series 3.   Get the command via the interactive command generator at MFS.  Download the boot disk from 2009, from the release announcement (see the attachment).  

If you are putting in a 1-2TB HD the command should look like:
       backup -qTao  -  /dev/sd-original | restore -s 500  -xzpi  -   /dev/sd-upgrade

Run fdisk -l to determine your hard drives.  Replace /dev/sd-original with your original drive, which will be something like /dev/sda, and also for /dev/sd-upgrade.

The -s 500 indicates to use 500MB as swap, which is larger than the default 127(Failed: I though I could use "restore -r 8 ... " to indicate the block size in MB for recordings, but the value has to be between 1 and 4.   With HD recordings being 5+GB, I thought using -r 8 or even -r 16 would help free up memory and would cause minimal internal fragmentation.)

The maximum size you can upgrade to is 2TB as of 2013.  Choose a HD with low noise and low power consumption (heat); typically you want an "Eco" or "green" drive that has a slow RPM, say 5400 or even 4200.  This is what Tivo uses.  All HDs can record and play back streaming material at 10X the speed needed.  Try to avoid a 7200 RPM drive if possible.

For a longer explanation on the TiVo HD / Premiere: read Ross Walker's detailed blog or for the new Premiere TiVos see the community discussion with links to the newest software.

For newer Tivos, see the community posting and also this newer update about using the JMFS tools. -------------------------- 
 Ignore, since this is all said better and with pictures at Ross Walker's blog.
Details:

Tivo lets you upgrade from the factory-installed hard drive to your own hard drive.    Why do this?  It's much much cheaper.  And you get a much bigger hard drive, such as 2T.


There is a lot of old information on the web, that evolved as Tivo introduced various models.  But since the switch to digital, aka HD, TV, you need a "newer" TiVo that has a digital tuner.
We got a bunch of the HD (which are the same as the Series 3).  Since then, Tivo has come out with a "Premiere" line, which this blog post does not cover.

Here's what to do to upgrade your Tivo HD or Series 3:

0) Need: computer, large SATA drive, Torx-10 and Torx-15 screwdrivers, blank CD, CD burner.

1) Find a computer that can boot from CD, that you can plug 2 SATA drives into.  It's OK to put these drives into external USB enclosures and hook them up via USB.  I have only done this hooking the HDs to a M/B directly via the SATA connectors.

Download the tools from MFS.  This is a tech blog, get the linux distro and burn to a CD.

2) Get a Torx 10 and Torx 15 screwdriver.  Open your Tivo box, via the 6 torx-10 screws on the back.  Slide the top case toward you by 1/4 to 1/2" and pull the sides outward gently and wiggle the case off.

3) Remove the original HD from the TiVo.:  Remove the SATA / power cable from the HD.
The HD is fastened by via 4 Torx-10 screws. Pull the HD + metal holder out.  Remove the metal stand held to the HD by 4 Torx-15 screws.

4) Hook up the original drive and the new drive to your computer, and boot the computer with your MFS CD.

5) Finish this.

Monday, February 11, 2013

Keebox W150NR V2.0R routers are not the DLink DIR-300vB

TL;DR: this Keebox is not the same as a DLink DIR-300vB.  It is not DD-WRT compatible as of Feb 2013.

----------------------------------------------------
Fry's was selling Keebox W150NR routers for very little ($10 or $15) in late 2012.  I got two.

My knowledgable friend Google told me these were rebranded DLink DIR-300vB routers.  The important things to know about these routers are
  1. The version matters, as version A is completely different hardware than version B.  The Keebox is a DIR-300vB.
  2. There are some pretty bad security vulnerabilities with some (all?) of this model of DLink routers that will not be fixed.  
  3. Some people managed to install DD-WRT on their Keebox routers by using the DIR-300vB instructions with minor modifications, but I cannot, since the routers I got behave differently than the others.  Sigh.

My Keebox router

My routers are labelled: HW: V2.0R FW:2.002 (note the 'R' in the version)


My Keebox behaves differently than the DIR-300vB and also differently from the other Keebox routers mentioned in this DD-WRT post.
  1. On normal power up, it has IP 192.168.10.1 as others have mentioned.
  2. When booting in the "Emergency Room Web Interface", the router comes up with IP 192.168.123.254 (not 192.168.10.1).  To access the upload page, you must let the router assign an IP address to your computer via DHCP.  Then you can visit http://192.168.123.254   
  3. However, none of the DD-WRT images would upload correctly.  I tried uploading
    from every variant of browser on both Win and Mac.
  4. The factory firmware does not have the security vulnerabilities of DLink-300vB , e.g. /command.php is not open.



It turns out this Keebox V2.0R is not the same as a DLink DIR-300vB.  I opened the router, by removing the two black pads on the bottom, and unscrewing the two screws underneath.  The SoC is a Ralink RT5350F (not a RT3050F) and  there is a chip missing relative to the reference photo.  After I figured this out, a better Google search corroborated my findings.

The Keebox summary: version 1 is good, but version 2 is not good.   Thus HW: V1.0R is a DLink DIR-300vB, but HW V2.0R is possibly a DIR-600v5 which does not support DD-WRT as of 2/2013.

Sunday, February 10, 2013

Choosing home wireless security settings

TL;DR:  Choose WPA2-PSK with AES encyption for home use.  Choose an ASCII encryption key with a made up phrase, like "I live at 1234 Main in California".  Disable WPS if possible.

When setting up a new wifi router, you have to choose how to set up your wireless security settings.
WPA2 AES is good;  WPA is mediocre.  Everything else offers minimal security as software to break the encryption in a few days or even hours exist for WPS (which does a poor job of setting up WPA/WPA2) and WEP.

Home settings

For WPA and WPA2, the home variants are referred to as "PSK" or "Personal".
Here's a run down of the various choices without any of the techno babble.


GradeProtocolVariantEncryptThoughts
AWPA 2PSK/PersonalAESThe best choice.
BWPA 2PSK/PersonalTKIPNot as good as AES
C+WPAPSK/PersonalAESBetter than WEP
C-WPAPSK/PersonalTKIPBetter than WEP
D+WPS

Most routers are flawed. Disable if possible.
D-WEP64/128 bit

AVOID, WEP has been cracked.
FNone

Publically announce everything you do.

Enterprise or Corporate settings.

There are also wireless security choices where there is a centralized key server, namely for companies or enterprises. These go by the name "Enterprise" or "Radius" or "802.1x". Confusingly, note that plain "WPA2" and "WPA" typically refer to the enterprise variants.

N/AWPA 2""/Enterprise/RadiusNot for home use
N/AWPA""/Enterprise/RadiusNot for home use

Sunday, February 3, 2013

Installing the Win 8 boot loader on a hard drive

Situation: I upgraded Win XP to Win 8 Pro and installed Win 8 to a new blank HD.  Win XP was on the "old" hard D: and Win 8 is now on C:.  The problem is that the Win 8 installer put the boot loader for Win 8 on the old drive D:, so I need to have both hard drives in the system.  I want to remove D: from the system, since I won't be using it anymore.  Thus, 
I needed to install the Win 8 boot loader on a target drive C:
As copied from Justin Coon's reply in this posting, the steps you need are
  1. Boot into Win 8, with both hard drives.
  2. Mark the target drive as active, in Disk Management, via
    • Control Panels | Administrative Tools | Computer Management | Disk Management  ... or ...
    • On the Desktop | Win + X key | Disk Management
    • right click on C: 
    • Mark Partition as Active
  3. Install the boot loader on C: via
    bcdboot
    windows-root-folder /s
    target-drive-to-boot-from,
    namely in my case 

    bcdboot c:\windows /s c:
  4. And that should do it.  Shutdown Win 8.  Power off your machine.  Remove the old hard drive D:, and then power up.

Friday, February 1, 2013

Windows 8 Desktop sounds OK esp with Ninite

I've been wondering whether getting Win 8 Pro make sense, as I have some of the $15 upgrades MS was giving out to recent Win 7 buyers.   Historically the Pro version offers features the Home version does not, but having used XP Home for years, the Pro features are of fairly low priority.

Pros:
 - It boots faster and is more secure.
 - Built in AV in the form of MS Defender
 - The Hyper-V virtual machine built in allowing guest OSs to run.  This saves one from having to download the free and good VirtualBox

Cons:
 - MS removed the Start Menu on the desktop but there are 3rd party solutions.   See Solutions.

Solutions

1) I've recently learned of Ninite which installs all sorts of desirable free software (e.g. Chrome and/or Firefox, Free A/V, OpenOffice, Google Earth, Skype, etc) without any crapware or toolbars or any other junk.  

For Win 8, it also installs ClassicStart, a popular Start Menu replacement.

Why has it taken me so long to learn of this?

Tuesday, January 15, 2013

Upgrade the Mac Mini 2011 to 16GB of RAM for $70

As the wikipedia page on the Mac Mini indicates, the 2011 (and apparently the 2010) model can handle 16GB of RAM.  When it was introduced, 16GB of DDR3 RAM was more expensive as the Mac Mini itself.  But these days, you can get 16GB (2 X 8GB) DDR3 SO-DIMMS for well under $80.  I just bought some Patriot RAM from Fry's for $59.  I also just got AData SO-DIMMS from Newegg for $65.

The main constraints on the maximum RAM a system can use are
  1. the maximum RAM the CPU can address.  For Intel CPUs, see ark.intel.com.   It is sometimes tricky to determine the actual CPU your system has.  In the case of the 2011 MacMini, the i5-2410M CPU can handle upto 16GB via 2 DIMMS or "channels".
  2. the address lines on the motherboard M/B.  In most cases, the M/B carries all the address lines from the CPU to the DIMMs.
  3. the manufacterer's BIOS or EFI, when booting Windows.  I'm fairly sure Linux probes the hardware itself so even if the BIOS underreported the amount of RAM, Linux would detect it all.
The speed of the RAM is not terribly important, except under very rare circumstances, in which case you'll know who you are.  For perspective, faster RAM might get you 1-2%; having more RAM so you do not  swapping will get you a 400-2000% improvement.   Also, DIMMs contain information on their speed and the memory controller will adjust accordingly.  

I usually just buy what is cheap from a decent brand (Crucial, Patriot, AData, ....).

Friday, December 28, 2012

Set up / Fixing / tweaking Linux Mint 13 Xfce

This post is a list of the software I need to install and the parts of the UI that I need to tweak.

Control key:

Make the left caps locks (left of the "A") be a control key.

To fix this immediately run:
setxkbmap -option 'ctrl:nocaps'
or
setxkbmap -option 'ctrl:swapcaps'

To fix this at startup everytime:
  1. Menu | Settings | Session and Startup | Application Autostart
  2. Hit the [+ Add] button.  In the pop up dialog:
  3. Make up a "name" and "description" of your liking, such as "Cntl <-> Caps".  For the "command" , copy one of the preceding setxkbmap commands.
The values allowed in the -options flag for setxdbmap
are in /usr/share/X11/xkb/rules/base.lst


Add Google to Linux Mint Firefox search engine choices:

The search bar (the one in the upper right) no longer has Google as an option.  Ugh.
I was using Firefox 17.0.1.
  1. Visit http://www.linuxmint.com/searchengines.php
  2. Click on the Google icon at the bottom.
  3. Go to the search bar and choose Google (which now be an option).
Add Google chrome as a software package

From a google search on "Chrome PPA", I've copied the results from http://www.howopensource.com/2011/10/install-google-chrome-in-ubuntu-11-10-11-04-10-10-10-04/
 and http://www.ubuntuupdates.org/ppa/google_chrome.

Install the PPAs for google chrome which tell Ubuntu/Mint where to look for new releases. There are three commands.

wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -

sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'

sudo apt-get update 



Then choose the distribution of your choice, by choosing one of the following.  Choose "stable" if not sure.

sudo apt-get install google-chrome-stable

sudo apt-get install google-chrome-beta

sudo apt-get install google-chrome-unstable

UI: move the task panel or task bar

Right click on the panel (not an applet in the pane) and in panel preferences, uncheck the Lock Panel box.  Once this is done, at both ends of the panel there is a small dotted region, which can be used to select the panel itself, rather than an applet.

Select the panel and move it to one of the edges.

UI: focus follows mouse

Adjust the setting in The Menu | Settings | Window Manager | Focus


UI: adjust the layout of your workspaces

If necessary, add the workspaces applet to the "task bar" or "panel", via right click on the panel:
Add New Items | Workspace Switcher | ... | Close "Add New Items"

To adjust the number of rows in which the workspaces are laid out:
Workspace switcher applet (right click) | Properties | Number of Rows


UI:  keyboard shortcuts for the desktop GUI (not application specific)

The settings are at:

The Menu | Settings | Window Manager | Keyboard


UI: How to lock your screen

There are several ways to lock your screen:
 - The underlying command to run is xflock4.  You can run this from a terminal if curious.

- Use the default keyboard short cut cntl-alt-delete.  This shortcut is set in 

The Menu | Settings | Keyboard | Application Shortcuts

 - On the right side of the panel, you should see your login name.  Left-click on this to get a menu.  One entry should be "Lock-screen".

 - Right click on the panel (on the ends) and choose

  Add New Items  || Action buttons  ||  Add  || Close

 Right click on the added Button || Properties  || First button action : "Lock Screen"

Choosing a Linux distro with LT support, a stable and lean 2D UI: Linux Mint 13 Xfce

Summary: The xfce 4 desktop does what I need and Linux Mint 13 Xfce is my distro of choice.

My priorities were
  1. Long term support, so that I continue to get updates and security patches over the next 3+ years.   I've moved to Ubuntu and so the distro choice would likely be their 12.04 LTS release or a derivative there of.
  2. A stable 2D UI.  I cut my teeth on X11 (before Linux) and very early Linux distros (Slackware).  I don't need a fancy GUI environment.  The 3D effects are a waste on me.   In the past, I eventually got used to Gnome2 based environments due to Ubuntu 9.x and 10.x releases, but the recent switch to Unity was not acceptable to me.
I decided to try Xfce which many distros support as their lean, but modern UI option. Since many lean GUIs have been around for years, the fact that many distros have chosen Xfce as their lean UI is encouraging for its long term support.

I compared Ubuntu LTS 12.04 Xfce versus Linux Mint 13 "Maya" Xfce, which is based on the ubuntu release.  Mint came with a newer version of Xfce (4.10 versus 4.08) and just looked better.  And the Mint default system menu was nicely filled out opposed to the more spartan Ubuntu menus.  Easy choice.


Saturday, December 22, 2012

The ASUS R704A 17" laptop is the same as an X75A-104A.


TL;DR: The big take aways are:
  1. I've opened my R704A-RB31 and yes there is a single empty DIMM slot.
  2. The Asus R704A is the same as the Asus X75A-Z104.

I bought this laptop / notebook at Fry's on a great sale ($378), hoping to upgrade the RAM to 8GB, as it comes with 4GB.

Dilemma:
Both Fry's and Newegg web sites said there was one empty DIMM slot allowing upto 8GB.  Good.

Many, many other sites on the internet including microcenter indicated there was one 4GB DIMM soldered to the M/B and that was it.  No upgrading.  Bad.

The ASUS website had no information on the R704A.  No specs.  No downloads.  No nothing.   Ack.

Several weeks later, the ASUS support site still had limited information but I was able to download a user manual, which was labelled X75A-104A, which is another 17" laptop ASUS makes.  And this model has full specs/info on the Asus support site.  And it says there is a single DIMM slot allowing upto 8GB of RAM.  Here's a link to all  manuals and documentation  for this laptop.  Choose other tabs too.

To get at the RAM and hard drive, unscrew and remove the two screws holding the big panel which covers the front half of the bottom.  Pull the plastic toward the front and it should just slide off.

Armed with this knowledge I finally opened the laptop and indeed there is an unfilled user accessible memory slot.

AMD A4/A6/A8 CPUs can only take 16GB of RAM

The motherboards for these CPUs claim upto 64GB of non-ECC RAM but in practice the Asus MBs have only verified 1, 2 or 4GB DIMMS.  With 4 memory slots, that is 16GB total.  In short the M/B only work with upto 4GB DIMMS and this applies to all ASUS FM slot M/Bs.

I tried putting in an 8GB DIMM and it was simply not recognized.  So much for 32GB, let alone 64GB of RAM in a A6 system.

Sunday, December 16, 2012

Samba issue: nmbd cannot bind to the broadcast address

I guess I hadn't run Samba on my Linux box for a while as it failed to run.

Checking /var/logs/samba/log.{s,n}mbd I found

2012/12/15 16:34:29.461856,  0] lib/util_sock.c:880(open_socket_in)
  bind failed on port 137 socket_addr = xx.yy.zz.255.
  Error = Cannot assign requested address

[2012/12/15 16:34:29.429656,  0] nmbd/nmbd_subnetdb.c:118(make_subnet)
  nmbd_subnetdb:make_subnet()
    Failed to open nmb bcast socket on interface xx.yy.zz.255 for port 137.  Error was Cannot assign requested address


A quick Google search on the actual error message, "Failed to open nmb bcast socket on"
pulled up various articles that Samba 3.5.x and possibly some of 3.6.x had a bug.

The fix:
Change my interface specifications in my smb.conf file

# Work around for bug
   interfaces = lo eth0
 

# This doesnn't work in 3.5.4 as we can't bind to the eth0 bcast addr !?
#    interfaces = 127.0.0.1/8 xx.yy.zz.vv/mm

Sunday, July 17, 2011

Tweaking firefox

1) Have a lot of tabs? Worried about FF slowing your machine to a crawl on a restart? Change FF so it only keeps the active tabs in memory. And at startup it only loads the active tab on each window.

Visit the URL about:config, proceed past the warning, and then set
browser.sessionstore.max_concurrent_tabs
to 0 (zero) by double clicking on that value (you can search for "max" first to narrow the list of variables).

2) Install the add-on "Noscript". This add on is an inconvenience initially and occasionally afterwards, as it is a Javascript blocker. When you visit a site you trust for the first time, you'll have to let Noscript know that you want to allow JS from that site. But if you inadvertantly visit or get redirected to a shady site, it will block the JS saving your rear. Choose "Tools" -> "Add-ons" and then search for "Noscript". Install it and restart the browser. By default it will install a little icon in your address bar.

Saturday, June 11, 2011

Airlink ar410w is not compatible with DD-WRT

Having just installed DD-WRT and then Tomato on a new Netgear 3500L, it was exciting to run a real OS on a router. I also had an old Airlink 101 AR410W still running, but upon checking it only supported WPA TKIP, not the newer WPA2 AES (avoid TKIP). I vaguely recall WPA being not that secure, and wanted WPA2. But there is no firmware upgrade from the manufacturer product page. I realized Tomato only supports a small subset of routers using modern CPUs, but could I upgrade to DD-WRT as it supports a fair number of routers.

A bit of hunting around shows that
  1. This router is the same as the DLink DI-624 which is specifically not supported by DD-WRT, in large part because it only has 1MB of flash, and you need 2MB just to run the mini version and 4MB to run anything full featured.
  2. The specs are it has a Atheros 2313 CPU + radio, Marvell 88E6060 ethernet switch, and Macronix/AMD 29LV800BTC-90 1MB Flash.
  3. The FCC ID from the label is: O7J-WLRT2454-QAO
In any case, it is clear I cannot install DD-WRT on this pre-2006 router.

Sunday, January 2, 2011

Changing the user id of an existing user

There is an existing user Adam with user id 1000 that you want to change to user id 2345.
Adam is the only user on the system and is an admin, of course. Adam also has an encrypted home directory.

1) Log in as Adam.
2) Create a new admin user, say call Newsome.
3) Log out as Adam and log in as Newsome. Ensure that "sudo id" succeeds as Newsome in case you mess something up with Adam's login
4) Run System -> Administration -> Users and Groups
5) Choose Adam, then Advanced Settings. In the Advanced User Settings window choose "Advanced" and then change the user id.
6) Hit "OK" and then "Close" on the User Settings tab.
7) Run "grep Adam /etc/passwd" and verify the new user id is 2345.
8) Run "ls -ln /home/Adam" and verify the owner id is 2345.
9) In a terminal go to and run "sudo chown Adam /home/.ecryptfs/Adam"
10) In a terminal, login as Adam and verify that all the files in the home directory exist.

Ubuntu note: Normal user start at 1000. Anything below that is considered reserved, but you are free to use those IDs. On the login screen, if your ID is below 1000, you'll have to choose "Other user" (or something like that) and enter your username, which is arguable slightly more secure but more annoying.

Friday, November 12, 2010

Enabling ECC memory in Linux without BIOS support

I build computers for reliability and low(er) power; I've been doing so long before the somewhat recent green kick. In particular, I want ECC memory, and a lot of it, and a good power supply. I don't care about CPU speed or the video card. I like to leave my linux box up for months, even a year. And ECC memory is necessary for this. I used to have to buy specific chipsets for Intel processors, but in the past 3 years I have chosen AMD processors solely largely because they support ECC. The AMD Athlon CPUs have a built-in memory controller and it has supported unbuffered ECC RAM all this time. So any motherboard is largely fine... or so I thought.

I finally assembled my new system with a Phenom II X4 and a lovely Gigabyte GA-MA785GM-US2H MB with nice copper wiring and good capacitors. I chose this M/B since it has the latest AMD 785G video, and it supports DDR2 which was cheaper than DDR3 when buying ECC RAM (I've been buying Kingston ECC RAM, and for this system it was 8G of KVR533D2E4K2/4G since it was amazingly cheap.). But this stupid mother ***** does not support ECC in the BIOS, which is a bit odd as the CPU talks to the memory directly. Apparently Gigabyte does not provide for this in their BIOS settings http://forums.amd.com/forum/messageview.cfm?catid=21&threadid=123883, see the response from Gigabyte.

I had the following fails:
  1. Running memtest86+ v4.10, the memory is not recognized as ECC. Argh.
  2. Flashing the latest BIOS for this M/B did not help. Argh.
  3. I tried adding the kernel boot parameter to GRUB ecc_enable_override, but that did not work. Argh.
To make a long story short, the solution is that you can force the Linux kernel module that enables ECC to load via:

% modprobe -v amd64_edac_mod ecc_enable_override=1
To verify that the ECC was turned on run
% dmesg | grep -i edac
And you should see something like:

[ 658.399849] EDAC amd64_edac: Ver: 3.3.0 Sep 19 2010
[ 658.400082] EDAC amd64: This node reports that Memory ECC is currently disabled, set F3x44[22] (0000:00:18.3).
[ 658.400102] EDAC amd64: Forcing ECC checking on!
[ 658.400198] EDAC MC: F10h CPU detected
[ 658.400230] EDAC MC: DCT0 chip selects:
[ 658.400236] EDAC MC: 0: 1024MB 1: 1024MB
[ 658.400242] EDAC MC: 2: 1024MB 3: 1024MB
[ 658.400246] EDAC MC: 4: 0MB 5: 0MB
[ 658.400251] EDAC MC: 6: 0MB 7: 0MB
[ 658.400254] EDAC MC: DCT1 chip selects:
[ 658.400259] EDAC MC: 0: 1024MB 1: 1024MB
[ 658.400263] EDAC MC: 2: 1024MB 3: 1024MB
[ 658.400267] EDAC MC: 4: 0MB 5: 0MB
[ 658.400271] EDAC MC: 6: 0MB 7: 0MB
[ 658.400333] EDAC amd64: This node reports that DRAM ECC is currently Disabled; ENABLING now
[ 658.400339] EDAC amd64: Hardware accepted DRAM ECC Enable
[ 658.401685] EDAC MC0: Giving out device to 'amd64_edac' 'Family 10h': DEV 0000:00:18.2
[ 658.401731] EDAC PCI0: Giving out device to module 'amd64_edac' controller 'EDAC PCI controller': DEV '0000:00:18.2' (POLLED)

The Linux modules that deal with ECC are labelled "enad". Some other commands you can run, are lsmod (to verify the amd enad module is loaded) and dmidecode --type memory (to see how the BIOS is reporting memory, which shows non-ECC RAM in this particular case).