Created
December 11, 2014 15:21
-
-
Save fsmithred/931b0ccf0964a6fde2d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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