[Kernel-packages] [Bug 1639500] Re: Snapshot the system zpool from within the initramfs

2017-04-05 Thread Aron Xu
** Changed in: zfs-linux (Ubuntu)
   Importance: Undecided => Wishlist

** Tags added: patch

-- 
You received this bug notification because you are a member of Kernel
Packages, which is subscribed to zfs-linux in Ubuntu.
https://bugs.launchpad.net/bugs/1639500

Title:
  Snapshot the system zpool from within the initramfs

Status in zfs-linux package in Ubuntu:
  New

Bug description:
  Idea/enhancement request.

  I wrote a small initramfs script to snapshot the zpool when booting
  off zfs in Ubuntu. As the pool is not actively used at that moment, it
  is in the perfect consistent state to take snapshots. Perhaps this is
  functionality more people are interested in?

  To use it, you do 2 things:
  - put the script in /etc/initramfs-tools/scripts/local-bottom and update the 
initrd (update-initramfs -ck all)
  - add a boot parameter in the form of ZFSSNAP=xx in /etc/default/grub and run 
update-grub. xx has to be an integer

  As I did not want to tamper with the initrd too much, it does not
  require any additional tools in the initrd image. However it uses the
  zfs-auto-snapshot syntax using "boot" as identifier instead of
  hourly/daily/weekly/monthly/yearly.

  As mentioned above you trigger the script when adding ZFSSNAP=xx as a
  grub parameter, where xx is an integer. The script will keep the last
  xx days that contain valid "boot" snapshots, and delete older ones.
  The number of snapshots on a single day is irrelevant.

  The script goes in /etc/initramfs-tools/scripts/local-bottom, so runs
  right after the root zpool is imported. Snapshot queries are done only
  on the top level of the pool ("-d 1") to avoid the script slowing down
  the boot process too much although this means orphans are possible if
  the cleaning operation is interrupted (system reset for example).

  If this kind of functionality would be supported by the systemd import
  script, other zpools on the system could be snapshotted at import time
  as well. I considered importing my other zpools in the initramfs stage
  temporarily just for snapshotting them, but then decided to keep it
  all simple and refrain from that. Only a zpool that is defined on the
  kernel command line for the rootfs (root=ZFS=zpool/rootfs) will be
  taken into account.

  So basically, if you add ZFSSNAP=4 to grub and put the script in the
  initrd image, you will end up with snapshots in the form 'dataset@zfs-
  auto-snap_boot--MM-DD-HHMM' for MYPOOL and all recursive datasets
  on MYPOOL that don't have com.sun:auto-snapshot set to false. You will
  find these snapshots for every time you have rebooted your machine but
  only the last 4 days (re)boots occured.

  Disclaimer: I am not a developer so the script might not be a piece of
  art. It does the job though.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/zfs-linux/+bug/1639500/+subscriptions

-- 
Mailing list: https://launchpad.net/~kernel-packages
Post to : kernel-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kernel-packages
More help   : https://help.launchpad.net/ListHelp


[Kernel-packages] [Bug 1639500] Re: Snapshot the system zpool from within the initramfs

2016-11-09 Thread Sam VdE
Small fixes done.

** Attachment removed: "script for /etc/initramfs-tools/scripts/local-bottom"
   
https://bugs.launchpad.net/ubuntu/+source/zfs-linux/+bug/1639500/+attachment/4773061/+files/zfs-boot-snap

** Attachment removed: "zfs-systemd-snap"
   
https://bugs.launchpad.net/ubuntu/+source/zfs-linux/+bug/1639500/+attachment/4773687/+files/zfs-systemd-snap

** Attachment added: "zfs-boot-snap"
   
https://bugs.launchpad.net/ubuntu/+source/zfs-linux/+bug/1639500/+attachment/4774847/+files/zfs-boot-snap

-- 
You received this bug notification because you are a member of Kernel
Packages, which is subscribed to zfs-linux in Ubuntu.
https://bugs.launchpad.net/bugs/1639500

Title:
  Snapshot the system zpool from within the initramfs

Status in zfs-linux package in Ubuntu:
  New

Bug description:
  Idea/enhancement request.

  I wrote a small initramfs script to snapshot the zpool when booting
  off zfs in Ubuntu. As the pool is not actively used at that moment, it
  is in the perfect consistent state to take snapshots. Perhaps this is
  functionality more people are interested in?

  To use it, you do 2 things:
  - put the script in /etc/initramfs-tools/scripts/local-bottom and update the 
initrd (update-initramfs -ck all)
  - add a boot parameter in the form of ZFSSNAP=xx in /etc/default/grub and run 
update-grub. xx has to be an integer

  As I did not want to tamper with the initrd too much, it does not
  require any additional tools in the initrd image. However it uses the
  zfs-auto-snapshot syntax using "boot" as identifier instead of
  hourly/daily/weekly/monthly/yearly.

  As mentioned above you trigger the script when adding ZFSSNAP=xx as a
  grub parameter, where xx is an integer. The script will keep the last
  xx days that contain valid "boot" snapshots, and delete older ones.
  The number of snapshots on a single day is irrelevant.

  The script goes in /etc/initramfs-tools/scripts/local-bottom, so runs
  right after the root zpool is imported. Snapshot queries are done only
  on the top level of the pool ("-d 1") to avoid the script slowing down
  the boot process too much although this means orphans are possible if
  the cleaning operation is interrupted (system reset for example).

  If this kind of functionality would be supported by the systemd import
  script, other zpools on the system could be snapshotted at import time
  as well. I considered importing my other zpools in the initramfs stage
  temporarily just for snapshotting them, but then decided to keep it
  all simple and refrain from that. Only a zpool that is defined on the
  kernel command line for the rootfs (root=ZFS=zpool/rootfs) will be
  taken into account.

  So basically, if you add ZFSSNAP=4 to grub and put the script in the
  initrd image, you will end up with snapshots in the form 'dataset@zfs-
  auto-snap_boot--MM-DD-HHMM' for MYPOOL and all recursive datasets
  on MYPOOL that don't have com.sun:auto-snapshot set to false. You will
  find these snapshots for every time you have rebooted your machine but
  only the last 4 days (re)boots occured.

  Disclaimer: I am not a developer so the script might not be a piece of
  art. It does the job though.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/zfs-linux/+bug/1639500/+subscriptions

-- 
Mailing list: https://launchpad.net/~kernel-packages
Post to : kernel-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kernel-packages
More help   : https://help.launchpad.net/ListHelp


[Kernel-packages] [Bug 1639500] Re: Snapshot the system zpool from within the initramfs

2016-11-09 Thread Sam VdE
Small fixes done.

** Attachment added: "zfs-systemd-snap"
   
https://bugs.launchpad.net/ubuntu/+source/zfs-linux/+bug/1639500/+attachment/4774848/+files/zfs-systemd-snap

-- 
You received this bug notification because you are a member of Kernel
Packages, which is subscribed to zfs-linux in Ubuntu.
https://bugs.launchpad.net/bugs/1639500

Title:
  Snapshot the system zpool from within the initramfs

Status in zfs-linux package in Ubuntu:
  New

Bug description:
  Idea/enhancement request.

  I wrote a small initramfs script to snapshot the zpool when booting
  off zfs in Ubuntu. As the pool is not actively used at that moment, it
  is in the perfect consistent state to take snapshots. Perhaps this is
  functionality more people are interested in?

  To use it, you do 2 things:
  - put the script in /etc/initramfs-tools/scripts/local-bottom and update the 
initrd (update-initramfs -ck all)
  - add a boot parameter in the form of ZFSSNAP=xx in /etc/default/grub and run 
update-grub. xx has to be an integer

  As I did not want to tamper with the initrd too much, it does not
  require any additional tools in the initrd image. However it uses the
  zfs-auto-snapshot syntax using "boot" as identifier instead of
  hourly/daily/weekly/monthly/yearly.

  As mentioned above you trigger the script when adding ZFSSNAP=xx as a
  grub parameter, where xx is an integer. The script will keep the last
  xx days that contain valid "boot" snapshots, and delete older ones.
  The number of snapshots on a single day is irrelevant.

  The script goes in /etc/initramfs-tools/scripts/local-bottom, so runs
  right after the root zpool is imported. Snapshot queries are done only
  on the top level of the pool ("-d 1") to avoid the script slowing down
  the boot process too much although this means orphans are possible if
  the cleaning operation is interrupted (system reset for example).

  If this kind of functionality would be supported by the systemd import
  script, other zpools on the system could be snapshotted at import time
  as well. I considered importing my other zpools in the initramfs stage
  temporarily just for snapshotting them, but then decided to keep it
  all simple and refrain from that. Only a zpool that is defined on the
  kernel command line for the rootfs (root=ZFS=zpool/rootfs) will be
  taken into account.

  So basically, if you add ZFSSNAP=4 to grub and put the script in the
  initrd image, you will end up with snapshots in the form 'dataset@zfs-
  auto-snap_boot--MM-DD-HHMM' for MYPOOL and all recursive datasets
  on MYPOOL that don't have com.sun:auto-snapshot set to false. You will
  find these snapshots for every time you have rebooted your machine but
  only the last 4 days (re)boots occured.

  Disclaimer: I am not a developer so the script might not be a piece of
  art. It does the job though.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/zfs-linux/+bug/1639500/+subscriptions

-- 
Mailing list: https://launchpad.net/~kernel-packages
Post to : kernel-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kernel-packages
More help   : https://help.launchpad.net/ListHelp


[Kernel-packages] [Bug 1639500] Re: Snapshot the system zpool from within the initramfs

2016-11-06 Thread Sam VdE
** Attachment added: "zfs-mount.service"
   
https://bugs.launchpad.net/ubuntu/+source/zfs-linux/+bug/1639500/+attachment/4773689/+files/zfs-mount.service

-- 
You received this bug notification because you are a member of Kernel
Packages, which is subscribed to zfs-linux in Ubuntu.
https://bugs.launchpad.net/bugs/1639500

Title:
  Snapshot the system zpool from within the initramfs

Status in zfs-linux package in Ubuntu:
  New

Bug description:
  Idea/enhancement request.

  I wrote a small initramfs script to snapshot the zpool when booting
  off zfs in Ubuntu. As the pool is not actively used at that moment, it
  is in the perfect consistent state to take snapshots. Perhaps this is
  functionality more people are interested in?

  To use it, you do 2 things:
  - put the script in /etc/initramfs-tools/scripts/local-bottom and update the 
initrd (update-initramfs -ck all)
  - add a boot parameter in the form of ZFSSNAP=xx in /etc/default/grub and run 
update-grub. xx has to be an integer

  As I did not want to tamper with the initrd too much, it does not
  require any additional tools in the initrd image. However it uses the
  zfs-auto-snapshot syntax using "boot" as identifier instead of
  hourly/daily/weekly/monthly/yearly.

  As mentioned above you trigger the script when adding ZFSSNAP=xx as a
  grub parameter, where xx is an integer. The script will keep the last
  xx days that contain valid "boot" snapshots, and delete older ones.
  The number of snapshots on a single day is irrelevant.

  The script goes in /etc/initramfs-tools/scripts/local-bottom, so runs
  right after the root zpool is imported. Snapshot queries are done only
  on the top level of the pool ("-d 1") to avoid the script slowing down
  the boot process too much although this means orphans are possible if
  the cleaning operation is interrupted (system reset for example).

  If this kind of functionality would be supported by the systemd import
  script, other zpools on the system could be snapshotted at import time
  as well. I considered importing my other zpools in the initramfs stage
  temporarily just for snapshotting them, but then decided to keep it
  all simple and refrain from that. Only a zpool that is defined on the
  kernel command line for the rootfs (root=ZFS=zpool/rootfs) will be
  taken into account.

  So basically, if you add ZFSSNAP=4 to grub and put the script in the
  initrd image, you will end up with snapshots in the form 'dataset@zfs-
  auto-snap_boot--MM-DD-HHMM' for MYPOOL and all recursive datasets
  on MYPOOL that don't have com.sun:auto-snapshot set to false. You will
  find these snapshots for every time you have rebooted your machine but
  only the last 4 days (re)boots occured.

  Disclaimer: I am not a developer so the script might not be a piece of
  art. It does the job though.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/zfs-linux/+bug/1639500/+subscriptions

-- 
Mailing list: https://launchpad.net/~kernel-packages
Post to : kernel-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kernel-packages
More help   : https://help.launchpad.net/ListHelp


[Kernel-packages] [Bug 1639500] Re: Snapshot the system zpool from within the initramfs

2016-11-06 Thread Sam VdE
For the additional pools one might have, I adapted the script so it
snapshots everything else.

To trigger the script I added a new service zfs-import-scan.service, and
I adapted the existing zfs-mount.service to include it. This way
additional zpools will be snapshotted right after being imported, and
before mounting takes place. The script doing the work is called zfs-
systemd-snap.

I keep both the initramfs and systemd solution in place on my systems
because the rootfs has been pivoted when systemd runs and the whole goal
of this is to snapshot zpools without them being written to. I did make
sure not to snapshot a zpool twice.

To test the additional systemd stuff:
- add zfs-systemd-snap to /etc/systemd
- add zfs-import-scan.service to /etc/systemd/system and run "systemctl enable 
zfs-import-scan.service"
- add zfs-mount.service to /etc/systemd/system and run "systemctl enable 
zfs-mount.service"

That's basically it, it should run based on the same GRUB parameter
mentioned before behaving the same way.

Disclaimer: when executing the steps above you are effectively
overriding the default zfs-mount.service script provided by the Ubuntu-
provided zfs packages. If the unit file gets updated in the future, this
will no longer be reflected on your system.

-- 
You received this bug notification because you are a member of Kernel
Packages, which is subscribed to zfs-linux in Ubuntu.
https://bugs.launchpad.net/bugs/1639500

Title:
  Snapshot the system zpool from within the initramfs

Status in zfs-linux package in Ubuntu:
  New

Bug description:
  Idea/enhancement request.

  I wrote a small initramfs script to snapshot the zpool when booting
  off zfs in Ubuntu. As the pool is not actively used at that moment, it
  is in the perfect consistent state to take snapshots. Perhaps this is
  functionality more people are interested in?

  To use it, you do 2 things:
  - put the script in /etc/initramfs-tools/scripts/local-bottom and update the 
initrd (update-initramfs -ck all)
  - add a boot parameter in the form of ZFSSNAP=xx in /etc/default/grub and run 
update-grub. xx has to be an integer

  As I did not want to tamper with the initrd too much, it does not
  require any additional tools in the initrd image. However it uses the
  zfs-auto-snapshot syntax using "boot" as identifier instead of
  hourly/daily/weekly/monthly/yearly.

  As mentioned above you trigger the script when adding ZFSSNAP=xx as a
  grub parameter, where xx is an integer. The script will keep the last
  xx days that contain valid "boot" snapshots, and delete older ones.
  The number of snapshots on a single day is irrelevant.

  The script goes in /etc/initramfs-tools/scripts/local-bottom, so runs
  right after the root zpool is imported. Snapshot queries are done only
  on the top level of the pool ("-d 1") to avoid the script slowing down
  the boot process too much although this means orphans are possible if
  the cleaning operation is interrupted (system reset for example).

  If this kind of functionality would be supported by the systemd import
  script, other zpools on the system could be snapshotted at import time
  as well. I considered importing my other zpools in the initramfs stage
  temporarily just for snapshotting them, but then decided to keep it
  all simple and refrain from that. Only a zpool that is defined on the
  kernel command line for the rootfs (root=ZFS=zpool/rootfs) will be
  taken into account.

  So basically, if you add ZFSSNAP=4 to grub and put the script in the
  initrd image, you will end up with snapshots in the form 'dataset@zfs-
  auto-snap_boot--MM-DD-HHMM' for MYPOOL and all recursive datasets
  on MYPOOL that don't have com.sun:auto-snapshot set to false. You will
  find these snapshots for every time you have rebooted your machine but
  only the last 4 days (re)boots occured.

  Disclaimer: I am not a developer so the script might not be a piece of
  art. It does the job though.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/zfs-linux/+bug/1639500/+subscriptions

-- 
Mailing list: https://launchpad.net/~kernel-packages
Post to : kernel-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kernel-packages
More help   : https://help.launchpad.net/ListHelp


[Kernel-packages] [Bug 1639500] Re: Snapshot the system zpool from within the initramfs

2016-11-06 Thread Sam VdE
** Attachment added: "zfs-import-snap.service"
   
https://bugs.launchpad.net/ubuntu/+source/zfs-linux/+bug/1639500/+attachment/4773688/+files/zfs-import-snap.service

-- 
You received this bug notification because you are a member of Kernel
Packages, which is subscribed to zfs-linux in Ubuntu.
https://bugs.launchpad.net/bugs/1639500

Title:
  Snapshot the system zpool from within the initramfs

Status in zfs-linux package in Ubuntu:
  New

Bug description:
  Idea/enhancement request.

  I wrote a small initramfs script to snapshot the zpool when booting
  off zfs in Ubuntu. As the pool is not actively used at that moment, it
  is in the perfect consistent state to take snapshots. Perhaps this is
  functionality more people are interested in?

  To use it, you do 2 things:
  - put the script in /etc/initramfs-tools/scripts/local-bottom and update the 
initrd (update-initramfs -ck all)
  - add a boot parameter in the form of ZFSSNAP=xx in /etc/default/grub and run 
update-grub. xx has to be an integer

  As I did not want to tamper with the initrd too much, it does not
  require any additional tools in the initrd image. However it uses the
  zfs-auto-snapshot syntax using "boot" as identifier instead of
  hourly/daily/weekly/monthly/yearly.

  As mentioned above you trigger the script when adding ZFSSNAP=xx as a
  grub parameter, where xx is an integer. The script will keep the last
  xx days that contain valid "boot" snapshots, and delete older ones.
  The number of snapshots on a single day is irrelevant.

  The script goes in /etc/initramfs-tools/scripts/local-bottom, so runs
  right after the root zpool is imported. Snapshot queries are done only
  on the top level of the pool ("-d 1") to avoid the script slowing down
  the boot process too much although this means orphans are possible if
  the cleaning operation is interrupted (system reset for example).

  If this kind of functionality would be supported by the systemd import
  script, other zpools on the system could be snapshotted at import time
  as well. I considered importing my other zpools in the initramfs stage
  temporarily just for snapshotting them, but then decided to keep it
  all simple and refrain from that. Only a zpool that is defined on the
  kernel command line for the rootfs (root=ZFS=zpool/rootfs) will be
  taken into account.

  So basically, if you add ZFSSNAP=4 to grub and put the script in the
  initrd image, you will end up with snapshots in the form 'dataset@zfs-
  auto-snap_boot--MM-DD-HHMM' for MYPOOL and all recursive datasets
  on MYPOOL that don't have com.sun:auto-snapshot set to false. You will
  find these snapshots for every time you have rebooted your machine but
  only the last 4 days (re)boots occured.

  Disclaimer: I am not a developer so the script might not be a piece of
  art. It does the job though.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/zfs-linux/+bug/1639500/+subscriptions

-- 
Mailing list: https://launchpad.net/~kernel-packages
Post to : kernel-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kernel-packages
More help   : https://help.launchpad.net/ListHelp