Показаны сообщения с ярлыком ZFS. Показать все сообщения
Показаны сообщения с ярлыком ZFS. Показать все сообщения
пятница, 2 октября 2015 г.
Don't think for me...
I really like OpenVZ and Proxmox. But what I hate is programs which try to think for me. For example, we have /var/lib/vz and subdirectories on ZFS. If by chance it was not mounted on system startup, OpenVZ creates subdirectories in /var/lib/vz/template. Next time ZFS filesystem containers/vz/template just will not be mounted on non-empty /var/lib/vz/template. And you discover it only during runtime. If OpenVZ just threw error on startup, it would be better. If ZFS just silently mounted filesystems over non-empty directories (as usual mount does), it would be better. But two subsystems try to think for me and make my life better. I hate programs being so smart...
пятница, 8 ноября 2013 г.
beadm destroy error
Today when I was trying to destroy old boot environment, I got strange error:
# beadm destroy oi-hipster-2013-08-06 Are you sure you want to destroy oi-hipster-2013-08-06? This action cannot be undone (y/[n]): y be_destroy_callback: failed to destroy data/zones/build/ROOT/zbe: dataset is busy be_destroy: failed to destroy BE data/zones/build/ROOT/zbe be_destroy_zone_root_callback: failed to destroy zone root data/zones/build/ROOT/zbe be_destroy_zone_roots: failed to destroy zone roots under zonepath dataset data/zones/build: dataset is busy be_destroy_zones: failed to find and destroy zone roots for zone build be_destroy: failed to destroy one or more zones for BE oi-hipster-2013-08-06I didn't want to destroy zone root FS accidentally, so was a bit scared. However, after looking at it a bit longer, I found out, that zone root FS has several manual ZFS snapshots. After destroying snapshots I was able to destroy BE.
четверг, 21 марта 2013 г.
Deleted files in directory
I was just refreshing my knowledge about filesystems... In FreeBSD it is definately easier to investigate fs behavior. You can just do a hexdump of a directory. In Solaris and Linux this does not work. Hexdump of zfs directory is not very interesting. However, in ufs dump we can see that deleted files persist in directory listing:
# zfs create -V 1G zpool/zvol1 # newfs /dev/zvol/zpool/zvol1 # mkdir test # mount /dev/zvol/zpool/zvol1 `pwd`/test # cd test # mkdir 99 # cd 99 # touch a b c d e # hd . 00000000 00 14 01 00 0c 00 04 01 2e 00 00 00 02 00 00 00 |................| 00000010 0c 00 04 02 2e 2e 00 00 01 14 01 00 0c 00 08 01 |................| 00000020 61 00 05 9e 02 14 01 00 0c 00 08 01 62 00 05 9e |a...........b...| 00000030 03 14 01 00 0c 00 08 01 63 00 05 9e 04 14 01 00 |........c.......| 00000040 0c 00 08 01 64 00 05 9e 05 14 01 00 b8 01 08 01 |....d...........| 00000050 65 00 05 9e 00 00 00 00 00 00 00 00 00 00 00 00 |e...............| 00000060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00000200Now, after removing some files we can see that corresponding records still exist in directory:
# rm e d a # hd . 00000000 00 14 01 00 0c 00 04 01 2e 00 00 00 02 00 00 00 |................| 00000010 18 00 04 02 2e 2e 00 00 01 14 01 00 0c 00 08 01 |................| 00000020 61 00 05 9e 02 14 01 00 0c 00 08 01 62 00 05 9e |a...........b...| 00000030 03 14 01 00 d0 01 08 01 63 00 05 9e 04 14 01 00 |........c.......| 00000040 c4 01 08 01 64 00 05 9e 05 14 01 00 b8 01 08 01 |....d...........| 00000050 65 00 05 9e 00 00 00 00 00 00 00 00 00 00 00 00 |e...............| 00000060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00000200 # ls b cIf we add some files, we can see that deleted record is used again:
# touch f # hd . 00000000 00 14 01 00 0c 00 04 01 2e 00 00 00 02 00 00 00 |................| 00000010 0c 00 04 02 2e 2e 00 00 01 14 01 00 0c 00 08 01 |................| 00000020 66 00 e9 05 02 14 01 00 0c 00 08 01 62 00 05 9e |f...........b...| 00000030 03 14 01 00 d0 01 08 01 63 00 05 9e 04 14 01 00 |........c.......| 00000040 c4 01 08 01 64 00 05 9e 05 14 01 00 b8 01 08 01 |....d...........| 00000050 65 00 05 9e 00 00 00 00 00 00 00 00 00 00 00 00 |e...............| 00000060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00000200
суббота, 24 сентября 2011 г.
Adding vdev to raidz pool
There is one fundamental flaw in raidz ZFS pools: you can't add devices to raidz (as opposed to usual raid5). So, could we do anything to expand our pool without full rebuilding? Yes, if we are ready to sacrifice one more disk.
From zpool man page:
So, to add some capacity to our pool, we can add one more raidz to it. Let's look at this process. Firstly, let's create test pool from three "disks":
Now, let's see what we have:
Now let's expand this pool:
So, we recieved the following configuration:
Let's compare this to raidz from 6 disks:
So, we lost more then 21% of space, but expanded our pool without downtime. Firstly, the lost of more then 20% space suprised me, but 20% was expectable (in second case only 5 disks, in first - 4, so 20% is the difference).
Let's see, where did 1 percent go. 443 MB is useful in second case, it means about 11.4 MB (100 /*disk size*/ - 443/*useful space*/ / 5 /*useful disks*/) metadata per disk. In first case we have 349 MB. It is provided by two pools with 2 useful disks in each. So, wasted space per disk is 12.75 MB (100 - 349/2/2). It seems, in this configuration we have a bit more metadata.
From zpool man page:
A pool can have any number of virtual devices at the top of the config‐
uration (known as "root vdevs"). Data is dynamically distributed across
all top-level devices to balance data among devices. As new virtual
devices are added, ZFS automatically places data on the newly available
devices.
So, to add some capacity to our pool, we can add one more raidz to it. Let's look at this process. Firstly, let's create test pool from three "disks":
freebsd# foreach i ( 1 2 3 4 5 6)
foreach? dd if=/dev/zero of=/tmp/disk$i bs=100M count=1
foreach? end
freebsd# zpool create testpool raidz /tmp/disk1 /tmp/disk2 /tmp/disk3
Now, let's see what we have:
freebsd# zpool status testpool
pool: testpool
state: ONLINE
scrub: none requested
config:
NAME STATE READ WRITE CKSUM
testpool ONLINE 0 0 0
raidz1 ONLINE 0 0 0
/tmp/disk1 ONLINE 0 0 0
/tmp/disk2 ONLINE 0 0 0
/tmp/disk3 ONLINE 0 0 0
errors: No known data errors
freebsd# zpool list testpool
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
testpool 286M 156K 286M 0% ONLINE -
freebsd# zfs list testpool
NAME USED AVAIL REFER MOUNTPOINT
testpool 95.9K 158M 28.0K /testpool
Now let's expand this pool:
freebsd# zpool add testpool raidz /tmp/disk4 /tmp/disk5 /tmp/disk6
So, we recieved the following configuration:
freebsd# zpool status testpool
pool: testpool
state: ONLINE
scrub: none requested
config:
NAME STATE READ WRITE CKSUM
testpool ONLINE 0 0 0
raidz1 ONLINE 0 0 0
/tmp/disk1 ONLINE 0 0 0
/tmp/disk2 ONLINE 0 0 0
/tmp/disk3 ONLINE 0 0 0
raidz1 ONLINE 0 0 0
/tmp/disk4 ONLINE 0 0 0
/tmp/disk5 ONLINE 0 0 0
/tmp/disk6 ONLINE 0 0 0
errors: No known data errors
freebsd# zpool list testpool
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
testpool 572M 210K 572M 0% ONLINE -
freebsd# zfs list testpool
NAME USED AVAIL REFER MOUNTPOINT
testpool 114K 349M 28.0K /testpool
Let's compare this to raidz from 6 disks:
freebsd# zpool create testpool raidz /tmp/disk1 /tmp/disk2 /tmp/disk3 /tmp/disk4 /tmp/disk5 /tmp/disk6
freebsd# zpool status testpool
pool: testpool
state: ONLINE
scrub: none requested
config:
NAME STATE READ WRITE CKSUM
testpool ONLINE 0 0 0
raidz1 ONLINE 0 0 0
/tmp/disk1 ONLINE 0 0 0
/tmp/disk2 ONLINE 0 0 0
/tmp/disk3 ONLINE 0 0 0
/tmp/disk4 ONLINE 0 0 0
/tmp/disk5 ONLINE 0 0 0
/tmp/disk6 ONLINE 0 0 0
errors: No known data errors
freebsd# zpool list testpool
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
testpool 572M 147K 572M 0% ONLINE -
freebsd# zfs list testpool
NAME USED AVAIL REFER MOUNTPOINT
testpool 112K 443M 34.9K /testpool
So, we lost more then 21% of space, but expanded our pool without downtime. Firstly, the lost of more then 20% space suprised me, but 20% was expectable (in second case only 5 disks, in first - 4, so 20% is the difference).
Let's see, where did 1 percent go. 443 MB is useful in second case, it means about 11.4 MB (100 /*disk size*/ - 443/*useful space*/ / 5 /*useful disks*/) metadata per disk. In first case we have 349 MB. It is provided by two pools with 2 useful disks in each. So, wasted space per disk is 12.75 MB (100 - 349/2/2). It seems, in this configuration we have a bit more metadata.
среда, 27 октября 2010 г.
ZFS snapshots or something new on something old
Everyone knows that snapshots are fascinating feature of ZFS. Automatic snapshots in OpenSolaris used to save my mental health. After migration to FreeBSD I thought "It would be easy. There are a lot of decisions for managing ZFS snapshots in FreeBSD". In fact, theare are too many decisions for managing ZFS snapshots in FreeBSD. It's hard to choose one decision. I've looked for example, on sysutils/zfsnap, sysutils/zfs-snapshot-mgmt... But my needs are quite different:
At last, I decided to create my own solution which was supposed to work as rc script (I boot my computer once or twice per day, and it would be good to have startup snapshot of the system).
The text of script is provided below.
There are three parameters for my script - zfs_snapshot_pool, zfs_snapshot_filesystems and zfs_snapshot_keep_days. First or second parameter may be used to specify pool (and all its FS for creating snapshots) or explicitly selecting necessary filesystems. Parameter fs_snapshot_keep_days determines when snapshot is considered outdated.
This simple script is supposed to make my life more comfortable...
- I'd like the decision for making automatic snapshots to be simple and effective as an axe.
- I'd like to understand how every line of these scripts (for creating and deleting snapshots) work to feel myself comfortable.
- I'm going to use snapshots on my home desktop, and I'd only like to have quite recent copy of my data to recover files after making some silly mistakes.
At last, I decided to create my own solution which was supposed to work as rc script (I boot my computer once or twice per day, and it would be good to have startup snapshot of the system).
The text of script is provided below.
#!/bin/sh
. /etc/rc.subr
name="zfs_snapshot"
start_cmd="create_snapshots"
stop_cmd="drop_snapshots"
zfs_pool=${zfs_snapshot_pool:-"zpool"}
keep_days=${zfs_snapshot_keep_days:-30}
create_snapshots()
{
echo "Creating zfs snapshots..."
if [ -z "${zfs_snapshot_filesystems}" ]; then
snapshot_filesystems=`zfs list -H -o name -t filesystem`;
else
snapshot_filesystems=${zfs_snapshot_filesystems};
fi
DATE=`env LC_ALL=C date -j "+%Y_%m_%d-%H:%M"`
for fs in $snapshot_filesystems ; do
snap="${fs}@AUTO_${DATE}"
logger -t $name "Creating snapshot $snap"
zfs snapshot $snap
done
}
drop_snapshots()
{
echo "Destroying old automatic zfs snapshots"
current_date=`date "+%s"`
if [ -z "${zfs_snapshot_filesystems}" ]; then
snapshot_filesystems=`zfs list -H -o name -t filesystem`;
else
snapshot_filesystems=${zfs_snapshot_filesystems};
fi
for fs in $snapshot_filesystems ; do
snapshots=`zfs list -H -t snapshot -o name -r $fs |grep "^${fs}@AUTO_"`;
for snap in $snapshots; do
creation_local=`zfs list -H -t snapshot -o creation $snap`
creation_real=`date -j -f "%a %b %d %k:%M %Y" "${creation_local}" "+%s"`
eval creation_minus=$(( ( ${current_date} - ${creation_real})/3600/24 ))
if [ $creation_minus -gt $keep_days ]; then
logger -t $name "Destroying snapshot $snap"
zfs destroy $snap
fi
done
done
}
load_rc_config $name
run_rc_command $*
There are three parameters for my script - zfs_snapshot_pool, zfs_snapshot_filesystems and zfs_snapshot_keep_days. First or second parameter may be used to specify pool (and all its FS for creating snapshots) or explicitly selecting necessary filesystems. Parameter fs_snapshot_keep_days determines when snapshot is considered outdated.
This simple script is supposed to make my life more comfortable...
пятница, 23 июля 2010 г.
FreeBSD 8.1
Now I'm downloading FreeBSD 8.1 DVD. Release was announced today. New features includes
1) addition of zfsloader
2) zpool support updated to version 14 (passthrough-x aclinherit maybe very useful on terminal server)
3) support for new SPARC and Power PC chips (does someone really use FreeBSD on SPARC? it looks strange even to meet SPARC nowadays :()
4) contributed software updates...
Link to news: http://www.freebsd.org/releases/8.1R/announce.html
Among these features I like new zpool version and presence of zfsloader...
It's interesting, will FreeBSD/8.1-i386 be quite stable with ZFS mirror pool, 2 GB of RAM and KDE? Let's test it...
1) addition of zfsloader
2) zpool support updated to version 14 (passthrough-x aclinherit maybe very useful on terminal server)
3) support for new SPARC and Power PC chips (does someone really use FreeBSD on SPARC? it looks strange even to meet SPARC nowadays :()
4) contributed software updates...
Link to news: http://www.freebsd.org/releases/8.1R/announce.html
Among these features I like new zpool version and presence of zfsloader...
It's interesting, will FreeBSD/8.1-i386 be quite stable with ZFS mirror pool, 2 GB of RAM and KDE? Let's test it...
вторник, 13 июля 2010 г.
Good news
I've just read that ZFS v15 was commited to FreeBSD-HEAD with 2 months before MFC to 8-STABLE (http://ivoras.sharanet.org/blog/tree/2010-07-13.all-welcome-zfs-v15-in-freebsd.html). It's really good news: we'll have faster, more stable ZFS version and it will support user quotas (lack of quotas was one of the things that prevented us from deploying it on our file server)... Great thanks to Martin for his work!
It's not enough - another piece of good news pc-sysinstall now supports packages. What does it mean? As I understand, this means one more step in side of easy binary package management in FreeBSD (http://www.freebsd.org/cgi/query-pr.cgi?pr=148584).
And last one. I've just read that NASA is going to use PostgreSQL to store data for quazy realtime monitoring system of Space Station (http://www.spinics.net/lists/pgsql/msg112022.html). I'm happy for PostgreSQL.
It's not enough - another piece of good news pc-sysinstall now supports packages. What does it mean? As I understand, this means one more step in side of easy binary package management in FreeBSD (http://www.freebsd.org/cgi/query-pr.cgi?pr=148584).
And last one. I've just read that NASA is going to use PostgreSQL to store data for quazy realtime monitoring system of Space Station (http://www.spinics.net/lists/pgsql/msg112022.html). I'm happy for PostgreSQL.
среда, 7 июля 2010 г.
Moving data to FreeBSD
Now I decided to move from OpenSolaris to FreeBSD.
Just for now I emulate this procedure in VirtualBox, later I'll do it on real hardware...
1) Installed OpenSolaris 09.06 and updated it to b134, updated zfs pool to version 19, added mirror disk to pool. So, I have configuration identical to my workstation.
2) Splitted pool (used zpool split for this task), destroyed second pool (which appeared as result of split) and filled first sectors of disk with zeroes (dd if=/dev/zero of=/dev/rdsk/) to erase all signs of zfs pool.
3) Booted from FreeBSD dvd (i386) and made everything similar to http://wiki.freebsd.org/RootOnZFS/ZFSBootPartition. Some caveats: I didn't manage to get zpool.cache from first time, had to import/export pool to get it. At the end of the procedure I got zfs pool consisting from /dev/ad1s1.
4) After some time I managed to boot from my pool (made several errors during install, e.g. forgot about zpool.cache and accidentally wrote wrong rc.conf).
5) Booted in OpenSolaris and imported my pool under alternative /fbsd root. Create on the FreeBSD zfs pool filesystem /old and zfs send all data from OpenSolaris /export fs there.
6) Rebooted. Couldn't boot FreeBSD. So I booted from FreeBSD DVD, imported ZFS pool and moved /boot/zfs/zpool.cache to zpool's /boot/zfs/zpool.cache
7) Now I have running ZFS FreeBSD installation
TODO:
a) add second mirror drive (old OpenSolaris drive) to new ZFS pool and put boot code and loader there.
b) tune i386 FreeBSD for ZFS usage...
After completing these tasks I'm going to make this procedure on physical system... (Certainly, after creating backup...)
Just for now I emulate this procedure in VirtualBox, later I'll do it on real hardware...
1) Installed OpenSolaris 09.06 and updated it to b134, updated zfs pool to version 19, added mirror disk to pool. So, I have configuration identical to my workstation.
2) Splitted pool (used zpool split for this task), destroyed second pool (which appeared as result of split) and filled first sectors of disk with zeroes (dd if=/dev/zero of=/dev/rdsk/
3) Booted from FreeBSD dvd (i386) and made everything similar to http://wiki.freebsd.org/RootOnZFS/ZFSBootPartition. Some caveats: I didn't manage to get zpool.cache from first time, had to import/export pool to get it. At the end of the procedure I got zfs pool consisting from /dev/ad1s1.
4) After some time I managed to boot from my pool (made several errors during install, e.g. forgot about zpool.cache and accidentally wrote wrong rc.conf).
5) Booted in OpenSolaris and imported my pool under alternative /fbsd root. Create on the FreeBSD zfs pool filesystem /old and zfs send all data from OpenSolaris /export fs there.
6) Rebooted. Couldn't boot FreeBSD. So I booted from FreeBSD DVD, imported ZFS pool and moved /boot/zfs/zpool.cache to zpool's /boot/zfs/zpool.cache
7) Now I have running ZFS FreeBSD installation
TODO:
a) add second mirror drive (old OpenSolaris drive) to new ZFS pool and put boot code and loader there.
b) tune i386 FreeBSD for ZFS usage...
After completing these tasks I'm going to make this procedure on physical system... (Certainly, after creating backup...)
Подписаться на:
Сообщения (Atom)