Skip to content

Instantly share code, notes, and snippets.

@fsmithred
Created December 11, 2014 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fsmithred/931b0ccf0964a6fde2d9 to your computer and use it in GitHub Desktop.
Save fsmithred/931b0ccf0964a6fde2d9 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# move-dir-mount.sh
# Send errors to the installer's error log.
error_log=$(grep error_log /etc/refractainstaller.conf | cut -d"\"" -f2)
exec 2>> "$error_log"
# Do not use a trailing slash in the variables.
# The directory you want to move to another partition
source_dir=
# The other partition (full device name, like /dev/sdb2)
target_partition=
# Temporary mount point for the other partition, just to copy the files.
temp_mountpoint="/mnt"
if [[ -z "$source_dir" || -z $target_partition || -z $temp_mountpoint ]] ; then
echo "ERROR: Empty variable in $0"
exit 1
fi
mount "$target_partition" "$temp_mount_point"
rsync -av /target/"$source_dir"/ "$temp_mountpoint"/
idnum=$(blkid -c /dev/null -o value -s UUID "$target_partition")
fstype=$(blkid -c /dev/null -o value -s TYPE "$target_partition")
echo -e "UUID=$idnum\t$source_dir\t$fstype\tdefaults,noatime\t0\t2" >> /target/etc/fstab
rm -rf /target/"$source_dir"/*
umount "$temp_mountpoint"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment