atconsultancy logo
cowloop logo
atcomputing logo

spacerHome

spacerNews

spacerDownload

spacerFAQ

 

SourceForge.net Logo

Tux

Example 1: filesystem on write-protected floppy

Obviously, you may read "USB stick" instead of "floppy" here....

Mount a filesystem on a write-protected floppy read-only to see the list of files:

  # mount -r /dev/fd0 /mnt/floppy
  # ls -l /mnt/floppy
  -rw-r--r--  1 root   root     44 Jun 30 13:14 adjtime
  -rw-r--r--  1 root   root   1343 Jun 30 13:14 aliases
  -rw-r-----  1 root   root  12288 Jun 30 13:14 aliases.db
  -rw-------  1 root   root      1 Jun 30 13:14 at.deny
  -rw-r--r--  1 root   root    872 Jun 30 13:14 atsar.conf
  -rw-r--r--  1 root   root    212 Jun 30 13:14 auto.master
  # umount /dev/fd0
The same filesystem can be mounted read-write via the cowloop driver (already loaded via the command modprobe), specifying the name of a new cowfile:
  # cowdev -a /dev/fd0 /tmp/ses1.cow
  /dev/cow/0
  # mount /dev/cow/0 /mnt/floppy
  # ls -l /mnt/floppy
  -rw-r--r--  1 root   root     44 Jun 30 13:14 adjtime
  -rw-r--r--  1 root   root   1343 Jun 30 13:14 aliases
  -rw-r-----  1 root   root  12288 Jun 30 13:14 aliases.db
  -rw-------  1 root   root      1 Jun 30 13:14 at.deny
  -rw-r--r--  1 root   root    872 Jun 30 13:14 atsar.conf
  -rw-r--r--  1 root   root    212 Jun 30 13:14 auto.master
After entering the command mount the situation is as shown in this figure:

cowfloppy schematics

Files can be modified and removed now:
  # vi /mnt/floppy/adjtime
  # ls -l /mnt/floppy/adjtime
  -rw-r--r--  1 root   root     47 Jun 30 13:24 /mnt/floppy/adjtime
  # rm /mnt/floppy/aliases
  # umount /dev/cow/0
  # cowdev -d /dev/cow/0
The contents of the floppy itself is unmodified. The modified blocks of the filesystem (superblock, inodes, bitmaps, data-blocks) are written to the cowfile.
Apparently the cowfile is almost half a Megabyte (according to command ls), but it only consumes 18 Kbytes of physical disk space (according to command du):
  # ls -l /tmp/ses1.cow
  -rw-------  1 root   root 475584 Jun 30 13:25 /tmp/ses1.cow
  # du -k /tmp/ses1.cow 
  18      /tmp/ses1.cow
Later on the filesystem can be mounted read-write again via the cowloop driver, using the same cowfile:
  # cowdev -a /dev/fd0 /tmp/ses1.cow
  /dev/cow/3
  # mount /dev/cow/3 /mnt/floppy
  # ls -l /mnt/floppy
  -rw-r--r--  1 root   root     47 Jun 30 13:24 adjtime
  -rw-r-----  1 root   root  12288 Jun 30 13:14 aliases.db
  -rw-------  1 root   root      1 Jun 30 13:14 at.deny
  -rw-r--r--  1 root   root    872 Jun 30 13:14 atsar.conf
  -rw-r--r--  1 root   root    212 Jun 30 13:14 auto.master
When the cowfile /tmp/ses1.cow is removed before activating it again via the command "cowdev -a", the cowloop driver creates a new empty cowfile. In that case the original floppy-contents appears again after the mount.

spacerIntroduction

spacerOverview

spacerInstall

spacerLoad & unload

spacerCowfiles

spacerCommands

spacerStatus info

small @ logoExample 1

spacerExample 2

spacerExample 3

spacerCowloop vs.
   device mapper

spacerView as single page


© AT Consultancy bv, Nijmegen, The Netherlands  -  www.ATConsultancy.nl
© AT Computing bv, Nijmegen, The Netherlands  -  www.ATComputing.nl - www.ATComputing.net