#!/bin/sh

set -eux

source_device="$1"
destination="${2:-/mnt}"

mount_subvol() {
  mount -o subvol=@$1 $source_device $destination/${2:-$1}
}

mount -o subvol=@ $source_device $destination
mount_subvol root
mount_subvol home
mount_subvol srv
mount_subvol tmp
mount_subvol cache var/cache
mount_subvol log var/log

mount -o bind /dev $destination/dev
mount -o bind /proc $destination/proc
mount -t sysfs /sys $destination/sys
