converting existing directory to zfs dataset

Status
Not open for further replies.

vicente95650

Dabbler
Joined
Nov 3, 2016
Messages
14
My intent was to create a dataset named winshare3 under an existing dataset named datapool3 and then to share, via SAMBA, the dataset winshare3 but I used a wrong process.

I created an SMB share with path /mnt/datapool3/winshare3 . I thought (mistakenly) that a dataset named winshare3 would be created under datapool3. A directory winshare3 was created instead.

In an attempt to achieve my original intent, I deleted the share and of course the directory remained. I then tried creating a dataset named winshare3 underneath the dataset datapool3 but I am told (in red letters) that "the path already exists".

What process, other than deleting the directory /mnt/datapool3/winshare3 and starting over , would you recommend to achieve my original intent?
 

anodos

Sambassador
iXsystems
Joined
Mar 6, 2014
Messages
9,554
My intent was to create a dataset named winshare3 under an existing dataset named datapool3 and then to share, via SAMBA, the dataset winshare3 but I used a wrong process.

I created an SMB share with path /mnt/datapool3/winshare3 . I thought (mistakenly) that a dataset named winshare3 would be created under datapool3. A directory winshare3 was created instead.

In an attempt to achieve my original intent, I deleted the share and of course the directory remained. I then tried creating a dataset named winshare3 underneath the dataset datapool3 but I am told (in red letters) that "the path already exists".

What process, other than deleting the directory /mnt/datapool3/winshare3 and starting over , would you recommend to achieve my original intent?

Open the CLI and type rmdir /mnt/datapool3/winshare3
The command won't work if there are files / subdirectories in there. In this case, you'll want to make sure you don't have anything valuable there, then 'rm -rf' the directory. rm -rf /mnt/datapool3/winshare3. It is VERY important to type out the path exactly. Putting an extra space in there can have unintended (bad) consequences.
 

vicente95650

Dabbler
Joined
Nov 3, 2016
Messages
14
I do have data in /mnt/datapool3/winshare3; that is why I was hoping for some method of "converting" rather than deleting the directory and starting all over?
I assume you are saying that I have no choice but to delete the directory before I can create a dataset named winshare3?

If there is no way then I will create a dataset /mnt/datapool3/winshare4 and then move the data from winshare3 to winshare4 and then delete the directory winshare3. Maybe I can then rename the dataset from winshare4 to winshare3 if need to?
 

anodos

Sambassador
iXsystems
Joined
Mar 6, 2014
Messages
9,554
I do have data in /mnt/datapool3/winshare3; that is why I was hoping for some method of "converting" rather than deleting the directory and starting all over?
I assume you are saying that I have no choice but to delete the directory before I can create a dataset named winshare3?

If there is no way then I will create a dataset /mnt/datapool3/winshare4 and then move the data from winshare3 to winshare4 and then delete the directory winshare3. Maybe I can then rename the dataset from winshare4 to winshare3 if need to?

Well, you can just use mv to rename winshare3.

https://www.freebsd.org/cgi/man.cgi?query=mv&sektion=1
 

Ericloewe

Server Wrangler
Moderator
Joined
Feb 15, 2014
Messages
20,194
If you have a folder foldername and want a dataset foldername, you can create a dataset differentname, move everything over, then rm -rf ./pathto/foldername and finally rename the dataset to foldername.
 

vicente95650

Dabbler
Joined
Nov 3, 2016
Messages
14
If you have a folder foldername and want a dataset foldername, you can create a dataset differentname, move everything over, then rm -rf ./pathto/foldername and finally rename the dataset to foldername.

I will use this method. Thanks.
 

melloa

Wizard
Joined
May 22, 2016
Messages
1,749

melloa

Wizard
Joined
May 22, 2016
Messages
1,749
Yes, I wonder that too since, in the FreeNas GUI , I see no way to rename a dataset; I have been warned against making changes behind the GUI.

I didn't know that until read Eric's post. I was on a situation that after rsync 6 TiB noticed datasets weren't created, so did it my way, the long Mello's way, to get the data moved to the datasets like I wanted. That above will save me couple days moving-data-work ... learning one post at a time!
 

Stux

MVP
Joined
Jun 2, 2016
Messages
4,419
Yes, I wonder that too since, in the FreeNas GUI , I see no way to rename a dataset; I have been warned against making changes behind the GUI.

It does work from the CLI. FN GUI is not so happy but it does recover.
 

Ericloewe

Server Wrangler
Moderator
Joined
Feb 15, 2014
Messages
20,194
Meh, export the pool and reimport it and FreeNAS will manage. Redo share paths and similar things and she'll be right.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
Wouldn't it be easier to rename the directory first, then create a dataset of the desired name, then move the contents of the directory into the dataset? No potential for GUI confusion in that case.
 

Ericloewe

Server Wrangler
Moderator
Joined
Feb 15, 2014
Messages
20,194
Wouldn't it be easier to rename the directory first, then create a dataset of the desired name, then move the contents of the directory into the dataset? No potential for GUI confusion in that case.
I guess, but paths will probably have to be redone in either case.
 

melloa

Wizard
Joined
May 22, 2016
Messages
1,749
Wouldn't it be easier to rename the directory first, then create a dataset of the desired name, then move the contents of the directory into the dataset? No potential for GUI confusion in that case.

I thought doing that, but was afraid mv would change permissions to the user running it (root in the case), changing permissions for datasets owned by other users, so user rsync which took a looooooong time :)

Would mv work?
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
I thought doing that, but was afraid mv would change permissions to the user running it (root in the case),
Nope, it won't change ownership or permissions.
 

melloa

Wizard
Joined
May 22, 2016
Messages
1,749
Status
Not open for further replies.
Top