ZFS on MAC OSX

ZFS 是很好檔案系統,可惜因為種種原因…沒有機會在OSX 上面使用.
MACZFS
是好心人porting到MAC OSX上面,只要下載安裝包下來就可以直接使用.
以下是實際使用方式:
先查看目前磁碟使用狀況.

1
2
3
4
5
6
7
8
#  diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.1 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            300.9 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
   4:                  Apple_HFS data                    198.2 GB   disk0s4


查看目前支援的ZFS 版本到哪一個版本.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# zpool upgrade -v 
This system is currently running ZFS pool version 8.
 
The following versions are supported:
 
VER  DESCRIPTION
---  --------------------------------------------------------
 1   Initial ZFS version
 2   Ditto blocks (replicated metadata)
 3   Hot spares and double parity RAID-Z
 4   zpool history
 5   Compression using the gzip algorithm
 6   pool properties
 7   Separate intent log devices
 8   Delegated administration
For more information on a particular version, including supported releases, see:
 
http://www.opensolaris.org/os/community/zfs/version/N
 
Where 'N' is the version number.

將目前磁區縮小,並建立一個名稱ZFS新磁區.

1
2
3
4
5
6
7
8
#  diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.1 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            240.0 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s5
   4:                  Apple_HFS ZFS                     60.0 GB    disk0s4

將新磁區zfs,清除格式化為ZFS格式

1
2
3
4
5
# diskutil eraseVolume ZFS %noformat% /dev/disk0s4
Started erase on disk0s4 ZFS
Unmounting disk
Erasing
Finished erase on disk0s4 ZFS

建立新zpool

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# zpool create pool1 disk0s4
# zpool status pool1 
  pool: pool1
 state: ONLINE
 scrub: none requested
config:
 
	NAME        STATE     READ WRITE CKSUM
	pool1       ONLINE       0     0     0
	  disk0s4   ONLINE       0     0     0
 
errors: No known data errors
# diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.1 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            240.0 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s5
   4:                        ZFS pool1                   60.0 GB    disk0s4
 
# zfs list
NAME    USED  AVAIL  REFER  MOUNTPOINT
pool1  1.07M  54.6G  1005K  /Volumes/pool1

設定屬性compression=gzip壓縮檔按以節省空間

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# zfs set compression=gzip pool1
 
# zfs get all pool1                                                                                    (11-23 01:07)  
NAME   PROPERTY       VALUE                 SOURCE
pool1  type           filesystem            -
pool1  creation       三 11 23  0:55 2011  -
pool1  used           370K                  -
pool1  available      54.6G                 -
pool1  referenced     284K                  -
pool1  compressratio  1.00x                 -
pool1  mounted        yes                   -
pool1  quota          none                  default
pool1  reservation    none                  default
pool1  recordsize     128K                  default
pool1  mountpoint     /Volumes/pool1        default
pool1  sharenfs       off                   default
pool1  checksum       on                    default
pool1  compression    gzip                  local
pool1  atime          on                    default
pool1  devices        on                    default
pool1  exec           on                    default
pool1  setuid         on                    default
pool1  readonly       off                   default
pool1  zoned          off                   default
pool1  snapdir        hidden                default
pool1  aclmode        groupmask             default
pool1  aclinherit     secure                default
pool1  canmount       on                    default
pool1  shareiscsi     off                   default
pool1  xattr          on                    default
pool1  copies         1                     default
pool1  version        2                     -

以下是我開了一個mysql_data的節點使用壓縮compression=gzip,exec=off.
各位可以看到壓縮比compressratio = 4.18x 等於說我原本這些資料佔用6.85G 現在節省到只佔用1.64G!!!!
幫我MBP節省寶貴空間,如果你是用SSD更是要必需計較空間使用在此強力推薦ZFS來使用.(不過打開壓縮勢必在存取檔案消耗更多CPU)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 # zfs get all pool1/mysql_data
NAME              PROPERTY       VALUE                      SOURCE
pool1/mysql_data  type           filesystem                 -
pool1/mysql_data  creation       三 11 23  1:56 2011       -
pool1/mysql_data  used           1.64G                      -
pool1/mysql_data  available      14.9G                      -
pool1/mysql_data  referenced     1.64G                      -
pool1/mysql_data  compressratio  4.18x                      -
pool1/mysql_data  mounted        yes                        -
pool1/mysql_data  quota          none                       default
pool1/mysql_data  reservation    none                       default
pool1/mysql_data  recordsize     128K                       default
pool1/mysql_data  mountpoint     /Volumes/pool1/mysql_data  default
pool1/mysql_data  sharenfs       off                        default
pool1/mysql_data  checksum       on                         default
pool1/mysql_data  compression    gzip                       local
pool1/mysql_data  atime          on                         default
pool1/mysql_data  devices        on                         default
pool1/mysql_data  exec           off                        local
pool1/mysql_data  setuid         on                         default
pool1/mysql_data  readonly       off                        default
pool1/mysql_data  zoned          off                        default
pool1/mysql_data  snapdir        hidden                     default
pool1/mysql_data  aclmode        groupmask                  default
pool1/mysql_data  aclinherit     secure                     default
pool1/mysql_data  canmount       on                         default
pool1/mysql_data  shareiscsi     off                        default
pool1/mysql_data  xattr          on                         default
pool1/mysql_data  copies         1                          default
pool1/mysql_data  version        2                          -

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *