VIDEO
Additional Resources:
VIDEO
GitHub Introduce zfs rewrite subcommand
master ← amotin:rewrite
opened 08:33PM - 15 Apr 25 UTC
### Motivation and Context
For years users were asking for an ability to re-bal… ance pool after vdev addition, de-fragment randomly written files, change some properties for already written files, etc. The closest option would be to either copy and rename a file or send/receive/rename the dataset. Unfortunately all of those options have some downsides.
### Description
This change introduces new `zfs rewrite` subcommand, that allows to rewrite content of specified file(s) as-is without modifications, but at a different location, compression, checksum, dedup, copies and other parameter values. It is faster than read plus write, since it does not require data copying to user-space. It is also faster for sync=always datasets, since without data modification it does not require ZIL writing. Also since it is protected by normal range range locks, it can be done under any other load. Also it does not affect file's modification time or other properties.
### How Has This Been Tested?
Manually tested it on FreeBSD. Linux-specific code is not yet tested.
### Types of changes
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Performance enhancement (non-breaking change which improves efficiency)
- [ ] Code cleanup (non-breaking change which makes code smaller or more readable)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Library ABI change (libzfs, libzfs\_core, libnvpair, libuutil and libzfsbootenv)
- [ ] Documentation (a change to man pages or other documentation)
### Checklist:
- [x] My code follows the OpenZFS [code style requirements](https://github.com/openzfs/zfs/blob/master/.github/CONTRIBUTING.md#coding-conventions).
- [ ] I have updated the documentation accordingly.
- [ ] I have read the [**contributing** document](https://github.com/openzfs/zfs/blob/master/.github/CONTRIBUTING.md).
- [ ] I have added [tests](https://github.com/openzfs/zfs/tree/master/tests) to cover my changes.
- [ ] I have run the ZFS Test Suite with this change applied.
- [x] All commit messages are properly formatted and contain [`Signed-off-by`](https://github.com/openzfs/zfs/blob/master/.github/CONTRIBUTING.md#signed-off-by).
Man Page
Connect With Us
Lawrence Systems Shirts and Swag
►👕 Lawrence Systems
AFFILIATES & REFERRAL LINKS
Amazon Affiliate Store
Lawrence Systems's Amazon Page
UniFi Affiliate Link
Ubiquiti Store
All Of Our Affiliates help us out and can get you discounts!
Partners We Love – Lawrence Systems
Gear we use on Kit
Kit
Use OfferCode LTSERVICES to get 10% off your order at
Tech Supply Direct - Premium Refurbished Servers & Workstations at Unbeatable Prices
Digital Ocean Offer Code
DigitalOcean | Cloud Infrastructure for Developers
HostiFi UniFi Cloud Hosting Service
HostiFi - Launch UniFi and UISP in the Cloud
Protect your privacy with a VPN from Private Internet Access
https://www.privateinternetaccess.com/pages/buy-vpn/LRNSYS
Patreon
https://www.patreon.com/lawrencesystems
Chapters:
00:00 ZFS Rewrite Explained
02:01 Command Line Parameters
03:04 Using ZFS Rewrite in TrueNAS
04:26 Snapshots and ZFS Rewrite
05:23 Starting and Stopping
05:54 ZFS Permissions
06:11 ZFS rewrite and data risk