Ceci est une ancienne révision du document !
Pour créer un sous volume
btrfs subvolume create NOM_DU_SOUS-VOLUME
Pour faire un snapshot du sous volume
btrfs subvolume snapshot NOM_DU_SOUS-VOLUME NOM_SNAPSHOT
Pour afficher la liste des sous volume
btrfs subvolume list /chemin/du/montage
Pour affiche des infos sur un sous volumes ou un snaphot
btrfs subvolume show /chemin/du/sous-volume
Un snapshot est aussi un sous volume, on peut très bien supprimer son parent sans poser de problème
Faire un checkdisk sans modif
btrfsck /dev/sda1
Faire un checkdisk avec option de réparation
btrfs check --repair /dev/sda1
Vérifier le checksum des blocksd
btrfs scrub start /dev/sda1
Vous pouvez voir l’avancement avec la commande suivante
btrfs scrub status /dev/sda1
Pour arrêter le scrub
btrfs scrub cancel /dev/sda1
Hugo Mills on the btrfs mailing list wrote:
Let’s assume that you don’t have a physical device failure (which
is a different set of tools – mount -odegraded, btrfs dev del
missing).
First thing to do is to take a btrfs-image -c9 -t4 of the
filesystem, and keep a copy of the output to show josef. smile
Then start with -orecovery and -oro,recovery for pretty much
anything.
If those fail, then look in dmesg for errors relating to the log
tree – if that’s corrupt and can’t be read (or causes a crash), use
btrfs-zero-log.
If there’s problems with the chunk tree – the only one I’ve seen
recently was reporting something like “can’t map address” – then
chunk-recover may be of use.
After that, btrfsck is probably the next thing to try. If options
-s1, -s2, -s3 have any success, then btrfs-select-super will help by
replacing the superblock with one that works. If that’s not going to
be useful, fall back to btrfsck –repair.
Finally, btrfsck –repair –init-extent-tree may be necessary if
there’s a damaged extent tree. Finally, if you’ve got corruption in
the checksums, there’s –init-csum-tree.
Hugo.
Dans le cas d’une conversion d’une partition racine, il faudra booter sur un live système.
1ère vérification, repérer le disque, son UUID, sa config fstab
Avec mount
mount /dev/sda2 on / type ext4 (rw,noatime,errors=remount-ro,data=ordered)
L’UUID
blkid /dev/sda2 /dev/sda2: UUID="3b3f3e41-c1cf-437f-a90f-80aeda99110d" TYPE="ext4" PARTUUID="8d9a85bd-2d6f-4412-b375-2bcb33859c26"
On doit le retrouver dans le /etc/fstab
vi /etc/fstab # <file system> <mount point> <type> <options> <dump> <pass> # / was on /dev/sda2 during installation UUID=3b3f3e41-c1cf-437f-a90f-80aeda99110d / ext4 noatime,errors=remount-ro 0 1
Lancer la conversion
btrfs-convert /dev/sda2
Monter le disque pour vérifier que tout s’est bien passé
mount /dev/sda2 /mnt/mon_disque
Si vous constatez des problèmes
umount /mnt/mon_disque btrfs-convert -r /dev/sda2
Si tout vous semble ok, supprimez la possibilité de revenir en ext4 afin de ne pas alourdir le système et gagner en performance
rm -fr /mnt/mon_disque/ext2_saved btrfs subvolume delete /ext2_saved btrfs balance start /mnt/mon_disque
Maintenant, il va falloir mettre à jour votre fstab sinon votre système ne redémarrera pas.
Options de montage
OPTION DE MONTAGE PROPRES À BTRFS | RÔLE |
autodefrag | Autorise la défragmentation en arrière plan |
compress=zlib | La compression la plus importante. Par défaut |
compress=lzo | La compression la plus rapide |
compress=no | Pas de compression |
degraded | Utilisé dans le cas des RAID. Permet de monter le volume même si certains disques sont manquants |
discard | Utilise le TRIM pour les disques SSD |
recovery | Lance la réparation automatique après le montage. A utilise si le volume ne veut plus se monter. un fois monté réaliser un scrub pour réparer les erreurs. (Ne fonctionne qu’avec les volumes crées avec la version 3.2 ou +) |
ssd | Utilise l’optimisation pour disques SSD de Btrfs. C’est utilisé par défaut si votre système reconnaît le SSD. Cette option ne lance pas le TRIM ! |
subvol=/chemin/vers/subvolume | Permet de monter un subvolume |
subvolid=id | Permet de monter un subvolume par son id. La racine a un id=0 |
Pour un ssd par exemple
mount /dev/sda2 -o rw,noatime,ssd,discard,autodefrag,compress=lzo,space_cache,inode_cache /mnt/mon_disque
Pour hdd
mount /dev/sda2 -o rw,noatime,compress=lzo,autodefrag
Dans un fichier fstab, refaite la commande blkid et mettez à jour votre fstab
UUID=a69d9182-f4c7-4276-b35d-7d5f9bd50a57 / btrfs rw,noatime,ssd,discard,autodefrag,compress=lzo 0 0
Mettre à jour grub
mount /dev/sda2 /mnt mount /dev/sda1 /mnt/boot/efi for fs in proc sys dev dev/pts; do mount --bind /$fs /mnt/$fs; done chroot /mnt update-initramfs -u -k all update-grub
La suite peut aider mais pas nécessaire normalement.
With Grub Legacy we need to modify root=UUID value in menu.lst file to btrfs partition’s manually. I used the following lines for Grub’s menu.lst file.
title Linux 2.6.32.67 uuid 89591593-766e-4565-9d5c-017fb0e33298 kernel /vmlinuz-2.6.32.67 root=UUID=a90c79b1-5883-44cc-9e74-752db9ca764d ro initrd /initrd.img-2.6.32.67
In this example, a90c79b1-5883-44cc-9e74-752db9ca764d is the UUID of btrfs partition and 89591593-766e-4565-9d5c-017fb0e33298 is UUID of /boot partition.
Also, I used following lines for my /etc/fstab file.
/dev/sda3 /boot ext4 defaults 0 0 /dev/sda1 / btrfs defaults 0 1
As you can see, I just wrote a path (/dev/sda1) instead of UUID as described in the referenced site.
Update initrd images Because some scripts and hooking are added to initramfs, initrd images in /boot directory should be updated.
I could not update them with command (i.e. update-initramfs -u -k all) described in the referenced site. It was guessed due to the kernel version difference between Live USB and my original installation. I designated the kernel version as a parameter like below and it worked.
update-initramfs -u -k 2.6.32.67
Si votre grub est coincé au redémarrage
grub>ls #pour lister les partition set root=(hd0,gpt2) # faite TAB en cours de frappe montre pas mal d'info sur la partition à choisir) linux /vmlinuz root=/dev/sda2 ro initrd /initrd.img boot
ensuite, pour réparer grub
update-grub