Post Installation SD Card Resizing for Raspberry Pi Running Arch Linux

If you install Arch Linux on your SD card you may notice you might not be using all of the storage space your SD card has to offer. In my instance I use a 16GiB card I was only using 1.5GiB of the 16GiB.

# df -h
Filesystem     Size Used Avail Use% Mounted on
/dev/root      1.5G 1.5G 51M   99%  /
devtmpfs       89M  0    89M   0%   /dev
tmpfs          93M  0    93M   0%   /dev/shm
tmpfs          93M  288K 93M   1%   /run
tmpfs          93M  0    93M   0%   /sys/fs/cgroup
tmpfs          93M  0    93M   0%   /tmp
/dev/mmcblk0p1 90M  25M  66M   28%  /boot
tmpfs          19M  0    19M   0%   /run/user/0

You can resize the partition online quite easily by using fdisk. Using the latest Arch Linux for RPi the root filesystem is mounted on mmcblk0p5 which is a logical partition within an extended one.

# fdisk /dev/mmcblk0
Welcome to fdisk (util-linux 2.24.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): d
Partition number (1,2,5, default 5): 
Partition 5 has been deleted.

Command (m for help): d
Partition number (1,2, default 2): 
Partition 2 has been deleted.

Command (m for help): n
Partition type:
 p primary (1 primary, 0 extended, 3 free)
 e extended
Select (default p): e
Partition number (2-4, default 2): 
First sector (186368-31116287, default 186368): 
Last sector, +sectors or +size{K,M,G,T,P} (186368-31116287, default 31116287): 
Created a new partition 2 of type 'Extended' and of size 14.8 GiB.

Command (m for help): n
Partition type:
 p primary (1 primary, 1 extended, 2 free)
 l logical (numbered from 5)
Select (default p): l
Adding logical partition 5
First sector (188416-31116287, default 188416): 
Last sector, +sectors or +size{K,M,G,T,P} (188416-31116287, default 31116287): 
Created a new partition 5 of type 'Linux' and of size 14.8 GiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy
The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).

At this point the partition table should be properly set-up to use the entire SD card. Reboot. The final step is to resize the filesystem to match the new partition size.

# resize2fs /dev/mmcblk0p5


VMware Workstation 7 Released

VMware just released version 7 of their well known Workstation application. Here’s an interesting new feature many have been waiting for:

Aero Glass — A new Windows Display Driver Model (WDDM) graphics driver has been developed for Windows Vista and Windows 7 virtual machines. The WDDM driver can display the Windows Aero user interface, OpenGL 1.4, and Shader Model 3.0. For more information on the VMware recommended graphics hardware, see the VMware Workstation User’s Manual.

Full release notes can be found here.
Downloads are here.

Windows 7 x64 - VMware Workstation

PPA Update

Yes, I have found some time (sorry, I meant “took some time”) to update my PPA. I’ve updated my x264 package to core 76 for now. You’ll find my PPA on launchpad.

I also want to update my other packages but first I need to better understand the process of updating an existing source package with a new upstream version using version control (git). Launchpad has lots of good resources on packaging software for Ubuntu (or any Debian based distro).

I found interesting links on packaging for Debian. However they all seem to be using their “own” way and there seems to be no “standard/official” way of doing it. There is also the vcs-pkg project that aims to further investigate the use of version control for packaging. Interesting.

Any good links aside those ones you would like to suggest?

(HD-)PVR happy [part 2]

So following my first post on this matter now I got an up & running system with plenty of power to stream HDTV. The next logical step was achieving the ability to play the stream flawlessly in real-time. Going down the road I might end up with a Linux media center but for now I’m focusing on playing/recording. There are many really good media players for Linux however I choose to go with MPlayer since my background experience with MPlayer is quite advanced (for CLI fans like me).

Once I had the HD-PVR driver loaded, recording was a simple matter to dumping /dev/video0 (or whatever your HD-PVR ends up on) into a TS file. I love Linux for that, no fuss. The driver supports some basic options like adjusting the bitrate and also boosting the input audio (since the device tends to loose some audio strenght when encoding). I’ve configured the driver to load with boost_audio=1 and adjusted the bitrate to the max (13.5Mbps) for maximum picture quality (I don’t mind the time required to re-encode later to fit a dual layer DVD or other media, plus I have plenty of storage space). So loading/configuring the driver and saving the stream is as simple as this:

# sudo modprobe -v hdpvr boost_audio=1
# sudo v4l2-ctl --device=/dev/video0 --set-ctrl=video_bitrate=13500000
# cat /dev/video0 > stream.ts

Just hit Ctrl+C to stop saving the stream. Finding the right options for playing the stream took a bit more time & tweaking since the HD-PVR stream is interlaced. I ended up with a command line that looks like this:

# cat /dev/video0 | mplayer - -correct-pts -vc ffh264vdpau -vo vdpau:deint=0 -mc 0 -delay 2.154 -cache 8192

This -correct-pts is required to play the stream live but can be omitted when playing a recorded TS file. The -mc 0 and -delay 2.154 are required only for playing the live stream as well (the delay might defer for you). You may not need the caching either when you’re playing a saved TS file. Since the box has quad power I can also use multi-threading decoding:

# cat /dev/video0 | mplayer - -correct-pts -vc ffh264 -vo vdpau -mc 0 -delay 2.154 -lavdopts threads=4 -cache 8192 -vf field=0

With this CPU the multi-threading playback is as smooth as using the GPU VDPAU capabilities. Spreading the decoding over several threads is one option of using multi-core CPU. The other is to use a multi-threading aware version of MPlayer/ffmpeg (still experimental and has issues). If I want to play the live stream and record at the same time I simply add a pipe and use tee (did I say I love Linux?):

# cat /dev/video0 | tee stream.ts | mplayer - -correct-pts ...

This is all very useful but a lot of manual intervention is required every time I want to record/pause the live stream. The plan is to come up with some interface to cover all the basic functionality of a fully functional PVR:  play/pause/stop/record. I haven’t looked around for such an interface, however I’m thinking this could be a sweet project as it seems fairly easy to build (projects, projects, projects… 😛 ). This could also make an excellent future post!

(HD-)PVR happy [part 1]

Last year I bought the Hauppauge HD-PVR model 1212 since I wanted to record HD TV at home (HDCP being an issue I had to go analog). My goal was to setup a home PVR with spare parts lying around and configure the device on that box, running Linux. Well, it didn’t happen… until last week!

Support for HD-PVR running at 1080p just didn’t work back then as the Linux HD-PVR driver was very alpha and MPlayer had a hard time feeding on the HD-PVR stream (which can be H.264/AAC with the analog audio input or H.264/AC3 with the optical audio input).

Now that the HD-PVR Linux driver has entered mainline since v2.6.30 I thought it was a good time to try the setup again. At the same time I updated the hardware used in the PVR (I bought a Q9550 and 4GB of DDR2).

I installed Ubuntu Jaunty 9.04 on a pair of ST3300831AS drives so I had to setup software RAID as I’ve set drives in stripping (RAID 0) inside the MediaShield BIOS (the box is using an EVGA 630i/7150 planar). The system has also seen a video card upgrade to a 8800GT (which comes from my main station, which I upgraded to a GTX280). The onboard 7150 GPU may not have been enough for running full 1080p and besides, I had that 8800GT collecting dust.

Since the box’s primary role is to provide realtime video streaming I thought I’d be running some of the latest software available to ensure smooth playback. Ubuntu is great for running cutting edge software with the support of all the PPAs on Launchpad so I added the xorg crack pushers to my sources.list.d. It provides the latest X server along with an updated MESA. I also added the NVIDIA VDPAU Team PPA to get the latest NVIDIA driver v190 series. I guess maybe now you see where this is going since the HD-PVR feeds H.264 and the box has an NVIDIA GPU (hint). I know, I know, the box has a Q9550 which can handle full 1080p even without VDPAU… but its there and its supported, so why not use it? The extra power from the Quad could be used wisely.

As the latest kernel in Jaunty is v2.6.28 (as of this writing) I had to upgrade to at least 2.6.30 to get the HD-PVR driver from the mainline or compile it myself. Well, since I’m lucky and I chose to run cutting-edge packages from the xorg crack pushers PPA I also have access to an updated kernel package v2.6.30! Awesome.

To be continued…