The New Filesystem for : Features and Tools Lab

Novell Training Services www.novell.com SUS18 ATT LIVE 2012 LAS VEGAS

Novell, Inc. Copyright 2012-ATT LIVE-1-HARDCOPY PERMITTED. NO OTHER PRINTING, COPYING, OR DISTRIBUTION ALLOWED. Legal Notices

Novell, Inc., makes no representations or warranties with respect to the contents or use of this documentation, and specifically disclaims any express or implied warranties of merchantability or fitness for any particular purpose. Further, Novell, Inc., reserves the right to revise this publication and to make changes to its content, at any time, without obligation to notify any person or entity of such revisions or changes. Further, Novell, Inc., makes no representations or warranties with respect to any software, and specifically disclaims any express or implied warranties of merchantability or fitness for any particular purpose. Further, Novell, Inc., reserves the right to make changes to any and all parts of Novell software, at any time, without any obligation to notify any person or entity of such changes. Any products or technical information provided under this Agreement may be subject to U.S. export controls and the trade laws of other countries. You agree to comply with all export control regulations and to obtain any required licenses or classification to export, re-export or import deliverables. You agree not to export or re-export to entities on the current U.S. export exclusion lists or to any embargoed or terrorist countries as specified in the U.S. export laws. You agree to not use deliverables for prohibited nuclear, missile, or chemical biological weaponry end uses. See the Novell International Trade Services Web page (http://www.novell.com/info/exports/) for more information on exporting Novell software. Novell assumes no responsibility for your failure to obtain any necessary export approvals. Copyright © 2009 Novell, Inc. All rights reserved. No part of this publication may be reproduced, photocopied, stored on a retrieval system, or transmitted without the express written consent of the publisher. Novell, Inc., has intellectual property rights relating to technology embodied in the product that is described in this document. In particular, and without limitation, these intellectual property rights may include one or more of the U.S. patents listed on the Novell Legal Patents Web page (http://www.novell.com/company/legal/patents/) and one or more additional patents or pending patent applications in the U.S. and in other countries.

Novell, Inc. 404 Wyman Street, Suite 500 Waltham, MA 02451 U.S.A. www.novell.com

Online Documentation: To access the latest online documentation for this and other Novell products, see the Novell Documentation Web page (http:// www.novell.com/documentation).

Novell Trademarks

For Novell trademarks, see the Novell Trademark and Service Mark list (http://www.novell.com/company/legal/trademarks/tmlist.html).

Third-Party Materials

All third-party trademarks are the property of their respective owners.

2 Copying all or part of this manual, or distributing such copies, is strictly prohibited. Version 1 To report suspected copying, please call 1-800-PIRATES.

Novell, Inc. Copyright 2012-ATT LIVE-1-HARDCOPY PERMITTED. NO OTHER PRINTING, COPYING, OR DISTRIBUTION ALLOWED. Contents

Section 1 The Btrfs Filesystem...... 5 Exercise 1.1 LAB 5-1: Install and Configure Btrfs...... 6 Task I: Install the BtrFS RPM Package...... 6 Task II: Format an Empty Virtual Disk with BtrFS...... 7 Exercise 1.2 LAB 5-2: Create a New Btrfs Subvolume and a Snapshot Subvolume...... 9 Task I: Create a Subvolume...... 9 Task II: Snapshot the New Subvolume...... 9 Exercise 1.3 LAB 5-3: an Existing into a Subvolume...... 11 Task I: Convert a Directory into a Subvolume...... 11 Exercise 1.4 LAB 5-4: Perform an In-place Upgrade of an ext3 to Btrfs...... 12 Task I: Convert the File System...... 12 Task II: Test the Converted File System...... 12 Exercise 1.5 LAB 5-5: Configure Snapper to Manage a New Subvolume...... 14 Task I: Create a New Snapper Configuration File...... 14 Task II: Create a Snapper Snapshot of /home...... 14 Exercise 1.6 LAB 5-6: Use the Snapper YaST Module to Restore Files From a Snapshot...... 15 Task I: Restore a File From a Snapshot...... 15

Version 1 Copying all or part of this manual, or distributing such copies, is strictly 3 prohibited. To report suspected copying, please call 1-800-PIRATES

Novell, Inc. Copyright 2012-ATT LIVE-1-HARDCOPY PERMITTED. NO OTHER PRINTING, COPYING, OR DISTRIBUTION ALLOWED. The Btrfs Filesystem List of Figures

4 Copying all or part of this manual, or distributing such copies, is strictly prohibited. Version 1 To report suspected copying, please call 1-800-PIRATES

Novell, Inc. Copyright 2012-ATT LIVE-1-HARDCOPY PERMITTED. NO OTHER PRINTING, COPYING, OR DISTRIBUTION ALLOWED. The Btrfs Filesystem

Section 1 The Btrfs Filesystem

In this section you install, configure and work with Btrfs filesystem technologies and tools.

Version 1 Copying all or part of this manual, or distributing such copies, is strictly 5 prohibited. To report suspected copying, please call 1-800-PIRATES

Novell, Inc. Copyright 2012-ATT LIVE-1-HARDCOPY PERMITTED. NO OTHER PRINTING, COPYING, OR DISTRIBUTION ALLOWED. The Btrfs Filesystem

1.1 LAB 5-1: Install and Configure Btrfs In this exercise, you install btrfsprogs on your machine and format an empty virtual disk with BtrFS using YaST.

Objectives: Task I: Install the BtrFS RPM Package Task II: Format an Empty Virtual Disk with BtrFS

Task I: Install the BtrFS RPM Package In this task, you install the BtrFS RPM packages from a pre-connected zypper software source. NOTE: You may copy and paste complex commands from the electronic copy, if it is available on geeko's desktop. Ask the instructor to blast it out there if it's not already available. It only takes a second and he'd be happy to do it. 1. In VMware, if it is not already running, browse to the .vmx file of the btrfs_1 VM and start the VM. 2. Here is the : /vms/brandon/btrfs_1/btrfs_1.vmx The instructor may have already started the VM for your convenience. 3. Log into btrfs1 (hostname of the btrfs_1 VM) as the geeko user, password novell. 4. a terminal prompt by right-clicking on the Desktop and selecting Open in Terminal in the pop-up menu. 5. To get root permission, enter su – and password novell. The virtual cdrom for this VM has been configured to point to the /tmp/sles_11_2_vmw.iso file to use as a virtual CD. 6. At the open command prompt, enter the following command to add the cd as an installation software repository: zypper ar cd:///?devices=/dev/sr0 sles11sp2 If it throws an error about already being entered, just ignore it. 7. Start the installation of the btrfsprogs package: zypper in btrfsprogs 8. Notice the following packages required by btrfsprogs:

6 Copying all or part of this manual, or distributing such copies, is strictly prohibited. Version 1 To report suspected copying, please call 1-800-PIRATES

Novell, Inc. Copyright 2012-ATT LIVE-1-HARDCOPY PERMITTED. NO OTHER PRINTING, COPYING, OR DISTRIBUTION ALLOWED. The Btrfs Filesystem

btrfsprogs libsnapper snapper snapper zypp-plugin-python 9. Complete the installation. Software installation requires you to be logged in as the root user. 10. Use this terminal window for later the next task.

Task II: Format an Empty Virtual Disk with BtrFS In this task, you format an empty virtual disk with btrfs file system. 1. Bring up the terminal prompt from the previous task. 2. Launch yast : yast2 disk 3. In the warning dialog,, select Yes. 4. in the System View, expand the Hard Disks item 5. Select sdb in the System view and click Add to add a new partition. 6. Make sure Primary Partition is selected; then click Next. 7. To use the whole space that is available on the new hard disk for the new partition, select Maximum Size; then click Next. 8. Under Formatting Options, select BtrFS from the File System pull-down menu. 9. Activate Mount partition and enter /lab1 in the Mount Point text box; then click Finish. 10. In the Expert Partitioner dialog click Next. 11. In the Summary dialog click Finish. 12. Open the terminal window and enter mount as root to see whether the partition was created successfully. There should appear a line like the following in the output: /dev/sdb1 on /lab1 type btrfs (rw)

In this exercise, you installed the btrfsprogs and associated packages (using the zypper command) needed for btrfs support and formatted an empty (virtual) hard disk with btrfs file system. Now you should be able to do it start working with Btrfs.

Version 1 Copying all or part of this manual, or distributing such copies, is strictly 7 prohibited. To report suspected copying, please call 1-800-PIRATES

Novell, Inc. Copyright 2012-ATT LIVE-1-HARDCOPY PERMITTED. NO OTHER PRINTING, COPYING, OR DISTRIBUTION ALLOWED. The Btrfs Filesystem

(End of Exercise)

8 Copying all or part of this manual, or distributing such copies, is strictly prohibited. Version 1 To report suspected copying, please call 1-800-PIRATES

Novell, Inc. Copyright 2012-ATT LIVE-1-HARDCOPY PERMITTED. NO OTHER PRINTING, COPYING, OR DISTRIBUTION ALLOWED. The Btrfs Filesystem

1.2 LAB 5-2: Create a New Btrfs Subvolume and a Snapshot Subvolume In this exercise you create a new Btrfs subvolume and then create a snapshot of that subvolume.

Objectives: Task I: Create a Subvolume Task II: Snapshot the New Subvolume

Special Instructions and Notes: (none) Task I: Create a Subvolume 1. While logged in as the root user, open a terminal and enter the following command to view the existing Btrfs subvolumes mounted in /: btrfs subvolume list / You should s a list of subvolumes 2. Enter the following command to create a new subvolume mounted in /: btrfs subvolume create /data 3. Enter the following command to view the new subvolume: btrfs subvolume list / You should see the new subvolume listed with the other subvolumes

Task II: Snapshot the New Subvolume 1. Enter the following command to create a file in the new subvolume: echo “data file 1” > /data/file1 2. Enter the following command to create a snapshot of the new data : btrfs subvolume snapshot /data /data-snap 3. Enter the following command to view the new snapshot: btrfs subvolume list / You should see the new snapshot subvolume listed 4. Enter the following commands to view the contents of the original subvolume and its snapshot: ls -l /data

Version 1 Copying all or part of this manual, or distributing such copies, is strictly 9 prohibited. To report suspected copying, please call 1-800-PIRATES

Novell, Inc. Copyright 2012-ATT LIVE-1-HARDCOPY PERMITTED. NO OTHER PRINTING, COPYING, OR DISTRIBUTION ALLOWED. The Btrfs Filesystem

ls -l /data-snap The commands should list the same file(s) cat /data/file1 cat /data-snap/file1 The file contents should be the same as well 5. Enter the following commands to modify and view the files in the subvolumes: echo “modified” >> /data/file1 echo “this is new” > /data-snap/file2 cat /data/file1; cat /data-snap/file1 The file contents should be different ls -l /data/; ls -l /data-snap/ The directory contents should be different with the snapshot containing a new file

(End of Exercise)

10 Copying all or part of this manual, or distributing such copies, is strictly prohibited. Version 1 To report suspected copying, please call 1-800-PIRATES

Novell, Inc. Copyright 2012-ATT LIVE-1-HARDCOPY PERMITTED. NO OTHER PRINTING, COPYING, OR DISTRIBUTION ALLOWED. The Btrfs Filesystem

1.3 LAB 5-3: Convert an Existing Directory into a Subvolume In this exercise you convert an existing directory into a subvolume.

Objectives: Task I: Convert a Directory into a Subvolume

Special Instructions and Notes: (none) Task I: Convert a Directory into a Subvolume 1. As the root user, enter the following command to list the existing subvolumes in /: btrfs subvolume list / 2. Enter the following command to view the contents of the /etc directory: ls -l /etc 3. Enter the following command to convert an existing directory into a subvolume: mv /etc /etc-orig btrfs subvolume create /etc mv /etc-orig/* /etc/ rm -rf /etc-orig 4. Enter the following commands to view the changes: ls -l /etc btrfs subvolume list / You should see the same contents in the “/etc” subvolume as was in the original “/etc” directory. You should also see that /home is listed as a new subvolume.

(End of Exercise)

Version 1 Copying all or part of this manual, or distributing such copies, is strictly 11 prohibited. To report suspected copying, please call 1-800-PIRATES

Novell, Inc. Copyright 2012-ATT LIVE-1-HARDCOPY PERMITTED. NO OTHER PRINTING, COPYING, OR DISTRIBUTION ALLOWED. The Btrfs Filesystem

1.4 LAB 5-4: Perform an In-place Upgrade of an ext3 File System to Btrfs In this exercise you perform an in-place, off-line upgrade of an ext3 file system to a Btrfs file system without a /restore and without loosing data.

Objectives: Task I: Convert the File System Task II: Test the Converted File System

Special Instructions and Notes: (none) Task I: Convert the File System 1. While logged in as the root user, open a terminal and enter the following command to verify the ext3 file system is mounted: mount Look for the file system mounted on /stuff. It should be ext3 2. Enter the following command to copy some files into the ext3 file system mounted on /stuff/: cp -a /etc/* /stuff/ 3. Enter the following command to verify the copy: ls -l /stuff/ 4. Enter the following command to unmount the ext3 file system that is mounted on /stuff/ umount /stuff 5. Enter the following command to convert the ext3 file system to Btrfs: btrfs-convert /dev/sda5 6. In the text editor of your choice, open the /etc/ to be edited 7. Modify the /dev/sda5 line to match the following: /dev/sda5 /stuff btrfs defaults 1 2 8. Save the file and close the text editor

Task II: Test the Converted File System 1. Enter the following command to mount the converted file system:

12 Copying all or part of this manual, or distributing such copies, is strictly prohibited. Version 1 To report suspected copying, please call 1-800-PIRATES

Novell, Inc. Copyright 2012-ATT LIVE-1-HARDCOPY PERMITTED. NO OTHER PRINTING, COPYING, OR DISTRIBUTION ALLOWED. The Btrfs Filesystem

mount /stuff 2. Enter the following command to verify that it was mounted: mount You should see that the file system mounted on /stuff is now btrfs 3. Enter the following command to verify the data is still there: ls -l /stuff You should still see all of the file and directories that you copied 4. Enter the following command to view the subvolumes of the new Btrfs file system: btrfs subvolume list /stuff You should see a subvolume named ext2_saved. This is a subvolume that contains a file system image of the original ext3 file system 5. Enter the following command to mount the ext2_saved file system image: mkdir /ext2_saved mount -t btrfs -o subvol=ext2_saved /dev/sda5 /ext2_saved mount -t ext3 -o loop,ro /ext2_saved/image /mnt 6. Enter the following command to verify that it is mounted: mount You should see that the ext2_saved/image is mounted. 7. Enter the following command to view the files in the file system image: ls -l /mnt You should see all of the same files 8. Enter the following commands to unmount the file system image: umount /mnt umount /ext2_saved

(End of Exercise)

Version 1 Copying all or part of this manual, or distributing such copies, is strictly 13 prohibited. To report suspected copying, please call 1-800-PIRATES

Novell, Inc. Copyright 2012-ATT LIVE-1-HARDCOPY PERMITTED. NO OTHER PRINTING, COPYING, OR DISTRIBUTION ALLOWED. The Btrfs Filesystem

1.5 LAB 5-5: Configure Snapper to Manage a New Subvolume In this exercise you configure Snapper to manage snapshots for the /home subvolume. You then create and list the snapshot for the /home subvolume.

Objectives: Task I: Create a New Snapper Configuration File Task II: Create a Snapper Snapshot of /home

Special Instructions and Notes: A subvolume named /home must exist to perform this exercise Task I: Create a New Snapper Configuration File A task description goes here (not required) 1. While logged in as the root user, open a terminal and enter the following command to list the current snapper configurations: snapper list-configs 2. Enter the following command to create a new configuration template for /home: snapper -c etc create-config -f btrfs -t default /etc 3. Enter the following to list the new current configs: snapper list-configs You should see the new config listed

Task II: Create a Snapper Snapshot of /home 1. Enter the following command to create a snapshot of the /home subvolume: snapper -c etc create 2. Enter the following command to list the snapshots for /home: snapper -c etc list 3. Enter the following command to view the file in the /home snapshots: ls -l /etc/.snapshots/ You should see snapshot directories listed

(End of Exercise)

14 Copying all or part of this manual, or distributing such copies, is strictly prohibited. Version 1 To report suspected copying, please call 1-800-PIRATES

Novell, Inc. Copyright 2012-ATT LIVE-1-HARDCOPY PERMITTED. NO OTHER PRINTING, COPYING, OR DISTRIBUTION ALLOWED. The Btrfs Filesystem

1.6 LAB 5-6: Use the Snapper YaST Module to Restore Files From a Snapshot In this exercise you use the Snapper YaST module to restore a file from a previous snapshot.

Objectives: Task I: Restore a File From a Snapshot

Special Instructions and Notes: (none) Task I: Restore a File From a Snapshot 1. While logged inn as the root user, in the text editor of your choice, open the /etc/hosts file to be edited 2. Add the following line at the bottom of the file: 10.0.0.1 da1 3. Save the file and close the text editor 4. Launch the Snapper YaST Module: YaST > Miscellaneous > Snapper 5. Select the latest single snapshot in the list and click Show Changes 6. In the left frame, expand /etc and select the hosts file In the right frame, you should see the new line that was added 7. To restore the original /etc/hosts file, in the left pane, place a check mark in the hosts file and then click Restore Selected 8. When prompted to confirm the restore, click Yes 9. Click OK to dismiss the restore window 10. In a terminal enter the following command to view the /etc/hosts file: cat /etc/hosts You should see the line that you added is now gone 11. Close the Snapper YaST Module

(End of Exercise)

Version 1 Copying all or part of this manual, or distributing such copies, is strictly 15 prohibited. To report suspected copying, please call 1-800-PIRATES

Novell, Inc. Copyright 2012-ATT LIVE-1-HARDCOPY PERMITTED. NO OTHER PRINTING, COPYING, OR DISTRIBUTION ALLOWED. The Btrfs Filesystem

16 Copying all or part of this manual, or distributing such copies, is strictly prohibited. Version 1 To report suspected copying, please call 1-800-PIRATES

Novell, Inc. Copyright 2012-ATT LIVE-1-HARDCOPY PERMITTED. NO OTHER PRINTING, COPYING, OR DISTRIBUTION ALLOWED.