Compare commits
	
		
			2 Commits
		
	
	
		
			1f70342aad
			...
			310b180580
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 310b180580 | |||
| ec7931cb4c | 
							
								
								
									
										61
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										61
									
								
								README.md
									
									
									
									
									
								
							@@ -341,12 +341,61 @@ find '/opt/git.bak' -type d -empty -delete
 | 
			
		||||
 | 
			
		||||
An example `zpool/data` dataset may now look like so:
 | 
			
		||||
```
 | 
			
		||||
# zfs list -r -oname,mountpoint,canmount zpool/data
 | 
			
		||||
NAME                MOUNTPOINT  CANMOUNT
 | 
			
		||||
zpool/data          /           off
 | 
			
		||||
zpool/data/home     /home       on
 | 
			
		||||
zpool/data/opt      /opt        off
 | 
			
		||||
zpool/data/opt/git  /opt/git    on
 | 
			
		||||
# zfs list -r -oname,mountpoint,canmount,mounted zpool/data
 | 
			
		||||
NAME                MOUNTPOINT       CANMOUNT  MOUNTED
 | 
			
		||||
zpool/data          /                off       no
 | 
			
		||||
zpool/data/home     /home            on        yes
 | 
			
		||||
zpool/data/opt      /opt             off       no
 | 
			
		||||
zpool/data/opt/git  /opt/git         on        yes
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Nested environment-independent datasets
 | 
			
		||||
 | 
			
		||||
### Caution
 | 
			
		||||
 | 
			
		||||
If you want a dedicated dataset for a directory that lives deeper in your file system tree than just `/opt/git`, for example like `/var/lib/docker` make sure to not recursively create this structure in a single `zfs create` command.
 | 
			
		||||
 | 
			
		||||
In [Adding another boot environment-independent dataset](#adding-another-boot-environment-independent-dataset) above you can safely do:
 | 
			
		||||
```
 | 
			
		||||
zfs create -o canmount=off zpool/data/opt
 | 
			
		||||
```
 | 
			
		||||
Here `zpool/data` already exists, you're only creating one child dataset `opt` and you're setting `-o canmount=off` so that it never mounts into your `/opt` directory.
 | 
			
		||||
 | 
			
		||||
Now consider the same setup for `/var/lib/docker`. If you follow the exact same approach:
 | 
			
		||||
```
 | 
			
		||||
zfs create -o canmount=off zpool/data/var/lib
 | 
			
		||||
```
 | 
			
		||||
Docker will correctly report:
 | 
			
		||||
```
 | 
			
		||||
cannot create 'zpool/data/var/lib': parent does not exist
 | 
			
		||||
```
 | 
			
		||||
You might want to just create the parent then with `-p` argument:
 | 
			
		||||
```
 | 
			
		||||
zfs create -p -o canmount=off zpool/data/var/lib
 | 
			
		||||
           ~~
 | 
			
		||||
```
 | 
			
		||||
Note, however, that `-o canmount=off` only applies to `lib` dataset and that `zpool/data/var` has just been auto-mounted into `/var`:
 | 
			
		||||
```
 | 
			
		||||
# zfs list -r -oname,mountpoint,canmount,mounted zpool/data
 | 
			
		||||
NAME                MOUNTPOINT  CANMOUNT  MOUNTED
 | 
			
		||||
zpool/data          /           off       no
 | 
			
		||||
zpool/data/home     /home       on        yes
 | 
			
		||||
zpool/data/opt      /opt        off       no
 | 
			
		||||
zpool/data/opt/git  /opt/git    on        yes
 | 
			
		||||
zpool/data/var      /var        on        yes  <---
 | 
			
		||||
zpool/data/var/lib  /var/lib    off       no
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### Advice
 | 
			
		||||
 | 
			
		||||
Instead create nested parents in multiple steps where you set each one to `-o canmount=off`:
 | 
			
		||||
```
 | 
			
		||||
zfs create -o canmount=off zpool/data/var
 | 
			
		||||
zfs create -o canmount=off zpool/data/var/lib
 | 
			
		||||
```
 | 
			
		||||
Lastly create the dataset you want mounted:
 | 
			
		||||
```
 | 
			
		||||
zfs create zpool/data/var/lib/docker
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
# Development
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user