ZFS on an usb stick

click

New Member


Messages: 15

Hello,

I`m interested if anyone has tried installing ZFS on USB sticks (not the root or any part of the system itself)? What I have in mind is using USB sticks for daily backup - create zfs snapshot and send it to the zfs of the USB stick.

Will I be able to boot in this configuration if the USB stick is removed? If I remove the USB stick and put it in, will I be able to retrieve the pool? Will I be able to use the USB stick pool on other system running using zfs? Would I need to label the usb GPT partition using glabel?

The system in subject is FreeBSD 8.2-RELEASE

Thanks :)
 

ian-nai

Member

Reaction score: 4
Messages: 48

click said:
I`m interested if anyone has tried installing ZFS on USB sticks(not the root or any part of the system itself)?
What I have in mind is using USB sticks for daily backup - create zfs snapshot and send it to the zfs of the USB stick.
Yes, zpool create usbstick /dev/da1 creates a zpool on whatever's at /dev/da1 (usb stick, for instance)

click said:
Will I be able to boot in this configuration if the USB stick is removed?
I don't know, if you mirror a bootable zpool onto the USB stick, probably. Has anybody else tried this already?

click said:
If I remove the USB stick and put it in, will I be able to retrieve the pool?
Yes, all you need to do is tell zpool to export the pool contained on the usb drive *before* you remove it.

[CMD=""]zpool export usbstick[/CMD]

click said:
Will I be able to use the USB stick pool on other system running using zfs?
Yes, just connect the drive and import it.
[CMD=""]zpool import
zpool import usbstick
[/CMD]
"zpool import" tells you what is available for import and the second command imports a pool named usbstick

click said:
Would I need to label the usb GPT partition using glabel?
No, ZFS labels drives itself. Though, I think it's "okay" to glabel a drive before passing the label to ZFS (just be sure to do it in that order...I think.)

Also, the relevant backup commands to copy a dataset (filesystem, snapshot, pool, etc) are zpool send and zpool receive. An example would be something like:

[CMD=""]zpool send pool2send | zpool receive usbstick [/CMD]

I hope that helps!
 

danbi

Active Member

Reaction score: 30
Messages: 227

I have found that because of the write aggregation, USB sticks perform better with ZFS, than with UFS for "normal" filesystem operation. The "normal" usage is different from writing backup data as large files on the stick.

You should however test the booting process of the USB stick, because controllers are wildly different, both on the USB stick and the host USB interfaces. Some sticks don't boot on some motherboards and that's it. Also make sure you have something like

Code:
kern.cam.boot_delay=10000
in /boot/loader.conf of the USB stick before trying to boot from it, as FreeBSD after 8.0 has some trouble with USB sticks/interfaces that are slow to discover the "drive".

If you need to boot the USB stick, you need to use either MBR or GPT label. The various ZFS-only-on-GPT guides work for USB sticks.

I am still unclean as to what your question really is. Here is what I understood:

- USB and ZFS -- good combination, yes!
- Booting USB stick with ZFS - works as expected.
- Using USB stick with ZFS filesystem in it as backup device - works as explained already.

- Using the USB stick as backup ZFS filesystem. This would work if your original ZFS filesystem is fairly small, because USB sticks are small in size, compared to other drives. There should not be trouble to send updates to the USB stick resident ZFS filesystem and it still boot. But if your data set it large, USB connected external hard drive is probably better idea.
 

danbi

Active Member

Reaction score: 30
Messages: 227

I have found that because of the write aggregation, USB sticks perform better with ZFS, than with UFS for "normal" filesystem operation. The "normal" usage is different from writing backup data as large files on the stick.

You should however test the booting process of the USB stick, because controllers are wildly different, both on the USB stick and the host USB interfaces. Some sticks don't boot on some motherboards and that's it. Also make sure you have something like

Code:
kern.cam.boot_delay=10000
in /boot/loader.conf of the USB stick before trying to boot from it, as FreeBSD after 8.0 has some trouble with USB sticks/interfaces that are slow to discover the "drive".

If you need to boot the USB stick, you need to use either MBR or GPT label. The various ZFS-only-on-GPT guides work for USB sticks.

I am still unclean as to what your question really is. Here is what I understood:

- USB and ZFS -- good combination, yes!
- Booting USB stick with ZFS - works as expected.
- Using USB stick with ZFS filesystem in it as backup device - works as explained already.

- Using the USB stick as backup ZFS filesystem. This would work if your original ZFS filesystem is fairly small, because USB sticks are small in size, compared to other drives. There should not be trouble to send updates to the USB stick resident ZFS filesystem and it still boot. But if your data set it large, USB connected external hard drive is probably better idea.
 
OP
C

click

New Member


Messages: 15

Solved

Thanks a lot ian-nai and danbi.
I didn`t explain my goal correctly at first place, but will try now.

We had one gmirror made out of two hard drives and one single disk used for temporary storage. Until now we had daily backup on usb sticks using tar and weekly backups using dump. Now
we`ve migrated the system to zfs with the same configuration - 1 zpool in mirror with two disks and one zpool with one disk. My goal is to make snapshot and send it to the usb stick - not dump it to file. The flash drive dosen`t needs to boot, I was just wondering if in the middle of the backup the system reboots and the usb stick dies will the system be able to came up again with the broken zpool still imported.

So I`ve test it and yes the system boots up without the usb stick.

And the solution is:

Destroy the old MBR layout and create new GPT one
Code:
gpart destroy -F da0
gpart create -s gpt /dev/da0
Add partition for the zfs and label it so it can work even if it change its device name
Code:
gpart add -t freebsd-zfs -l weekly-backup da0
Create the zpool
Code:
zpool create weekly-backup /dev/gpt/weekly-backup
Exporting the zpool so we can remove the flash drive in a hurry without damaging the zpool
Code:
zpool export weekly-backup
The actual backup will be some script that does:
Code:
zpool import weekly-backup
zfs snapshot zstore/samba/storage@`date +%Y%m%d`
zfs send zstore/samba/storage@`date +%Y%m%d` | zfs receive weekly-backup/storage@`date +%Y%m%d`
zpool export weekly-backup
 

danbi

Active Member

Reaction score: 30
Messages: 227

By the way, there is not much point in labeling the USB stick, if it will be for single-drive zpool. ZFS will figure out the devices that comprise the pool all by itself -- you will inport/export the pool frequently with the USB stick anyway.

By not labeling the USB stick, it will be usage in order operating systems.
 

Galactic_Dominator

Active Member

Reaction score: 37
Messages: 196

danbi said:
By not labeling the USB stick, it will be usage in order operating systems.
He's using GPT labels, not GEOM labels meaning every OS that supports GPT will read that label just fine.
 
Top