<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://homeostasis.scs.carleton.ca/wiki/index.php?action=history&amp;feed=atom&amp;title=Operating_Systems_2019F%3A_Tutorial_5</id>
	<title>Operating Systems 2019F: Tutorial 5 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://homeostasis.scs.carleton.ca/wiki/index.php?action=history&amp;feed=atom&amp;title=Operating_Systems_2019F%3A_Tutorial_5"/>
	<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2019F:_Tutorial_5&amp;action=history"/>
	<updated>2026-06-02T20:21:23Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2019F:_Tutorial_5&amp;diff=22525&amp;oldid=prev</id>
		<title>Soma: Created page with &quot;In this tutorial you will be playing with filesystems (regular filesystems and sshfs).  Please use a VM and make backups, as some of these commands could erase all data on you...&quot;</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2019F:_Tutorial_5&amp;diff=22525&amp;oldid=prev"/>
		<updated>2019-10-23T15:41:33Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;In this tutorial you will be playing with filesystems (regular filesystems and sshfs).  Please use a VM and make backups, as some of these commands could erase all data on you...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;In this tutorial you will be playing with filesystems (regular filesystems and sshfs).  Please use a VM and make backups, as some of these commands could erase all data on your system.&lt;br /&gt;
&lt;br /&gt;
==Creating, Mounting, and Unmounting Filesystem==&lt;br /&gt;
&lt;br /&gt;
# Run &amp;lt;tt&amp;gt;ls -lai&amp;lt;/tt&amp;gt; (by itself or for a specific directory).  What are the numbers appearing in the left column?&lt;br /&gt;
# Run dd if=/dev/zero of=foo bs=8192 count=32K   What is the logical size of the file?  How much space does it consume on disk? (Hint: Look at the size option to ls.)&lt;br /&gt;
# Run &amp;lt;tt&amp;gt;mkfs.ext4 foo&amp;lt;/tt&amp;gt;.  (If asked, say &amp;quot;yes&amp;quot; to operating on a regular file.)  Does foo consume any more space?&lt;br /&gt;
# Run &amp;lt;tt&amp;gt;dumpe2fs foo&amp;lt;/tt&amp;gt;.  What does the output of this command mean?&lt;br /&gt;
# What command do you run to check the filesystem in foo for errors?&lt;br /&gt;
# Run &amp;lt;tt&amp;gt;sudo mount foo /mnt&amp;lt;/tt&amp;gt;.  How does this command change what files are accessible?&lt;br /&gt;
# Run &amp;lt;tt&amp;gt;df&amp;lt;/tt&amp;gt;.  What device is mounted on /mnt?  What is this device?&lt;br /&gt;
# Run &amp;lt;tt&amp;gt;chown student:student /mnt&amp;lt;/tt&amp;gt;.  (If you are on your own Linux system, substitute your current user for student.)&lt;br /&gt;
# Run &amp;lt;tt&amp;gt;rsync -a -v /etc /mnt&amp;lt;/tt&amp;gt;.  What does this command do?  Explain the arguments as well.  Did you get errors copying any files?&lt;br /&gt;
# Run &amp;lt;tt&amp;gt;sudo umount /mnt&amp;lt;/tt&amp;gt;.  What files can you still access, and what have gone away?&lt;br /&gt;
# Run &amp;lt;tt&amp;gt;dd if=/dev/zero of=foo conv=notrunc count=10 bs=512&amp;lt;/tt&amp;gt;.  How does the &amp;quot;conv=notrunc&amp;quot; change dd&amp;#039;s behavior (versus the command in question 1)?&lt;br /&gt;
# Run &amp;lt;tt&amp;gt;sudo mount foo /mnt&amp;lt;/tt&amp;gt;.  What error do you get?&lt;br /&gt;
# What command can you run to make foo mountable again?  What characteristic of the file system enables this command to work?&lt;br /&gt;
# Run the command &amp;lt;tt&amp;gt;truncate -s 1G bar&amp;lt;/tt&amp;gt;.  What is the logical size of bar, and how much space does it consume on disk?  How does this compare with foo?&lt;br /&gt;
# How does the logical size of bar change when you create an ext4 filesystem in it?  What about the space consumed on disk?&lt;br /&gt;
&lt;br /&gt;
==SSH &amp;amp; SSHFS==&lt;br /&gt;
&lt;br /&gt;
Here you will be learning about [http://www.openssh.org ssh (openssh)] and [https://github.com/libfuse/sshfs sshfs], a network filesystem built on [https://github.com/libfuse/libfuse FUSE].&lt;br /&gt;
&lt;br /&gt;
===Setup===&lt;br /&gt;
&lt;br /&gt;
Install the openssh-server and sshfs packages:&lt;br /&gt;
&lt;br /&gt;
 sudo apt-get install openssh-server sshfs&lt;br /&gt;
&lt;br /&gt;
Create a second user in the virtual machine named &amp;quot;other&amp;quot; (or any other name you wish to use):&lt;br /&gt;
&lt;br /&gt;
 sudo adduser other&lt;br /&gt;
&lt;br /&gt;
(Answer the subsequent prompts however you wish, just remember the password.)&lt;br /&gt;
&lt;br /&gt;
At this point you should be able to log in to the &amp;quot;other&amp;quot; account using ssh:&lt;br /&gt;
&lt;br /&gt;
 ssh other@localhost&lt;br /&gt;
&lt;br /&gt;
You&amp;#039;ll have to enter your password.&lt;br /&gt;
&lt;br /&gt;
If you don&amp;#039;t get a password prompt, password authentication has probably been disabled.  (Password authentication has been disabled on the openstack VMs.)  To enable it, do the following&lt;br /&gt;
&lt;br /&gt;
  sudo nano /etc/ssh/sshd_config    (or vi, or emacs)&lt;br /&gt;
&lt;br /&gt;
In the editor change the line &amp;quot;PasswordAuthentication no&amp;quot; to &amp;quot;PasswordAuthentication yes&amp;quot;.  Then, to restart sshd:&lt;br /&gt;
&lt;br /&gt;
  sudo service sshd restart&lt;br /&gt;
&lt;br /&gt;
Be sure to change it back after you&amp;#039;ve set up public key authentication!&lt;br /&gt;
&lt;br /&gt;
===Remote filesystems using sshfs===&lt;br /&gt;
&lt;br /&gt;
To mount the other user&amp;#039;s files in a directory called &amp;quot;otherfiles&amp;quot;, do the following (as user student, ubuntu, or  your personal account):&lt;br /&gt;
&lt;br /&gt;
 mkdir otherfiles&lt;br /&gt;
 sshfs other@localhost: otherfiles&lt;br /&gt;
&lt;br /&gt;
To unmount the filesystem:&lt;br /&gt;
&lt;br /&gt;
 fusermount -u otherfiles&lt;br /&gt;
&lt;br /&gt;
===Public key authentication and ssh===&lt;br /&gt;
&lt;br /&gt;
Create a public key file for your account (as user student, ubuntu, or your personal account):&lt;br /&gt;
&lt;br /&gt;
 ssh-keygen&lt;br /&gt;
&lt;br /&gt;
(Accept the default filename and choose at least a simple passphrase.)&lt;br /&gt;
&lt;br /&gt;
You just created a certificate!  (A certificate is just a public key with metadata.)&lt;br /&gt;
&lt;br /&gt;
Copy the key to the other account:&lt;br /&gt;
&lt;br /&gt;
 cat ~/.ssh/id_rsa.pub &amp;gt;&amp;gt; authorized_keys&lt;br /&gt;
 scp authorized_keys other@localhost:.&lt;br /&gt;
 rm authorized_keys&lt;br /&gt;
 ssh other@localhost&lt;br /&gt;
&lt;br /&gt;
 (as user other)&lt;br /&gt;
 mkdir ~/.ssh (if it doesn&amp;#039;t exist already)&lt;br /&gt;
 chmod 700 ~/.ssh  (make it private)&lt;br /&gt;
 mv ~/authorized_keys ~/.ssh&lt;br /&gt;
 chmod 600 ~/.ssh/authorized_keys&lt;br /&gt;
&lt;br /&gt;
Now you can log in to user other by typing in the passphrase you used to lock the key you generated.&lt;br /&gt;
&lt;br /&gt;
To avoid entering this passphrase every time, you can give it to the authentication agent (generally, ssh-agent) that was started when you logged in:&lt;br /&gt;
&lt;br /&gt;
  ssh-add&lt;br /&gt;
&lt;br /&gt;
Note I expect the above to be a bit confusing.  Do look around for resources on public key cryptography; however, you may find that playing around with ssh authentication may help you understand things better.  In particular, try using &amp;quot;-v&amp;quot; (verbose) with ssh.&lt;br /&gt;
&lt;br /&gt;
===Tasks===&lt;br /&gt;
&lt;br /&gt;
# Look at the hard link counts of files locally and compare those to the link counts over sshfs.  How do they compare?&lt;br /&gt;
# Try running some of the sudo&amp;#039;d commands above (e.g, &amp;quot;sudo mount foo /mnt&amp;quot;) without the sudo.  Why do they fail?  Try running them under strace and see how their system calls change.  Do they figure out that they aren&amp;#039;t running as root and abort, or do they try doing a privileged operation and it fails?&lt;br /&gt;
# Can you access sshfs mounted files as root?  (You can become root by typing &amp;quot;sudo su -&amp;quot;.)  What happens?&lt;br /&gt;
# Look at inode numbers in local and remote filesystems (as reported by ls -i).  How do they compare?&lt;br /&gt;
# dd a large file to a local drive.  Do same thing over sshfs.  Which is faster? (What is a large file in this context?)&lt;br /&gt;
# Can you sshfs to the SCS systems (e.g., access.scs.carleton.ca)?&lt;br /&gt;
# Setup password-less login to the SCS system (and then undo it).&lt;br /&gt;
# How can you use the mount command to unmount a sshfs-mounted filesystem (rather than fusermount)?&lt;/div&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
</feed>