I wrote this as a post on XBMC forum, but I thought I should share the wealth. The following is a guide to automounting a drive in a minimal install of Ubuntu with no GUI or desktop, only CLI access.
To manually get a minimal install of Ubuntu to auto-mount a USB drive at boot:
First off, you need command line access (also called The Terminal) to your installation and also you need to boot WITHOUT your USB drive connected. So, shutdown your box and then disconnect your USB drive. Now restart the box. Then, when XBMC has loaded, press Alt and F7 together, which should bring up a new Terminal screen with a log in.
Then log in using your username and password that you set up when you installed Ubuntu.
Next you need to type the following:
tail -f /var/log/syslog
This basically prints out the system log as it changes. Once you have typed this, plug in your USB drive. You should see a load of new stuff being printed in your terminal, this is the Ubuntu system recognising and loading your USB drive (though not mounting it). You should see something like this:
Jan 8 13:13:34 xpuntu kernel: [ 1671.616121] usb 2-2: new high speed USB device using ehci_hcd and address 5
Jan 8 13:13:34 xpuntu kernel: [ 1671.750917] usb 2-2: configuration #1 chosen from 1 choice
Jan 8 13:13:34 xpuntu kernel: [ 1671.752477] scsi6 : SCSI emulation for USB Mass Storage devices
Jan 8 13:13:34 xpuntu kernel: [ 1671.752815] usb-storage: device found at 5
Jan 8 13:13:34 xpuntu kernel: [ 1671.752820] usb-storage: waiting for device to settle before scanning
Jan 8 13:13:39 xpuntu kernel: [ 1676.753513] usb-storage: device scan complete
Jan 8 13:13:39 xpuntu kernel: [ 1676.754606] scsi 6:0:0:0: Direct-Access WDC WD16 00AABB-56PUA0 7H00 PQ: 0 ANSI: 2 CCS
Jan 8 13:13:39 xpuntu kernel: [ 1676.755793] sd 6:0:0:0: Attached scsi generic sg2 type 0
Jan 8 13:13:39 xpuntu kernel: [ 1676.756402] sd 6:0:0:0: [sdb] 312581808 512-byte logical blocks: (160 GB/149 GiB)
Jan 8 13:13:39 xpuntu kernel: [ 1676.757163] sd 6:0:0:0: [sdb] Write Protect is off
Jan 8 13:13:39 xpuntu kernel: [ 1676.757171] sd 6:0:0:0: [sdb] Mode Sense: 00 38 00 00
Jan 8 13:13:39 xpuntu kernel: [ 1676.757176] sd 6:0:0:0: [sdb] Assuming drive cache: write through
Jan 8 13:13:39 xpuntu kernel: [ 1676.761108] sd 6:0:0:0: [sdb] Assuming drive cache: write through
Jan 8 13:13:39 xpuntu kernel: [ 1676.761119] sdb: sdb1
Jan 8 13:13:39 xpuntu kernel: [ 1676.774572] sd 6:0:0:0: [sdb] Assuming drive cache: write through
Jan 8 13:13:39 xpuntu kernel: [ 1676.774583] sd 6:0:0:0: [sdb] Attached SCSI disk
You want to look out for the reference to “[sd*]”, in my case it is [sdb]. This is the name that Ubuntu has given to your USB drive.
Next stop the tail command, so press:
Ctrl and C
This stops the tail command, then type the following:
You will have to enter your password. This should give you something like the following:
/dev/sda1: UUID="1024B74F24B73696" TYPE="ntfs"
/dev/sda5: UUID="015273a3-e1a8-4d53-867f-ffec83b3df60" TYPE="swap"
/dev/sda6: UUID="50b2512a-4d07-4a83-860e-be608a5b2cb7" TYPE="ext4"
/dev/sdb1: LABEL="" UUID="48D3-B1C9" TYPE="vfat"
What you see should be different from this. This basically lists all the drives attached to your system, alongside two important pieces of info, the drives UUID number and what the drive is formatted as. You need to find the reference to the “sd*” that you found out earlier, so in my case it is /dev/sdb1. Then, make a note of the UUID number and the TYPE as well, in my case it is vfat.
So, now we know where our USB drive is and what it is called.
Next, we want to tell Ubuntu to automount it each time it boots.
So, you need to edit the /etc/fstab file that tells Ubuntu what drives to mount at boot. Be careful here, don’t delete or change anything that is already in this file, since it will stop your device from booting. It is ok to add new stuff to this file however. To be safe, we shall make a backup of the /etc/fstab file, just incase we mess up. If we do mess up, simple copy this backup over the /etc/fstab file and reboot and everything will be back as we found it. So, to make a backup simple type:
sudo cp /etc/fstab /etc/fstabackup
This copies the /etc/fstab file to /etc/fstabackup, which we can use as a backup.
To edit the /etc/fstab file, you need to use the command line Text editor called Vi ([url]http://en.wikipedia.org/wiki/Vi[/url] and [url]http://www.cs.colostate.edu/helpdocs/vi.html[/url]) I would recommend reading about it first, since it is a bit of an arse to use in Terminal mode.
Start Vi to edit your file using:
sudo vi /etc/fstab
Use your arrow keys to move down to the very end of the file. Then press “a” to Append stuff to the end of the file. Press Return to start a new line and then type the following:
UUID=YOURUUIDNUMBERHERE /home/xbmc/usb vfat defaults 0 0
Add your own UUID number after the = and change the TYPE if yours wasn’t vfat. /home/xbmc/usb is where you will be mounting your USB drive, this can be anything you want, but to make your life easy, since XBMC defaults to showing your home directory in the file browser, put it under your home directory, so in my case, the main user on my box is xbmc, so I use /home/xbmc/usb.
Press Enter again after typing that, then press Escape, then press and hold Shift and press Z twice, this saves and exits Vi.
Next, you need to make the folder that the drive will be mounted in, so type:
Replace /home/xbmc/usb with whatever you put in the /etc/fstab file earlier.
Finally, that is it. Hopefully, if all went well, you can now simply reboot, with your USB drive attached, and the drive will be found at /home/xbmc/usb which you can navigate to from XBMC.
Best of luck!!