Login
Run the command "ssh userXX@play.coker.com.au" with password "userXX" where XX is your user number. Change the password after you login.
To access your virtual machine run the command "ssh root@userXX".
BTRFS
- Making the filesystem
- Make the filesystem, this makes a filesystem that spans 2 devices:
mkfs.btrfs /dev/xvdd /dev/xvde
- Use file(1) to see basic data from the superblocks:
file -s /dev/xvdd /dev/xvde
- Mount the filesystem (can mount either block device, the kernel knows they belong together):
mount /dev/xvdd /mnt/tmp
- See a BTRFS df of the filesystem, shows what type of RAID is used:
btrfs filesystem df /mnt/tmp
- See more information about FS device use:
btrfs filesystem show /mnt/tmp
- Balance the filesystem to change RAID settings and verify the change:
btrfs balance start -dconvert=raid1 -mconvert=raid1 -sconvert=raid1 --force /mnt/tmp
btrfs filesystem df /mnt/tmp
- See if there are any errors, shouldn't be any (yet):
btrfs device stats /mnt/tmp
- Copy some files to the filesystem:
cp -r /usr /mnt/tmp
- Check the filesystem for basic consistency (only checks checksums):
btrfs scrub start -B -d /mnt/tmp
Online corruption
- Corrupt the filesystem:
dd if=/dev/zero of=/dev/xvdd bs=1024k count=2000 seek=50
- Scrub again, should give a warning about errors:
btrfs scrub start -B /mnt/tmp
- Check error count:
btrfs device stats /mnt/tmp
- Corrupt it again:
dd if=/dev/zero of=/dev/xvdd bs=1024k count=2000 seek=50
- Unmount it:
umount /mnt/tmp
- In another terminal follow the kernel log:
tail -f /var/log/kern.log
- Mount it again and observe it correcting errors on mount:
mount /dev/xvdd /mnt/tmp
- Run a diff, observe kernel error messages and observe that diff reports no file differences:
diff -ru /usr /mnt/tmp/usr/
- Run another scrub, this will probably correct some errors which weren't discovered by diff:
btrfs scrub start -B -d /mnt/tmp
- Offline corruption
- Umount the filesystem, corrupt the start, then try mounting it again:
umount /mnt/tmp
dd if=/dev/zero of=/dev/xvdd bs=1024k count=200
mount /dev/xvdd /mnt/tmp
mount /dev/xvde /mnt/tmp
- Note that the filesystem was not mountable due to a lack of a superblock. There are ways of recovering from this but that's more advanced so we will restore the RAID.
Mount the filesystem in a degraded RAID mode, this allows full operation.
mount /dev/xvde /mnt/tmp -o degraded
- Add /dev/xvdd back to the RAID:
btrfs device add /dev/xvdd /mnt/tmp
- Show the filesystem devices, observe that xvdd is listed twice, the missing device and the one that was just added:
btrfs filesystem show /mnt/tmp
- Remove the missing device and observe the change:
btrfs device delete missing /mnt/tmp
btrfs filesystem show /mnt/tmp
- Balance the filesystem, not sure this is necessary:
btrfs balance start /mnt/tmp
- Umount and mount it, note that the degraded option is not needed:
umount /mnt/tmp
mount /dev/xvdd /mnt/tmp
- Experiment
- Experiment with the "btrfs subvolume create" and "btrfs subvolume delete" commands (which act like mkdir and rmdir).
- Experiment with "btrfs subvolume snapshot SOURCE DEST" and "btrfs subvolume snapshot -r SOURCE DEST" for creating regular and read-only snapshots of other subvolumes (including the root).
ZFS
- Installing zfsonlinux
- Add the following to /etc/apt/sources.list:
deb http://archive.zfsonlinux.org/debian jessie main
- Run the following commands:
apt-get update
apt-get install debian-zfs
This takes ages
- Making the filesystem
- Create the pool:
zpool create -o ashift=12 nyancat raidz /dev/xvdd /dev/xvde /dev/xvdf
NB You need to add a "-f" to overwrite the BTRFS filesystem
- Make some default filesystem settings:
zfs set devices=off nyancat
zfs set atime=off nyancat
zfs set setuid=off nyancat
zfs set compression=on nyancat
- Get information on the pool:
zfs get all nyancat|less
zpool list
zpool status
- Make a filesystem:
zfs create nyancat/friday
df -h -
- See if there are any errors, shouldn't be any (yet):
zpool scrub nyancat
zpool status
- Copy some files to the filesystem:
cp -r /usr /nyancat/friday
- Scrub the filesystem:
zpool scrub nyancat
zpool status
Online corruption
- Corrupt the filesystem:
dd if=/dev/zero of=/dev/xvdd bs=1024k count=2000 seek=50
- Scrub again, should give a warning about errors:
zpool scrub nyancat
zpool status
- Verify that the data is intact:
diff -ru /usr /nyancat/friday/usr
- Corrupt it again: