Using gcc-7 for the Ceph build is a simple matter of:
> sudo zypper in gcc7-c++ > CC=gcc-7 CXX=/usr/bin/g++-7 ./do_cmake.sh ... > cd build && make -j$(nproc)
> sudo zypper in gcc7-c++ > CC=gcc-7 CXX=/usr/bin/g++-7 ./do_cmake.sh ... > cd build && make -j$(nproc)
~/> cd ~ ~/> git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git ~/> git clone https://github.com/rapido-linux/rapido.git
~/> cp rapido/kernel/vanilla_config linux/.config ~/> cd linux ~/linux/> make -j6 ~/linux/> make modules ~/linux/> INSTALL_MOD_PATH=./mods make modules_install
~/linux/> cd ~/rapido ~/rapido/> cp rapido.conf.example rapido.conf ~/rapido/> vi rapido.conf
~/rapido/> ./cut_fstests_local.sh ... dracut: *** Creating initramfs image file 'initrds/myinitrd' done *** ~/rapido/> ls -lah initrds/myinitrd -rw-r--r-- 1 ddiss users 30M Dec 13 18:17 initrds/myinitrd
~/rapido/> ./vm.sh + mount -t btrfs /dev/zram1 /mnt/scratch [ 3.542927] BTRFS info (device zram1): disk space caching is enabled ... btrfs filesystem mounted at /mnt/test and /mnt/scratch rapido1:/#
rapido1:/# shutdown [ 267.304313] sysrq: SysRq : sysrq: Power Off rapido1:/# [ 268.168447] ACPI: Preparing to enter system sleep state S5 [ 268.169493] reboot: Power down + exit 0
~/rapido/> sudo tools/br_setup.sh ~/rapido/> ip addr show br0 4: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 ... inet 192.168.155.1/24 scope global br0
~/> git clone https://github.com/ceph/ceph ~/> cd ceph <install Ceph build dependencies> ~/ceph/> ./do_cmake.sh -DWITH_MANPAGE=0 -DWITH_OPENLDAP=0 -DWITH_FUSE=0 -DWITH_NSS=0 -DWITH_LTTNG=0 ~/ceph/> cd build ~/ceph/build/> make -j4
~/ceph/build/> OSD=3 MON=1 RGW=0 MDS=1 ../src/vstart.sh -i 192.168.155.1 -n ... ~/ceph/build/> bin/ceph -c status ... health HEALTH_OK monmap e2: 1 mons at {a=192.168.155.1:40160/0} election epoch 4, quorum 0 a fsmap e5: 1/1/1 up {0=a=up:active} mgr no daemons active osdmap e10: 3 osds: 3 up, 3 in
~/ceph/build/> cd ~/rapido ~/rapido/> vi rapido.conf
~/rapido/> ./cut_cephfs.sh
... dracut: *** Creating initramfs image file 'initrds/myinitrd' done ***
~/rapido/> ./vm.sh
...
+ mount -t ceph 192.168.155.1:40160:/ /mnt/cephfs -o name=admin,secret=... [ 3.492742] libceph: mon0 192.168.155.1:40160 session established ... rapido1:/# df -h /mnt/cephfs Filesystem Size Used Avail Use% Mounted on 192.168.155.1:40160:/ 1.3T 611G 699G 47% /mnt/cephfsCephFS is a clustered filesystem, in which case testing from multiple clients is also of interest. From another window, boot a second VM:
~/rapido/> ./vm.sh
![]() |
Test Environment Overview - image based on content by Sage Weil |
> sudo /sbin/brctl addbr br0 > sudo ip addr add 192.168.155.1/24 dev br0 > sudo ip link set dev br0 up
> sudo /sbin/tunctl -u $(whoami) -t tap0 > sudo /sbin/brctl addif br0 tap0 > sudo ip link set tap0 up
> cd $ceph_source_dir <build Ceph> > cd src > OSD=3 MON=1 RGW=0 MDS=1 ./vstart.sh -i 192.168.155.1 -n --memstore
> cd $kernel_source_dir > make menuconfig$kernel_source_dir should be replaced with the actual path. Ensure CONFIG_BLK_DEV_RBD=m, CONFIG_CEPH_FS=y, CONFIG_CEPH_LIB=y, CONFIG_E1000=y and CONFIG_IP_PNP=y are set in the kernel config. A sample can be found here.
> make > INSTALL_MOD_PATH=./mods make modules_install
Create a link to the modules directory ./mods, so that Dracut can find them:
> sudo ln -s $PWD/mods/lib/modules/$(make kernelrelease) \ /lib/modules/$(make kernelrelease)
> export CEPH_SRC=$ceph_source_dir/src > dracut --no-compress --kver "$(cat include/config/kernel.release)" \ --install "tail blockdev ps rmdir resize dd vim grep find df sha256sum \ strace mkfs.xfs /lib64/libkeyutils.so.1" \ --include "$CEPH_SRC/mount.ceph" "/sbin/mount.ceph" \ --include "$CEPH_SRC/ceph.conf" "/etc/ceph/ceph.conf" \ --add-drivers "rbd" \ --no-hostonly --no-hostonly-cmdline \ --modules "bash base network ifcfg" \ --force myinitrd
> qemu-kvm -smp cpus=2 -m 512 \ -kernel arch/x86/boot/bzImage -initrd myinitrd \ -device e1000,netdev=network1,mac=b8:ac:6f:31:45:70 \ -netdev tap,id=network1,script=no,downscript=no,ifname=tap0 \ -append "ip=192.168.155.2:::255.255.255.0:myhostname \ rd.shell=1 console=ttyS0 rd.lvm=0 rd.luks=0" \ -nographic
dracut:/# ip a ... 2: eth0: ... mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether b8:ac:6f:31:45:70 brd ff:ff:ff:ff:ff:ff inet 192.168.155.2/24 brd 192.168.155.255 scope global eth0
> cd $ceph_source_dir/src > ./rados lspools rbd ...
> ./rbd create --image-format 1 --size 1024 1g_vstart_img > ./rbd ls -l NAME SIZE PARENT FMT PROT LOCK 1g_vstart_img 1024M 1
dracut:/# modprobe rbd [ 9.031056] rbd: loaded dracut:/# echo -n "192.168.155.1:6789 name=admin,secret=AQBPiuhd9389dh28djASE32Ceiojc234AF345w== rbd 1g_vstart_img -" > /sys/bus/rbd/add [ 347.743272] libceph: mon0 192.168.155.1:6789 session established [ 347.744284] libceph: client4121 fsid 234b432f-a895-43d2-23fd-9127a1837b32 [ 347.749516] rbd: rbd0: added with size 0x40000000
dracut:/# mkfs.xfs /dev/rbd0 ... dracut:/# mkdir -p /mnt/rbdfs dracut:/# mount /dev/rbd0 /mnt/rbdfs [ 415.841757] XFS (rbd0): Mounting V4 Filesystem [ 415.917595] XFS (rbd0): Ending clean mount dracut:/# df -h /mnt/rbdfs Filesystem Size Used Avail Use% Mounted on /dev/rbd0 1014M 33M 982M 4% /mnt/rbdfs
> cd $ceph_source_dir/src > ./ceph fs ls > name: cephfs_a, metadata pool: cephfs_metadata_a, data pools: [cephfs_data_a ]All that's left is to mount it from the kernel VM using the mount.ceph binary that was copied into the initramfs:
dracut:/# mkdir -p /mnt/mycephfs dracut:/# mount.ceph 192.168.155.1:6789:/ /mnt/mycephfs \ -o name=admin,secret=AQBPiuhd9389dh28djASE32Ceiojc234AF345w== [ 723.103153] libceph: mon0 192.168.155.1:6789 session established [ 723.184978] libceph: client4122 fsid 234b432f-a895-43d2-23fd-9127a1837b32 dracut:/# df -h /mnt/mycephfs/ Filesystem Size Used Avail Use% Mounted on 192.168.155.1:6789:/ 3.0G 4.0M 3.0G 1% /mnt/mycephfs
dracut:/# umount /mnt/mycephfsUnmount the RBD image:
dracut:/# umount /dev/rbd0 [ 1592.592510] XFS (rbd0): Unmounting FilesystemUnmap the RBD image (0 is derived from /dev/rbdX):
dracut:/# echo -n 0 > /sys/bus/rbd/removePower-off the VM:
dracut:/# echo 1 > /proc/sys/kernel/sysrq && echo o > /proc/sysrq-trigger [ 1766.387417] sysrq: SysRq : Power Off dracut:/# [ 1766.811686] ACPI: Preparing to enter system sleep state S5 [ 1766.812217] reboot: Power downShutdown the Ceph cluster:
> cd $ceph_source_dir/src > ./stop.sh
~/> sudo zypper install --no-recommends git-core gcc make ncurses-devel bc ~/> git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git ~/> cd linux ~/linux/> wget https://raw.githubusercontent.com/ddiss/ceph_usb_gateway/master/.config # or `make sunxi_defconfig menuconfig` # ->enable Ceph, sunxi and USB gadget modules ~/linux/> make oldconfig ~/linux/> make -j2 zImage dtbs modules ~/linux/> sudo make install modules_install ~/linux/> sudo cp arch/arm/boot/zImage /boot/zImage-$(make kernelrelease) ~/linux/> sudo cp arch/arm/boot/dts/sun7i-a20-cubietruck.dtb /boot/dtb-4.3.0-2/ ~/linux/> sudo cp arch/arm/boot/dts/sun7i-a20-cubietruck.dtb /boot/dtb/
# modprobe rbd
# echo -n "${MON_IP}:6789 name=${AUTH_NAME},secret=${AUTH_SECRET} " \
"${CEPH_POOL} ${CEPH_IMG} -" > /sys/bus/rbd/add
# echo -n "${DEV_ID}" > /sys/bus/rbd/remove
# rbd create --size=10240 --pool ${CEPH_POOL} ${CEPH_IMG}
# modprobe sunxi configfs libcomposite usb_f_mass_storage # mount -t configfs configfs /sys/kernel/config # cd /sys/kernel/config/usb_gadget/ # mkdir -p ceph # cd ceph # mkdir -p strings/0x409 # echo "fedcba9876543210" > strings/0x409/serialnumber # echo "openSUSE" > strings/0x409/manufacturer # echo "Ceph USB Drive" > strings/0x409/product # mkdir -p functions/mass_storage.usb0 # echo 1 > functions/mass_storage.usb0/stall # echo 0 > functions/mass_storage.usb0/lun.0/cdrom # echo 0 > functions/mass_storage.usb0/lun.0/ro # echo 0 > functions/mass_storage.usb0/lun.0/nofua # echo "$DEV" > functions/mass_storage.usb0/lun.0/file # mkdir -p configs/c.1/strings/0x409 # echo "Config 1: mass-storage" > configs/c.1/strings/0x409/configuration # echo 250 > configs/c.1/MaxPower # ln -s functions/mass_storage.usb0 configs/c.1/ # ls /sys/class/udc > UDC$DEV corresponds to a /dev/X device path, which should be a locally mapped RBD device path. The module can however also use local files as backing for USB mass storage.
[Unit] Wants=network-online.target After=network-online.target [Service] # XXX assume that rbd_usb_gw.sh is present in /bin ExecStart=/bin/rbd_usb_gw.sh %i Type=oneshot RemainAfterExit=yes
POST_UP_SCRIPT="systemd:rbd-mapper@.service"
# dracut --no-compress \ --kver "`uname -r" \ --install "ps rmdir dd vim grep find df modinfo" \ --add-drivers "rbd musb_hdrc sunxi configfs" \ --no-hostonly --no-hostonly-cmdline \ --modules "bash base network ifcfg" \ --include /bin/rbd_usb_gw.sh /lib/dracut/hooks/emergency/02_rbd_usb_gw.sh \ myinitrd
=> setenv append 'ip=dhcp'
=> boot
# cp myinitrd /boot/
# rm /boot/initrd
# sudo ln -s /boot/myinitrd /boot/initrd