How to use the mv command to move files from one dataset to another

csearle

Contributor
Joined
Jan 18, 2019
Messages
189
Looking up rsync right now..

but wouldn’t renaming the folder stop the dataset crash, and I’d-just have to move the files to the dataset?
 
Last edited:

Scharbag

Guru
Joined
Feb 1, 2012
Messages
620
What is this dataset crash you speak of?
 

csearle

Contributor
Joined
Jan 18, 2019
Messages
189

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
So really, this isn't that hard. Assuming that your pool is called tank, and the directory/dataset are called mediafiles:
  • Stop the Plex jail (and any other jails or sharing services that may be using the dataset)
  • zfs unmount tank/mediafiles
  • mv /mnt/tank/mediafiles /mnt/tank/mediafiles_dir
  • zfs mount tank/mediafiles
This renames the directory to mediafiles_dir, and then brings mediafiles back online. Now both are available, and you can move files from the directory to the dataset using whatever tool you like (I think I'd still vote for mc for the sake of simplicity. Once you've moved the files over, restart the Plex jail.

Now, how you got in this situation is anyone's guess--FreeNAS shouldn't let you do what's happened.
 

csearle

Contributor
Joined
Jan 18, 2019
Messages
189
Well the mediafiles are on the root dataset in the folder called media files, and I have a dataset with the name media files. with no data id like to move the files from the root to the mediafile dataset if that make more sense..

my pool is called Candace

I have no clue how this happened

Screen Shot 2020-12-21 at 6.52.53 AM.png
 

ornias

Wizard
Joined
Mar 6, 2020
Messages
1,458
@danb35 Just told you litterally step-by-step how to solve it.
That being said, I don't see a dataset named "media files" in your screenshot
 

csearle

Contributor
Joined
Jan 18, 2019
Messages
189
My bad Media Library
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
if that make more sense
Not in the least--I don't see how it's any different from what you've been saying. And as Ornias says, I literally gave you step-by-step instructions to solve it, though you'll obviously need to replace the pool and dataset names with the actual ones. Since you have a space in the dataset name, put it in quotes.
I have no clue how this happened
That is not surprising in the least.
 

ornias

Wizard
Joined
Mar 6, 2020
Messages
1,458
In that case:
  • Stop the Plex jail (and any other jails or sharing services that may be using the dataset)
  • zfs unmount "Candace/Media Library"
  • mv "/mnt/Candace/Media Library" /mnt/Candace/mediafiles_dir
  • zfs mount "Candace/Media Library"
  • mv /mnt/Candace/mediafiles_dir/* "/mnt/Candace/Media Library/"



Btw, if you hide your personal information from a screenshot (and those of "Dawn Smith"), maybe do so in both places you post it ;-)
 

csearle

Contributor
Joined
Jan 18, 2019
Messages
189
I got flack for hiding it the first time and I got flack for not hiding it this time can't win I suppose
 

ornias

Wizard
Joined
Mar 6, 2020
Messages
1,458
I got flack for hiding it the first time and I got flack for not hiding it this time can't win I suppose
Which flak? I don't see it in your other duplicate thread.
I'm starting to get the feeling we are getting trolled here....
 

csearle

Contributor
Joined
Jan 18, 2019
Messages
189
No trolling I swear..... Not in this tread the first time
 

Scharbag

Guru
Joined
Feb 1, 2012
Messages
620
I would suggest that you never ever ever ever use spaces in directory names...

It also looks like your Media Library dataset is empty. Why not just delete that dataset, then rename the folder to MediaTEMP using the mv command. Then recreate the Media_Library dataset and then move the contents into it? Or, follow the other clear and concise instructions others have given you?

Good luck.
 

csearle

Contributor
Joined
Jan 18, 2019
Messages
189
I want to learn why not uses spaces in directory names?

well I’m more apprehensive about the whole ordeal, I’d love to learn and understand how the whole command works, why the unmount of the Media Library is necessary?
The last time I used a move command was back in DOS.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
I want to learn why not uses spaces in directory names?
Because in Unix, a space is ordinarily a separator. It separates commands from arguments, and one argument from another. When a file or directory name contains a space, you need to quote or escape that name (or at least that space) so that the system recognizes that it's a single item. This is a pretty big deal at the CLI, much less so in a shared directory.
well I’m more apprehensive about the whole ordeal,
Why? You have literal step-by-step, copy-and-paste instructions to do what you say you need to do.
I’d love to learn and understand how the whole command works
Which one? Whichever one it is, I'm sure the manpage would explain it.
why the unmount of the Media Library is necessary?
Because you apparently determined eight months ago that you have an empty dataset mounted over the top of a directory that contains a lot of data, thus "hiding" that directory (or the data inside it). Though you clearly aren't in any hurry to fix this problem, you need to unmount that dataset in order to access the directory. Once you've done that, you can rename the directory (so it doesn't conflict with the dataset), then re-mount the dataset. At that point, you can move the data from the directory into the dataset.
 

Scharbag

Guru
Joined
Feb 1, 2012
Messages
620
Spaces in files and directory names are just cumbersome. They work fine in a GUI but they will cause you to pull out your hair in a CLI if they are similar. I use TAB a lot to auto-complete. When spaces are involved, things can become far more cumbersome as you cannot simply type cd Medial Library. You actually need to type cd Media\ Library. Now, if everything is unique enough, it is not such a big deal. That said, it is still good practice to not use spaces in folders/directories. @danb35 did a much better job of explaining this... :D

For a painful example, make a file in a GUI that starts with a space and then try to delete it using the CLI... Fun.

As for your ordeal, it is simple. Another option would be to make a new dataset called Media_Folder, move your files there and then delete both the old directory and the old dataset. Boom. Done.

Cheers,
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
Boom. Done.
...once you tell the Plex jail to use the new path as a mountpoint, and reconfigure any file shares that were pointing to the old path.
 

Scharbag

Guru
Joined
Feb 1, 2012
Messages
620
...once you tell the Plex jail to use the new path as a mountpoint, and reconfigure any file shares that were pointing to the old path.

Well, yeah, those little details matter... :D
 

csearle

Contributor
Joined
Jan 18, 2019
Messages
189
Thank you all for helping and explaining everything, Means allot, thank you for going into detail on the MV command. I suppose I have allot to repair and correct I was unaware about spaces. Looks like I have a few options to use..

Thanks @Scharbag @danb35 @ornias
 

csearle

Contributor
Joined
Jan 18, 2019
Messages
189
Hey guys so I tried the zfs unmount "Candace/Media Library" in the CLI and I get the following

root@SirNas[~]# zfs unmount "Candace/Media Library"
cannot open 'Candace/Media Library': dataset does not exist
root@SirNas[~]#

Screen Shot.png Screen Shot 2020-12-28 at 2.16.04 PM.png

I also opened the MC command and came across this.. I also cannot delete the Media Library Dataset. Should I create another Dataset Called Media_Library?
 
Last edited:
Top