Read my book

I wrote books about Webpack and React. Check them out!

Monday, June 8, 2009

Mounting SD memory card on boot

I have a SD memory card that I use as my music stash. Previously in order to access the music via Amarok I had to mount it manually (ie. click the device in "last plugged in devices") and have Amarok to scan it. Obviously I got tired of this after a while and started to look for a solution.

First of all I had to figure out how to mount the device manually. Unix systems provide mount command for this. Basically you invoke it using "mount -t " (example: "mount -t vfat /dev/mmcblk0p1 /media/sd_music") while in root mode (su first or sudo the command (sudo mount ...)).

The source part refers to what is going to be mounted ("ls /dev" to see alternatives). There are certain conventions that help you to spot hard disks, memory cards and whatnot.

The target refers to directory in which you are going to mount the device. You can create one using mkdir (example: "mkdir sd_music").

To unmount the folder, just use "umount ".

After checking out that I can mount the memory card manually I decided to look into making this process automatic. There is a special file, /etc/fstab, that happens to do exactly what I needed. Luckily I found a page describing it thoroughly. Essentially all I had to do was to add "/dev/mmcblk0p1 /media/sd_music vfat defaults 0 0" into my fstab. I checked out if it works by using "mount -a" (it executes fstab) and all worked out well. Obviously things still worked after a boot.

Note that before editing /etc/fstab or other system files it's probably a good idea to create a backup or two of the file edited. This can be particularly useful if things don't work out as they should. :)

You can find more information about mount and umount commands by surfing to man:/mount and man:/umount using Konqueror. Of course you can access the same information using the "man" command.