Seed-device

From btrfs Wiki
(Difference between revisions)
Jump to: navigation, search
m
Line 1: Line 1:
# dd if=/dev/zero of=/mnt/gentoo/btrfs-test-1 count=2 bs=1G
+
=== Seed-device use example ===
# dd if=/dev/zero of=/mnt/gentoo/btrfs-test-2 count=2 bs=1G
+
The original filesystem and devices are included as a readonly starting point to the new FS. All modifications go onto different devices and the COW machinery makes sure the original is unchanged.
  
# losetup /dev/loop0 /mnt/gentoo/btrfs-test-1
+
# dd if=/dev/zero of=/mnt/gentoo/btrfs-test-1 count=2 bs=1G
# losetup /dev/loop1 /mnt/gentoo/btrfs-test-2
+
# dd if=/dev/zero of=/mnt/gentoo/btrfs-test-2 count=2 bs=1G
  
# mkfs.btrfs /dev/loop0
+
# losetup /dev/loop0 /mnt/gentoo/btrfs-test-1
 +
# losetup /dev/loop1 /mnt/gentoo/btrfs-test-2
  
# mount /dev/loop0 /mnt/test/
+
# mkfs.btrfs /dev/loop0
# echo a > /mnt/test/a
+
# echo b > /mnt/test/b
+
  
# umount /mnt/test
+
# mount /dev/loop0 /mnt/test/
# btrfstune -S 1 /dev/loop0
+
# echo a > /mnt/test/a
 +
# echo b > /mnt/test/b
  
# mount /dev/loop0 /mnt/test
+
# umount /mnt/test
mount: block device /dev/loop0 is write-protected, mounting read-only
+
# btrfstune -S 1 /dev/loop0
# btrfs device add /dev/loop1 /mnt/test
+
# ls /mnt/test
+
a  b
+
# echo c > /mnt/test/c
+
bash: c: Read-only file system
+
  
# mount -o remount,rw /mnt/test
+
# mount /dev/loop0 /mnt/test
OR
+
mount: block device /dev/loop0 is write-protected, mounting read-only
# umount /mnt/test
+
# btrfs device add /dev/loop1 /mnt/test
# mount /dev/loop1 /mnt/test
+
# ls /mnt/test
 +
a  b
 +
# echo c > /mnt/test/c
 +
bash: c: Read-only file system
  
# echo c > /mnt/test/c
+
# mount -o remount,rw /mnt/test
# echo d > /mnt/test/d
+
OR
# umount /mnt/test
+
# umount /mnt/test
 +
# mount /dev/loop1 /mnt/test
  
# mount /dev/loop0 /mnt/test
+
# echo c > /mnt/test/c
mount: block device /dev/loop0 is write-protected, mounting read-only
+
# echo d > /mnt/test/d
# ls /mnt/test
+
# umount /mnt/test
a  b
+
 
# umount /mnt/test
+
# mount /dev/loop0 /mnt/test
# mount /dev/loop1 /mnt/test
+
mount: block device /dev/loop0 is write-protected, mounting read-only
# ls /mnt/test
+
# ls /mnt/test
a  b  c  d
+
a  b
# cat /mnt/test/c
+
# umount /mnt/test
c
+
# mount /dev/loop1 /mnt/test
 +
# ls /mnt/test
 +
a  b  c  d
 +
# cat /mnt/test/c
 +
c

Revision as of 20:46, 14 May 2012

Seed-device use example

The original filesystem and devices are included as a readonly starting point to the new FS. All modifications go onto different devices and the COW machinery makes sure the original is unchanged.

# dd if=/dev/zero of=/mnt/gentoo/btrfs-test-1 count=2 bs=1G
# dd if=/dev/zero of=/mnt/gentoo/btrfs-test-2 count=2 bs=1G
# losetup /dev/loop0 /mnt/gentoo/btrfs-test-1
# losetup /dev/loop1 /mnt/gentoo/btrfs-test-2
# mkfs.btrfs /dev/loop0
# mount /dev/loop0 /mnt/test/
# echo a > /mnt/test/a
# echo b > /mnt/test/b
# umount /mnt/test
# btrfstune -S 1 /dev/loop0
# mount /dev/loop0 /mnt/test
mount: block device /dev/loop0 is write-protected, mounting read-only
# btrfs device add /dev/loop1 /mnt/test
# ls /mnt/test
a  b
# echo c > /mnt/test/c
bash: c: Read-only file system
# mount -o remount,rw /mnt/test
OR
# umount /mnt/test
# mount /dev/loop1 /mnt/test
# echo c > /mnt/test/c
# echo d > /mnt/test/d
# umount /mnt/test
# mount /dev/loop0 /mnt/test
mount: block device /dev/loop0 is write-protected, mounting read-only
# ls /mnt/test
a  b
# umount /mnt/test
# mount /dev/loop1 /mnt/test
# ls /mnt/test
a  b  c  d
# cat /mnt/test/c
c
Personal tools