User Tools

  • (equal to forum credentials)

Site Tools


It's all automatic

By default XBian will automatically discover and mount USB hard disks. When you plug them in they appear in the SCSI subsystem so the names of the various drive devices will be /dev/sda, /dev/sdb, etc., depending on the order in which they are connected.

Xbian will automatically mount the partitions found on these drives in subdirectories created in the /media directory. The actual name will depend on whether you have a UUID on the drive, etc. The names could be:

  /media/49f67e18-61de-475a-bf6a-8b100727f03e  (long name = UUID of the drive)
  /media/32G (name = label of the drive)

You can view the currently mounted drives using the mount command when connected via SSH:

  xbian@xbian ~ $ mount
  sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)
  proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
  udev on /dev type devtmpfs (rw,relatime,size=256k,nr_inodes=47078,mode=755)
  devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
  tmpfs on /run type tmpfs (rw,nosuid,noexec,noatime,size=38304k,mode=755)
  /dev/mmcblk0p2 on / type btrfs (rw,noatime,thread_pool=2,compress=lzo,ssd,space_cache,autodefrag,commit=120)
  /dev/mmcblk0p1 on /boot type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)
  /dev/mmcblk0p2 on /home type btrfs (rw,noatime,thread_pool=2,compress=lzo,ssd,space_cache,autodefrag,commit=120)
  /dev/mmcblk0p2 on /lib/modules type btrfs (rw,noatime,thread_pool=2,compress=lzo,ssd,space_cache,autodefrag,commit=120)
  none on /sys/kernel/debug type debugfs (rw,relatime)
  /dev/sdb1 on /media/6e56ad20-5db1-48f3-bca1-c631724c7a51 type ext4 (rw,nodev,noexec,noatime,nodiratime,sync,data=ordered)
  /dev/mmcblk0p2 on /xbmc-backup type btrfs (rw,noatime,thread_pool=2,compress=lzo,ssd,space_cache,autodefrag,commit=120)
  /dev/sda1 on /media/49b67e18-61fd-475a-bf6a-8b100727f03e type ext4 (rw,nodev,noexec,noatime,nodiratime,sync,data=ordered)
  xbian@xbian ~ $

Look for the lines that begin with /dev/sd….

When you unplug the HDD these directories will disappear automatically.

Mounting to a permanent location

If you'd like to have a more permanent mount point for your drive you have several options:

Create a symbolic link (symlink) to the /media/ subdirectory where you drive appears. For example you can make it appear in /home/xbian/downloads by typing this command after connecting via SSH:

  ln -s /media/49f67e18-61de-475a-bf6a-8b100727f03e /home/xbian/downloads

(replace the /media/… part with your actual drive)

Whenever the disk is plugged in and automatically mounted your files will appear in the symlink location. You can even create multiple symlinks to the same disk or to subdirectories of your disk.

Hard way: fstab

You can add an entry to the /etc/fstab file to set a permanent mount point, replacing the default /media location. This file gives the list of filesystems to mount at startup or when you type the mount -a command. You can add a new line in it (using nano or your favorite command-line editor after becoming root with sudo -s). When you do this you should specify the disk device to mount using its UUID and not the current drive letter (e.g. /dev/sda) because it could change when you unplug/replug it. The easiest is to copy the corresponding line from the mount output (see above) and replace the current drive device by UUID=<your-uuid>. For example for an ext4-formatted USD drive to be mounted on /home/xbian/downloads could be added like this (use your own UUID of course!):

  UUID=6e56ad20-5db1-48f3-bca1-c631724c7a51 /home/xbian/downloads ext4 rw,sync,nodev,noexec,noatime,nodiratime,data=ordered 0 0

After adding this line you should save the file and use mount -a to test it. You can unmount a currently mounted drive using umount (e.g. umount /dev/sda), just make sure you are not currently in the mounted directory.

Important: if you add an entry in /etc/fstab XBian will sometimes not boot if the disk is missing. You can add the noauto options in your fstab line to avoid this:

  UUID=6e56ad20-5db1-48f3-bca1-c631724c7a51 /home/xbian/downloads ext4 noauto,rw,sync,nodev,noexec,noatime,nodiratime,data=ordered 0 0

Have a look at the documentation (man fstab) for more details.

How to find your disk's UUID?

Usually the simplest way is to type mount and look at the output. Another option is to look into the /dev/disk/by-uuid folder that contains symlinks to the actual devices:

  xbian@xbian ~ $ ls -l /dev/disk/by-uuid/
  total 0
  lrwxrwxrwx 1 root root 10 Jun 28 08:28 49b67e18-61fd-475a-bf6a-8b100727f03e -> ../../sda1
  lrwxrwxrwx 1 root root 10 Jun 28 08:28 6e56ad20-5db1-48f3-bca1-c631724c7a51 -> ../../sdb1
  lrwxrwxrwx 1 root root 15 Jun 28 08:28 A815-4C22 -> ../../mmcblk0p1
  lrwxrwxrwx 1 root root 15 Jun 28 08:28 bc525fb5-5301-4146-bfbf-635e20849a3b -> ../../mmcblk0p2
  lrwxrwxrwx 1 root root 15 Jun 28 08:28 e9184209-fe43-4ef8-be30-1ee0e701708a -> ../../mmcblk0p3

You can also find out using blkid command when connected as root:

  root@xbian:~# blkid
  /dev/mmcblk0p1: SEC_TYPE="msdos" LABEL="xbianboot" UUID="A815-4C22" TYPE="vfat" 
  /dev/mmcblk0p3: UUID="e9184209-fe43-4ef8-be30-1ee0e701708a" TYPE="swap" 
  /dev/sda1: UUID="49b67e18-61fd-475a-bf6a-8b100727f03e" TYPE="ext4" 
  /dev/sdb1: UUID="6e56ad20-5db1-48f3-bca1-c631724c7a51" TYPE="ext4" 
  /dev/root: LABEL="xbian-copy" UUID="bc525fb5-5301-4146-bfbf-635e20849a3b" UUID_SUB="a3e309d6-00ad-41bc-84ba-b441767b3b97" TYPE="btrfs"
mount_usb.txt · Last modified: 2014/08/01 16:01 by nullredvector