Archive

Archive for the ‘howto’ Category

Raspberry Pi as a Car AirPlay Receiver

June 22nd, 2013 No comments

This can also be done with an Airport Express and a DC inverter. Using a RaspberryPi is slightly less expensive and more fun to setup.

 

Parts List:

  • $25/$35 – RaspberryPi (model A or B)
  • $8 – case
  • $9 – car usb power adapter
  • $3 – usb cable
  • $12 – usb wifi adapter (148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter)
  • $6 – 8 GB SD memory card
  • $1 – 3.5″ audio cable

Total: $64/$74 (depending on rPI model)

 

There are a lot of high quality howto guides around the net, but I haven’t found one that combines all the necessary steps. These steps are:

  1. Install Raspbian
  2. Setup Shairport
  3. Setup Wi-Fi in AP mode
  4. Configure Raspbian to boot into read-only mode
  5. Configure iPhone/iPad

1. Install Raspbian to the SD Card

2. Install shairport and configure audio:

3. Setup Wi-Fi Adapter in AP mode

/etc/hostapd/hostapd.conf
interface=wlan0
driver=nl80211
ssid=CarPi
hw_mode=g
channel=11
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=password
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

4. Configure Raspbian to boot into read-only mode

5. Connect to the rPI network

  • Select the Wi-Fi network on your iPhone. It’ll connect to the network, but without DNS and Gateway settings you’ll still be able to use your cellular connection for data, so iTunes Match, Pandora, etc will still work.

Results

At this point it works great during home testing. I can stream audio from the internet on my phone and have it play on the 3.5mm audio jack on the Raspberry Pi without stuttering or buffering. However, car testing has not worked well. I get frequent drops, which I’m attributing to Wi-Fi interference. I’m thinking a 5GHz Wi-Fi connecting will fix this problem, but I’ve yet to find a mini adapter that will work.

 

 

 

Categories: howto

parted

April 25th, 2011 No comments

Create a single, aligned partition on a drive larger than 2TB.

% sudo parted /dev/sdx
(parted)% mklabel gpt
(parted)% mkpart primary 1 -1
Categories: file systems, howto

Replace an LVM Drive with a Larger One

March 21st, 2009 2 comments

LVM allows you to hot add devices to expand volume space. It also allows you to hot remove devices, as long as there are enough free extents in the volume group (vgdisplay) to move data around. Here I’m going to replace a 400 GB drive (sdg) with a 750 GB one (sdh) from logical volume “backup” on volume group “disks”. It does not matter how many hard drives are in the volume group, and the filesystem can stay mounted.

  1. Partition and create a physical volume on the device
    1
    
    $ sudo pvcreate /dev/sdh1
  2. Add the new drive to the volume group
    1
    
    $ sudo vgextend disks /dev/sdh1
  3. Move all extents from the old drive to the new one (this step may take hours)
    1
    
    $ sudo pvmove -v /dev/sdg1
  4. Remove the old drive
    1
    
    $ sudo vgreduce disks /dev/sdg1
  5. Expand the logical volume to use the rest of the disk. In this case, another 350GB.
    1
    
    $ sudo lvextend -l+83463 /dev/disks/backup
  6. Expand the file system
    1
    2
    
    $ sudo resize2fs /dev/disks/backup
    $ sudo xfs_growfs /dev/disks/backup
Categories: file systems, howto, LVM

Start Folding@Home on Boot with Screen on Ubuntu Linux

March 1st, 2008 No comments

Quick instructions to get Folding@home (or any other program) to run at boot before user login on Ubuntu Linux. This probably works on other distros with an rc.local file too.

1. Install F@H client, mine is in /opt/folding

2. Create a simple script, I called mine folding.sh and is only has:

1
2
3
#!/bin/bash
cd /opt/folding
./fah6 -smp

3. Put the screen command in /etc/rc.local. This will execute as user nick (su nick -c), “-dmS” will create the session detached and name it folding, and “bash –rcfile” will allow the screen session to keep running even if folding quits.

1
su nick -c "screen -dmS folding bash --rcfile /home/nick/bin/folding.sh"

Folding@home now starts whenever the computer boots, before anyone logs in. Nick can reattach to it and  control it or watch the progress by running “screen -r folding”.

Categories: howto, shell

Tripwire on Ubuntu 6.06

December 23rd, 2007 No comments

Quick instructions to getting Tripwire installed and running on Ubuntu 6.06 LTS (Dapper Drake). For more detailed instructions check out this site.

1. Install Tripwire. Say Yes to everything, and create some passwords.

% sudo apt-get install tripwire
% sudo tripwire -m i

2. Fix the policy. I was getting many errors that looked like:

### Warning: File system error.
### Filename: /root/.Xauthority
### No such file or directory

I removed the non-existent files from the policy file with the following commands:

% sudo cp /etc/tripwire/twpol.txt /etc/tripwire/twpol.txt.bak
% sudo vim /etc/tripwire/twpol.txt
% sudo tripwire --update-policy -Z low /etc/tripwire/twpol.txt

Later, when you need to update the database, such as after running updates (adjust the date and number from then end of the file, or sometimes you can just drop the whole -r flag):

% sudo tripwire -m u -r /var/lib/tripwire/report/closetbox64-20071223-133927.twr

By default, Tripwire will be set to email whenever it sees changes. To quickly check the status, run:

% sudo tripwire --check

Categories: howto, server

Find the Model Number of Your DVD Burner in Linux

May 14th, 2007 No comments

$ cdrdao drive-info /dev/scd0

Cdrdao version 1.2.2 – (C) Andreas Mueller <andreas@daneb.de>
SCSI interface library – (C) Joerg Schilling
Paranoia DAE library – (C) Monty

Check http://cdrdao.sourceforge.net/drives.html#dt for current driver tables.

Using libscg version ‘ubuntu-0.8ubuntu1’

/dev/cdrw: LITE-ON DVDRW LH-20A1S Rev: 9L02
Using driver: Generic SCSI-3/MMC – Version 2.0 (options 0x0000)

Maximum reading speed: 8467 kB/s
Current reading speed: 8467 kB/s
Maximum writing speed: 8467 kB/s
Current writing speed: 8467 kB/s
BurnProof supported: yes
JustLink supported: no
JustSpeed supported: yes

Categories: hardware, howto

Install the Ubuntu Studio Theme in Ubuntu Feisty

May 11th, 2007 No comments

Instructions here.

Categories: howto

Download Ubuntu 7.04

April 19th, 2007 No comments

Download all the Ubuntu i386 and AMD64 ISOs with one command.

wget ftp://mirrors.kernel.org/ubuntu-releases/7.04/ubuntu-7.04-{desktop,server,alternate}-{i386,amd64}.iso

Categories: howto

Swap Hard Drives with Ubuntu 6.10

January 16th, 2007 No comments

I recently upgrade my main workstation’s hard drive under Ubuntu 6.10 and noticed a couple things changed during the process. Here are my instructions for a fast and reliably hard drive swap. I’m using SATA drives without LVM using the default Ubuntu install and partition options for this howto.

  1. Prepare
    1. Shutdown your machine and install your new hard drive. Don’t mess with your current hard drive (yet)
    2. Find a LiveCD, I used the Ubuntu 6.10 LiveCD, it matched my OS, but it doesn’t have to. Knoppix should work fine.
    3. Boot using your LiveCD
    4. After booting, open a terminal and “sudo su” to become root
  2. Setup your new drive
    1. Use cfdisk /dev/sda to look at your partitions on your current drive. I have sda1 of type linux as most of my current drive, and a 6 GB sda5 as linux swap at the end
    2. Duplicate this on your new drive using cfdisk /dev/sdb, adjusting for space as necessary. I created a new primary partition using cfdisk using all but 6 GB of space, then a new logical partition using the rest of the space. You must create the partitions in this order to get the right numbering
    3. make the primary partition to bootable
    4. set the swap partition as type 82 (linux swap)
    5. save and quit
    6. create filesystems on the new partitions using mkfs.ext3 /dev/sdb1 and mkswap /dev/sdb5
  3. Copy data
    1. Make directories to mount your old and new partitions, in this case, /mnt/sda1 and /mnt/sdb1
    2. Mount your drives to these partitions using mount /dev/sda1 /mnt/sda1 and mount /dev/sdb1 /mnt/sdb1
    3. Copy all your data from your old drive to your new drive using cp -a /mnt/sda1/* /mnt/sdb1/ . The -a will preserve owners, permissions, date, etc.
    4. Get up and do something else. It took 70 minutes for my machine to copy about 150 GB of data from one drive to the other
  4. Fix the boot options
    1. This is where Ubuntu 6.10 differs from previous versions. Fstab and menu.lst both use UUID numbers to find partitions. To get the UUID number of your new partitions, run vol_id /dev/sdb1 and vol_id /dev/sdb5 . Copy these numbers into their appropriate places in your /mnt/sdb1/etc/fstab and /mnt/sdb1/boot/grub/menu.lst files. You may need to dig around the menu.lst to find all the entries.
    2. Now install grub onto the MBR of the new drive to make it bootable. To do this I first chroot into my new system using chroot /mnt/sdb1 /bin/bash . Now that you’re in the new system, run grub. Inside grub, run setup (hd1,0) then root (hd1) . This will differ if you have a different drive setup. Quit grub (quit).
  5. Finish up
    1. Logout of your chroot (logout), unmount your mounted drives umount /dev/sda1 and umount /dev/sdb1, and shutdown your computer. Disconnect your old drive, plug your new drive into the old drive’s cable, and start your computer back up. If everything went well, it will boot back up as if nothing happened.
Categories: file systems, howto

A Couple Ways to Run FSCK on Ubuntu

November 19th, 2006 No comments

My server decided that an executable file didn’t really exist on the file system, or so I thought. Lack of sleep was the main problem, but here are some things I did to check my file system for errors. I setup this file system on a Ubuntu 6.06 AMD64 install with LVM, so everything is in LVM instead of standard partitions.

# sudo e2fsck -n /dev/mapper/Ubuntu-root

This was showing errors, but I ran it while the system was mounted and running, so there were open files, so this was normal. The -n kept e2fsck from attempting to fix anything, which was good because later I ran the command after booting from an Ubuntu LiveCD and found no errors.

Before booting from the LiveCD I tried to get the system to fix itself by running fsck on boot. Two methods I used to do this on Ubuntu were running these from the live system before rebooting, they both accomplish the same thing, so only one was really needed.

# sudo touch /forcefsck

# sudo tune2fs -C 40 /dev/mapper/Ubuntu-root

These appeared to have no affect, probably because the filesystem was fine, but I took down the system and ran fsck from a LiveCD instead. Of course, this wasn’t as simple as it should have been, the LiveCD did not detect my LVM volumes, so /dev/mapper/Ubuntu-root was missing. The fix was to install LVM2 and start it up.

# sudo apt-get install lvm2
# sudo /etc/init.d/lvm start

The /dev/mapper/ entries then appeared and I could run all the fscks I wanted. At this point my fsck checks were coming out clean, so file system corruption was not to blame.

Categories: file systems, howto