meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
linux:fs:btrfs_as_root [2016/04/20 10:58]
niziak
linux:fs:btrfs_as_root [2017/01/18 21:41] (current)
niziak
Line 17: Line 17:
  
  
-===== Conversion ​=====+===== Update to kernel 4 ===== 
 +Edit /​etc/​apt/​sources and add sid release
 <code bash> <code bash>
-fsck -f /dev/sda1 +apt-get update 
-fsck -f /dev/sda6 +apt-get install linux-image-amd64 
- +apt-get install ​btrfs-tools 
-btrfs-convert /dev/sda1+update-initramfs -u
 </​code>​ </​code>​
  
-  ​Disk usage before conversionused 1.56GBfree 2.53GB +  ​* ERRORWarning: /sbin/fsck.btrfs doesn'​t existcan't install to initramfs, ignoring
-  ​after conversionused 1.65GB, free 2.43GB+  ​* EXPLANATION"This is going to be changed back in the next version of btrfs-tools.
 +  * SOLUTION: ln -s /​bin/​fsck.btrfs /sbin/fsck.btrfs
  
-<code bash>btrfs check /dev/sda1</​code>​+Check btrfs-tools version 
 +<code bash>/bin/btrfs version</​code>​
  
-===== Update system ===== 
-Mount new root filesystem: 
  
-<code bash> +===== Converting dirs into subvolumes ​ ===== 
-mount /dev/sda1 /mnt +To make backups, snapshots, moving much easier and faster, every directory you want to backup by snapshot should be a subvolume. Also root filesystem should be created ​in separate subvolume not in btrfs root.
-for i in dev dev/pts proc sys ; do mount --bind /$i /mnt/$i ; done +
-chroot /mnt +
-</​code>​+
  
-get new UUID of /dev/sda1 using "​blkid"​ +To distinguish volumes from directories we will use @ character at beginning ​of subvolume name. This is Ubuntu naming convention for subvolumes.
-mount /dev/sda1 somewhere, go to etc/fstab and update to new UUID:+
  
-  UUID=a74f5787-aee1-4981-b7e6-fbd3cb6ac919 ​              btrfs    defaults 0       1+Proposed subvolumes structure (where ​is BTRFS root) 
 +  * /@ 
 +  * /@home 
 +  * /@var
  
-<code bash> +Mount BTRFS filesystem (BTRFS root) to /mnt/btrfs.
-update-grub +
-grub-install ​/dev/sda+
  
-exit+==== root ==== 
 +  * take a snapshot of root volume. Name of snapshot is '​@'​ 
 +    * ''​btrfs subvolume snapshot /mnt/btrfs @''​ 
 +  * delete files on BTRFS root (/​mnt/​btrfs) 
 +  * make @ subvolume a default root 
 +      * update fstab:<​file | /​etc/​fstab>​UUID=739e6086-d925-4bdb-94f5-26d8c10dc171 /​ btrfs defaults,​subvol=@</​file>​ 
 +    * OR  
 +      * get @ subvolume id ''​btrfs subvolume list /​mnt/​btrfs''​ 
 +      * set default subvolume to use when system is mounted ''​btrfs subvolume set-default 256 /​mnt/​btrfs''​
  
-reboot 
-</​code>​ 
  
-and remove ​Live CD with Gparted+==== subdirectories ==== 
 +  * On BTRFS root create a new subvolume 
 +    * ''​btrfs subvolume create /​mnt/​btrfs/​@home''​ 
 +  * move files into the new subvolume as if it were a directory 
 +    * ''​mv /​mnt/​btrs/​@/​home/​* /​mnt/​btrfs/​@home/''​ 
 +    * ''​cp --reflink''​ is much faster on BTRFS 
 +  * remove ​old directory 
 +    * ''​rmdir /​mnt/​btrfs/​@/​home''​ 
 +  * update /etc/fstab to mount @home as /home
  
-==== rollback to ext FS ==== +===== fstab ==== 
-Rollback to ext2 is possible. There is subvolume ext2_saved on filesystem+Do not use ''​errors=remount-ro''​ option which is not valid for BTRFS. 
-<code bash>​btrfs subvolume list /</code+Example working fstab file: 
-To delete backup +<file | /etc/fstab
-<code bash>btrfs subvolume delete ​/ext2_saved</code>+UUID=ed730508-753e-4a7f-ac1e-bf8646f7bd63 /​ btrfs defaults,​subvol=@,​compress=no 0 0 
 +UUID=ed730508-753e-4a7f-ac1e-bf8646f7bd63 /​var btrfs defaults,​subvol=@var,​compress=no 0 0 
 +UUID=ed730508-753e-4a7f-ac1e-bf8646f7bd63 /var/​log btrfs defaults,​subvol=@varlog,​compress=no 0 0 
 +UUID=ed730508-753e-4a7f-ac1e-bf8646f7bd63 /​home btrfs defaults,​subvol=@home,​compress=no 0 0 
 +UUID=ed730508-753e-4a7f-ac1e-bf8646f7bd63 /​mnt/​btrfs btrfs noauto,​defaults,​subvolid=5,​compress=no 0 0 
 +</file>
  
 +To prevent systemd to halt system during startup if device is not found (nofail and x-systemd.device-timeout):​
 +<file | /​etc/​fstab>​
 +UUID=<​the_device_uuid>​ /​mount/​point btrfs nofail,​x-systemd.device-timeout=10,​noatime,​compress=lzo,​autodefrag 0 0
 +</​file>​
 +NOTE: do not use autodefrag - it consumes lots of cpu