Rahul Deb
2011-Jan-24 21:58 UTC
[zfs-discuss] zfs create -p only creates the parent but not the child
I have a pool "tank" and "dir1" is the filesystem on that pool. "zfs list" and "df -h" both shows "tank/dir1" mounted. *-----------------------------------------------------* *# zfs list* *tank 124K 228G 32K /tank* *tank/dir1 31K 228G 31K /tank/dir1* *#* * * *# df -h* *tank 229G 32K 229G 1% /tank* *tank/dir1 229G 31K 229G 1% /tank/dir1* *#* *-----------------------------------------------------* After that I created a directory "dir2" with mkdir command under /tank/dir1 and touch couple of files inside dir2 *-------------------* *# cd /tank/dir1* *# mkdir dir2* *# cd dir2* *# touch file1 file2* *-------------------* Now if I try to create zfs filesystem named "dir2/dir3" under "tank/dir1", it gives the following message. Though I am using -p flag, it only creates filesystem until tank/dir1/dir2 but not dir3 and also "df -h" does not show "/tank/dir1/dir2" as mounted. *# zfs create -p tank/dir1/dir2/dir3* *cannot mount ''/tank/dir1/dir2'': directory is not empty* *#* * * *# zfs list* *tank 250K 228G 33K /tank* *tank/dir1 63K 228G 32K /tank/dir1* *tank/dir1/dir2 31K 228G 31K /tank/dir1/dir2* *#* Is it a normal behaviour? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.opensolaris.org/pipermail/zfs-discuss/attachments/20110124/4e9e86a9/attachment-0001.html>
Richard Elling
2011-Jan-25 03:02 UTC
[zfs-discuss] zfs create -p only creates the parent but not the child
comment below... On Jan 24, 2011, at 1:58 PM, Rahul Deb wrote:> I have a pool "tank" and "dir1" is the filesystem on that pool. "zfs list" and "df -h" both shows "tank/dir1" mounted. > > ----------------------------------------------------- > # zfs list > tank 124K 228G 32K /tank > tank/dir1 31K 228G 31K /tank/dir1 > # > > # df -h > tank 229G 32K 229G 1% /tank > tank/dir1 229G 31K 229G 1% /tank/dir1 > # > ----------------------------------------------------- > > After that I created a directory "dir2" with mkdir command under /tank/dir1 and touch couple of files inside dir2 > > ------------------- > # cd /tank/dir1 > # mkdir dir2 > # cd dir2 > # touch file1 file2 > ------------------- > > > Now if I try to create zfs filesystem named "dir2/dir3" under "tank/dir1", it gives the following message. Though I am using -p flag, it only creates filesystem until tank/dir1/dir2 but not dir3 and also "df -h" does not show "/tank/dir1/dir2" as mounted. > > # zfs create -p tank/dir1/dir2/dir3 > cannot mount ''/tank/dir1/dir2'': directory is not empty > # > > # zfs list > tank 250K 228G 33K /tank > tank/dir1 63K 228G 32K /tank/dir1 > tank/dir1/dir2 31K 228G 31K /tank/dir1/dir2 > # > > Is it a normal behaviour?Yes. With the -p option, ZFS will create: /tank/dir1/dir2 when that succeeds, it will try and create: /tank/dir1/dir2/dir3 The creation of /tank/dir1/dir2 file system succeeds, as you note. But the mounting of that file system fails because the /tank/dir1/dir2 directory contains files. Therefore the /tank/dir1/dir2/dir3 file system is not created. -- richard -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.opensolaris.org/pipermail/zfs-discuss/attachments/20110124/85b7bd9c/attachment.html>
Rahul Deb
2011-Jan-25 06:30 UTC
[zfs-discuss] zfs create -p only creates the parent but not the child
Thanks Richard for the prompt response. But second time same commands creates dir3 too. I mean to say, as I said earlier, first time it gives the mounting error and does not create dir3 *# zfs create -p tank/dir1/dir2/dir3* *cannot mount ''/tank/dir1/dir2'': directory is not empty* *#* but if I issue the same command again(just after the above error ), it creates the dir3. After that "zfs list" shows dir3 but "df -h" still does not show dir2 as mounted. *# zfs create -p tank/dir1/dir2/dir3* ***# zfs list|grep tank* ***tank 290K 228G 33K /tank* ***tank/dir1 95K 228G 32K /tank/dir1* ***tank/dir1/dir2 63K 228G 32K /tank/dir1/dir2* ***tank/dir1/dir2/dir3 31K 228G 31K /tank/dir1/dir2/dir3* ***#* * # df -h|grep tank* * tank 229G 33K 229G 1% /tank* * tank/dir1 229G 34K 229G 1% /tank/dir1* * tank/dir1/dir2/dir3 229G 31K 229G 1% /tank/dir1/dir2/dir3* * #* On Mon, Jan 24, 2011 at 7:02 PM, Richard Elling <richard.elling at gmail.com>wrote:> comment below... > > On Jan 24, 2011, at 1:58 PM, Rahul Deb wrote: > > I have a pool "tank" and "dir1" is the filesystem on that pool. "zfs list" > and "df -h" both shows "tank/dir1" mounted. > > *-----------------------------------------------------* > *# zfs list* > *tank 124K 228G 32K /tank* > *tank/dir1 31K 228G 31K /tank/dir1* > *#* > * > * > *# df -h* > *tank 229G 32K 229G 1% /tank* > *tank/dir1 229G 31K 229G 1% /tank/dir1* > *#* > *-----------------------------------------------------* > > After that I created a directory "dir2" with mkdir command under /tank/dir1 > and touch couple of files inside dir2 > > *-------------------* > *# cd /tank/dir1* > *# mkdir dir2* > *# cd dir2* > *# touch file1 file2* > *-------------------* > > > Now if I try to create zfs filesystem named "dir2/dir3" under "tank/dir1", > it gives the following message. Though I am using -p flag, it only creates > filesystem until tank/dir1/dir2 but not dir3 and also "df -h" does not show > "/tank/dir1/dir2" as mounted. > > *# zfs create -p tank/dir1/dir2/dir3* > *cannot mount ''/tank/dir1/dir2'': directory is not empty* > *#* > * > * > *# zfs list* > *tank 250K 228G 33K /tank* > *tank/dir1 63K 228G 32K /tank/dir1* > *tank/dir1/dir2 31K 228G 31K /tank/dir1/dir2* > *#* > > Is it a normal behaviour? > > > Yes. > With the -p option, ZFS will create: > /tank/dir1/dir2 > when that succeeds, it will try and create: > /tank/dir1/dir2/dir3 > > The creation of /tank/dir1/dir2 file system succeeds, as you note. > But the mounting of that file system fails because the /tank/dir1/dir2 > directory contains files. Therefore the /tank/dir1/dir2/dir3 file system > is not created. > -- richard > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.opensolaris.org/pipermail/zfs-discuss/attachments/20110124/ce94abe8/attachment-0001.html>
Cindy Swearingen
2011-Jan-25 22:41 UTC
[zfs-discuss] zfs create -p only creates the parent but not the child
You''re mixing a mkdir operation with a zfs create operation and only the zfs create operation creates a file system that is mounted, which is why df -h doesn''t show dir2 as mounted. dir2 is just a directory, not a file system. ZFS does two things with a default zfs create operation: o creates the file system o creates the file system mountpoint In this case, you pre-created the file system mount point but because it is not empty, ZFS can''t mount the file system. If the directory dir2 was empty, then this command would succeed by mounting the dir2 file system right over the dir2 directory: # zfs create tank/dir1 # mkdir /tank/dir1/dir2 # zfs create -p tank/dir1/dir2/dir3 # zfs list -r tank NAME USED AVAIL REFER MOUNTPOINT tank 210K 134G 32K /tank tank/dir1 95K 134G 32K /tank/dir1 tank/dir1/dir2 63K 134G 32K /tank/dir1/dir2 tank/dir1/dir2/dir3 31K 134G 31K /tank/dir1/dir2/dir3 Thanks, Cindy On 01/24/11 14:58, Rahul Deb wrote:> I have a pool "tank" and "dir1" is the filesystem on that pool. "zfs > list" and "df -h" both shows "tank/dir1" mounted. > > *-----------------------------------------------------* > *# zfs list* > *tank 124K 228G 32K /tank* > *tank/dir1 31K 228G 31K /tank/dir1* > *#* > * > * > *# df -h* > *tank 229G 32K 229G 1% /tank* > *tank/dir1 229G 31K 229G 1% /tank/dir1* > *#* > *-----------------------------------------------------* > > After that I created a directory "dir2" with mkdir command under > /tank/dir1 and touch couple of files inside dir2 > > *-------------------* > *# cd /tank/dir1* > *# mkdir dir2* > *# cd dir2* > *# touch file1 file2* > *-------------------* > > > Now if I try to create zfs filesystem named "dir2/dir3" under > "tank/dir1", it gives the following message. Though I am using -p flag, > it only creates filesystem until tank/dir1/dir2 but not dir3 and also > "df -h" does not show "/tank/dir1/dir2" as mounted. > > *# zfs create -p tank/dir1/dir2/dir3* > *cannot mount ''/tank/dir1/dir2'': directory is not empty* > *#* > * > * > *# zfs list* > *tank 250K 228G 33K /tank* > *tank/dir1 63K 228G 32K /tank/dir1* > *tank/dir1/dir2 31K 228G 31K /tank/dir1/dir2* > *#* > > Is it a normal behaviour? > > > ------------------------------------------------------------------------ > > _______________________________________________ > zfs-discuss mailing list > zfs-discuss at opensolaris.org > http://mail.opensolaris.org/mailman/listinfo/zfs-discuss