diskmv -- A set of utilities to move files between disks


Recommended Posts

  • 4 months later...

I was pointed to these posts as a way to re-group my TV Shows so they are not spread across two disks.  I however do not wish to pass in a target disk but re-group to the same disks they are currently on.  Im not sure if this will work ?

 

My issue :

 

After creating my TVSwhows share - MediaTVShows over two disks, and having the default automatic split, I now have stuff spread over the two disks.  These two 4TB disks have about 600Meg free on each.  I dont have another disk to 'move/consolidate' too - so I wish to do this to the same disks.

 

My structure :

 

Top Dir - media-tvshows

Second Dir - TVShow Name

Third Dir - Season XX

Fourth Dir - Episodes

 

so, after reading this thread, the colsolidate command seems like it can do this - but I want the target disks to be the same disks the stuff is already on.

 

Can a script do this ?

 

Thanks.

 

Link to comment

Never mind - I manually sorted it. (drives are disk2 and disk3)

 

I used krusader to compare the tv shows between the two disks, then used unbalance to select the TV shows that existed on both drives, then it said I would only need 150GB of transfers to move the scattered stuff it back to disk2.  That is running now.

 

Going forward, I have changed the share to NOT automatically split so hopefully the issue will not happen again.

Link to comment
  • 3 years later...
On 8/3/2016 at 10:03 PM, korpo53 said:

Use Putty to remote into your server

 

 

mkdir /boot/scripts
wget https://raw.githubusercontent.com/trinapicot/unraid-diskmv/master/diskmv -O /boot/scripts/diskmv
wget https://raw.githubusercontent.com/trinapicot/unraid-diskmv/master/consld8 -O /boot/scripts/consld8
echo "ln -s /boot/scripts/diskmv /usr/sbin" >> /boot/config/go
echo "ln -s /boot/scripts/consld8 /usr/sbin" >> /boot/config/go
 

 

That'll:

 

  • Create a directory to hold the scripts that survives reboots.
  • Download the scripts to that directory.
  • Add lines to your startup script to create symlinks (shortcuts, sort of) to those permanent files in a non-permanent space that makes them more usable.

 

After doing that, if you don't want to reboot, you can just run the below to create the symlinks right now. They'll get recreated every boot by the go script, so you only have to do this part the first time.

 

ln -s /boot/scripts/diskmv /usr/sbin
ln -s /boot/scripts/consld8 /usr/sbin
 

 

 

 

 I am hoping for a little help I tried installing using the method described but I am getting permission denied errors. I was hoping someone could help me figure out what is wrong. Thanks

Link to comment

I suspect the instructions are no longer accurate as in the last few Unraid releases security has been tightened so that files on the flash drive are not allowed to have execute permission.

 

instead of using a link as suggested you need to copy the files elsewhere (such as /user/local/bin) and give them execute permission.

Link to comment
On 1/12/2022 at 4:18 PM, itimpi said:

I suspect the instructions are no longer accurate as in the last few Unraid releases security has been tightened so that files on the flash drive are not allowed to have execute permission.

 

instead of using a link as suggested you need to copy the files elsewhere (such as /user/local/bin) and give them execute permission.

Or you can just "bash" them into submission.....

 

so instead of just doing

 

diskmv blah blah2

(which will fail as no execute permission on diskmv)

 

do 

 

bash diskmv blah blah2

 

 

Link to comment
On 1/22/2022 at 6:08 AM, Shaboobala said:

Thanks @Meles Meles I am trying to use the consld8 script and  earlier in the thread it says to execute it by using this comand 

 

 

if i were to bash would I put it before find? Sprry for my ignorance is its and obvious answer just trying to learn. 

 

 

you'd put it just before consold8

 

find "/mnt/user/Media/Movies" -mindepth 1 -maxdepth 1 -type d -print0 | xargs -0 -n 1 bash consld8 -f

 

Link to comment
  • 2 months later...
  • 3 months later...

diskmv is such a lifesaver!

I was going to make the exact same script myself and you saved me the trouble :)

 

Since I coded it, I'm offering my contribution with the diskdu script. It checks the size of /mnt/user/ files or directories in each /mnt/disk*/ and /mnt/cache*/ where it is present.

Do what you will with this. It comes with no waranty.

#!/bin/bash
# diskdu - Summarize disk usage of the set of unRAID user share directories 
#          and/or files
#
# usage: diskdu [options] file...
#
# A du operation is made for every disk and every file given as parameters.

usage(){
cat << EOF

usage: diskdu [options] file...

file...      The set of files or directories.
             They can be specified as an absolute or relative path and can be 
             relative to the current directory or the /mnt/user/ directory.  

Options:

--help	help, print this help message
All other options from the du command can be used.
See du --help

EOF
}

[ ${DEBUG:=0} -gt 0 ] && set -x -v

shopt -s extglob

# Basically the only option understood by this script is --help. The rest is 
# passed down to du.
ARGS=()

while [[ $# -gt 0 ]]; do
  case "$1" in
    --help)
      usage
      exit 0
      ;;
    *) # Default case: add to array of arguments to pass down to du.
      if [ -e "$1" ]
      then # File or directory, replace /mnt/user/... with /mnt/disk*/...
        FULLNAME=$(readlink -e "$1")   # Handle relative path
        MERGEDIR="${FULLNAME#/mnt/*/}"   # Remove any /mnt/*/ prefix

        if [ ! -e "/mnt/user/$MERGEDIR" ]
        then 
          echo "'$1' is not a valid user share file or directory." >&2
          usage >&2
          exit 1
        fi
        ARGS+=(/mnt/@(disk*|cache*)/"$MERGEDIR")
      else # Something for du to figure out
        ARGS+=("$1")
      fi
      ;;
  esac
  shift
done

du "${ARGS[@]}"

 

Link to comment
12 minutes ago, Guillaurent said:

I'm offering my contribution with the diskdu script

Looks like this (and the source script) only work properly if there are no pools with names other than cache. That USED to be the case, but with the advent of multiple cache pools, there is no guarantee that the cache pool will even be named cache, it can be user defined, and there can be more than one.

 

So, if you have a single cache pool named cache, it should work as planned. Otherwise, it looks like it will ignore any other cache pools.

 

I could be reading this wrong though.

Link to comment
1 hour ago, JonathanM said:

Looks like this (and the source script) only work properly if there are no pools with names other than cache. That USED to be the case, but with the advent of multiple cache pools, there is no guarantee that the cache pool will even be named cache, it can be user defined, and there can be more than one.

 

So, if you have a single cache pool named cache, it should work as planned. Otherwise, it looks like it will ignore any other cache pools.

 

I could be reading this wrong though.

I haven't used anything else than 1 cache pool named cache so far. I though it would be named cache cache1 like disks are...

If anyone knows how to identify cache mounting points, I (or someone else) could modify the script.

Link to comment
  • 10 months later...
On 7/22/2015 at 2:05 AM, Benni-chan said:

@markswift:

 

i've used consld8 recently for my Movies Collection for the same reason you wish. Since I have a few thousand movie folders, i used following command: (USE AT OWN RISK)

 

find "/mnt/user/Media/Movies" -mindepth 1 -maxdepth 1 -type d -print0 | xargs -0 -n 1 consld8 -f
 

 

 

 

 

 

 

 

Is there a way I can easily run this as a cron job in userscripts? Tried doing it with just the command but it errors.


EDIT

 

Or how would you put this in the mover tuning plugin to run this after each time the mover runs? 
 

 

EDIT2

 

Disregard! Figured it out, added it to user scripts and pointed mover tuning to:

 /tmp/user.scripts/tmpScripts/script_name/script


Now it will run the consld8 script after every time the mover runs. 

Edited by Oamster
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.