6464 libbe shouldn't mangle zfs mountpoints
Review Request #297 — Created Dec. 17, 2016 and updated — Latest diff uploaded
Information | |
---|---|
alp | |
illumos-gate | |
6464 | |
Reviewers | |
general | |
Currently libbe mangle boot environments mountpoints while mounting them.
For example:$ sudo beadm mount oi-hipster-2016-08-23 /mnt
$ zfs list |grep oi-hipster-2016-08-23
rpool/ROOT/oi-hipster-2016-08-23 27.7M 40.8G 38.9G /mntNow if we reboot system in such state, without unmounting boot environment, on fresh boot mountpoint will be incorrect. When BE has one filesystem, it's not critical. But when BE has, for example, the following structure:
rpool/ROOT/hipster-2016-10-29 30.1M 3.90G 7.39G /
rpool/ROOT/hipster-2016-10-29/var 7.33M 3.90G 1.39G /varon boot rpool/ROOT/hipster-2016-10-29/var will have incorrect mountpoint, set to /mnt/var . fs-minimal will refuse to mount it, and system will not boot.
One of the methods to solve it is to avoid setting zfs mountpoints while mounting boot environments. To do it we use zfs_mount-like function mount_zfs() in libbe, which uses mount(2) to mount ZFS filesystems.
# beadm list BE Active Mountpoint Space Policy Created hipster-2016-10-29 - - 30.1M static 2016-11-19 13:15 hispter-2016-12-08 - - 30.5M static 2016-12-08 22:26 hipster-2016-12-17-be-test NR / 18.3G static 2016-12-17 14:02 # beadm mount hipster-2016-10-29 /mnt Mounted successfully on: '/mnt' # beadm list BE Active Mountpoint Space Policy Created hipster-2016-10-29 - /mnt 30.1M static 2016-11-19 13:15 hispter-2016-12-08 - - 30.5M static 2016-12-08 22:26 hipster-2016-12-17-be-test NR / 18.3G static 2016-12-17 14:02 # zfs list |grep hipster-2016-10-29 rpool/ROOT/hipster-2016-10-29 30.1M 3.99G 7.39G / rpool/ROOT/hipster-2016-10-29/var 7.33M 3.99G 1.39G /var # beadm umount /mnt Unmounted successfully # beadm mount hipster-2016-10-29 /mnt Mounted successfully on: '/mnt' # beadm umount hipster-2016-10-29 Unmounted successfully # pkg uninstall -v --require-new-be --be-name hipster-2016-12-17-be-test-1 media/wildmidi ... # beadm list BE Active Mountpoint Space Policy Created hipster-2016-10-29 - - 30.1M static 2016-11-19 13:15 hispter-2016-12-08 - - 30.5M static 2016-12-08 22:26 hipster-2016-12-17-be-test N / 112K static 2016-12-17 14:02 hipster-2016-12-17-be-test-1 R - 18.6G static 2016-12-17 22:46 # beadm mount hipster-2016-12-17-be-test-1 /mnt # zfs list |grep hipster-2016-12-17-be-test-1 rpool/ROOT/hipster-2016-12-17-be-test-1 13.6G 3.81G 7.50G / rpool/ROOT/hipster-2016-12-17-be-test-1/var 3.44G 3.81G 733M /var # df Filesystem 1K-blocks Used Available Use% Mounted on rpool/ROOT/hipster-2016-12-17-be-test 11859016 7866134 3992882 67% / swap 4361200 1204 4359996 1% /etc/svc/volatile rpool/ROOT/hipster-2016-12-17-be-test/var 4743858 750976 3992882 16% /var swap 4360004 8 4359996 1% /tmp swap 4360056 60 4359996 1% /var/run rpool/export 3992907 25 3992882 1% /export rpool/export/home 4035270 42388 3992882 2% /export/home /export/home/leoric 4231317 238435 3992882 6% /home/leoric rpool 3992921 39 3992882 1% /rpool rpool/zones 3992907 25 3992882 1% /zones rpool/ROOT/hipster-2016-12-17-be-test-1 11858253 7865371 3992882 67% /mnt rpool/ROOT/hipster-2016-12-17-be-test-1/var 4743798 750916 3992882 16% /mnt/var # init 6 ###### After this system would not go up clean earlier ##### After system boots to new BE, checking bootadm # bootadm install-bootloader -v be_do_installboot: device c2t0d0s0 Command: "/usr/sbin/installboot //boot/pmbr //boot/gptzfsboot /dev/rdsk/c2t0d0s0" Errors: bootblock version installed on /dev/rdsk/c2t0d0s0 is more recent or identical Use -F to override or install without the -u option # bootadm list-menu the location for the active menu is: /rpool/boot/menu.lst Index Default Dataset Menu 0 - rpool/ROOT/hipster-2016-10-29 hipster-2016-10-29 1 - rpool/ROOT/hispter-2016-12-08 hispter-2016-12-08 2 - rpool/ROOT/hipster-2016-12-17-be-test hipster-2016-12-17-be-test 3 * rpool/ROOT/hipster-2016-12-17-be-test-1 hipster-2016-12-17-be-test-1I created zone and checked that beadm behaves as expected with zone's datasets.
# beadm create test Created successfully # beadm mount test /mnt Mounted successfully on: '/mnt' # df |grep /mnt rpool/ROOT/test 12688466 7865467 4822999 62% /mnt rpool/ROOT/test/var 5872819 1049820 4822999 18% /mnt/var rpool/zones/test/ROOT/zbe-1 5919408 1096409 4822999 19% /mnt/zones/test/root # zfs list |grep zones rpool/zones 1.05G 4.60G 26K /zones rpool/zones/test 1.05G 4.60G 31K /zones/test rpool/zones/test/ROOT 1.05G 4.60G 29K legacy rpool/zones/test/ROOT/zbe 1.05G 4.60G 1.05G legacy rpool/zones/test/ROOT/zbe-1 134K 4.60G 1.05G legacy # beadm umount /mnt Unmounted successfully # zlogin test # beadm list BE Active Mountpoint Space Policy Created zbe NR / 1.05G static 2016-12-17 21:46 zbe-1 xb - 134K static 2016-12-17 22:05 # beadm mount zbe-1 /mnt Mounted successfully on: '/mnt' # df |grep zbe-1 /mnt (rpool/zones/test/ROOT/zbe-1): 9628835 blocks 9628835 files # zfs list NAME USED AVAIL REFER MOUNTPOINT rpool 18.5G 4.59G 38.5K /rpool rpool/zones 1.05G 4.59G 26K /zones rpool/zones/test 1.05G 4.59G 31K /zones/test rpool/zones/test/ROOT 1.05G 4.59G 29K legacy rpool/zones/test/ROOT/zbe 1.05G 4.59G 1.05G legacy rpool/zones/test/ROOT/zbe-1 134K 4.59G 1.05G legacy # beadm umount /mnt Unmounted successfully # df |grep zbe-1 ###Shows nothing