Ceph 預設是使用 btrfs, 所以第一次初始化時, 可以透過參數把 storage 準備好
mkcephfs -a -c /etc/ceph/ceph.conf --mkbtrfs
不過如果要改用 ext4 就沒有這麼輕鬆, 首先你必須在每一台 osd 自行準備好一塊 ext4, 而且掛載到正確的路徑
根據
網站上的描述
The ext4 partition must be mounted with -o user_xattr or else mkcephfs will fail. Also using noatime,nodiratime boosts performance at no cost. When using ext4, you should disable the ext4 journal
root@wistor-dev-7:~$ mke2fs -t ext4 /dev/mapper/ubuntu64--33--7-lvol0
mke2fs 1.41.14 (22-Dec-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
13107200 inodes, 52428800 blocks
2621440 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
1600 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 28 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
root@wistor-dev-7:~$ tune2fs -o journal_data_writeback /dev/mapper/ubuntu64--33--7-lvol0
tune2fs 1.41.14 (22-Dec-2010)
root@wistor-dev-7:~$ tune2fs -O ^has_journal /dev/mapper/ubuntu64--33--7-lvol0
tune2fs 1.41.14 (22-Dec-2010)
root@wistor-dev-7:~$ e2fsck -f /dev/mapper/ubuntu64--33--7-lvol0
e2fsck 1.41.14 (22-Dec-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/mapper/ubuntu64--33--7-lvol0: 11/13107200 files (0.0% non-contiguous), 837781/52428800 blocks
為了讓每次開機能自動掛載這個磁區, 要修改一下 /etc/fstab
root@wistor-dev-7:~$ cat /etc/fstab
proc /proc proc nodev,noexec,nosuid 0 0
/dev/mapper/ubuntu64--33--7-root / ext4 errors=remount-ro 0 1
# /boot was on /dev/sda1 during installation
UUID=bf0a72da-7ca7-4960-9a7e-f90298b95609 /boot ext2 defaults 0 2
/dev/mapper/ubuntu64--33--7-swap_1 none swap sw 0 0
# 加入這一行
/dev/mapper/ubuntu64--33--7-lvol0 /srv/osd.2 ext4 errors=remount-ro,data=writeback,noatime,nodiratime,user_xattr 0 1
root@wistor-dev-7:~$ mount -a
root@wistor-dev-7:~$ mount
/dev/mapper/ubuntu64--33--7-lvol0 on /srv/osd.2 type ext4 (rw,noatime,nodiratime,errors=remount-ro,data=writeback,user_xattr)
然後修改 /etc/ceph/ceph.conf
[osd]
; This is where the btrfs volume will be mounted.
osd data = /srv/osd.$id
[osd.0]
host = wistor-dev-5
# 把原本指定 btrfs devs 的這行拿掉
# btrfs devs = /dev/mapper/ubuntu1104--64--5-lvol0
[osd.1]
host = wistor-dev-6
# 把原本指定 btrfs devs 的這行拿掉
# btrfs devs = /dev/mapper/wistor--dev--6-lvol0
[osd.2]
host = wistor-dev-7
# 把原本指定 btrfs devs 的這行拿掉
# btrfs devs = /dev/mapper/ubuntu64--33--7-lvol0