Announcement
Collapse
No announcement yet.
BTRFS usage- Adding devices, moving data, converting to RAID1, all without rebooting
Collapse
This topic is closed.
X
X
-
That makes more sense. I simply didn't understand how sudo command su would be valid under any circumstances!
- Top
- Bottom
-
From the btrfs wiki:
COMMAND SYNTAX
Any command name can be shortened as far as it stays unambiguous, however it is recommended to use full command names in scripts. All command groups have their manual page named btrfs-<group>.
For example: it is possible to run btrfs sub snaps instead of btrfs subvolume snapshot. But btrfs file s is not allowed, because file s may be interpreted both as filesystem show and as filesystem sync.
If the command name is ambiguous, the list of conflicting options is printed.
For an overview of a given command use btrfs command --help or btrfs [command…] --help --full to print all available options.
- Top
- Bottom
Leave a comment:
-
Originally posted by Snowhog View PostExpanded, this would be sudo btrfs su sn -r /subvol/@KDEneon /snapshot/@KDEneon3 My confusion is sudo btrfs su. Isn't the use of su redundant?
btrfs su sn
translates to:
btrfs subvolume snapshotLast edited by oshunluvr; Apr 09, 2017, 10:16 AM.
- Top
- Bottom
Leave a comment:
-
I have also added the alias "bt" to my bash_aliases file for "sudo btrfs"
The simplicity kicks in when I'm doing snapshots:
bt su sn -r /subvol/@KDEneon /snapshot/@KDEneon3Expanded, this would be sudo btrfs su sn -r /subvol/@KDEneon /snapshot/@KDEneon3 My confusion is sudo btrfs su. Isn't the use of su redundant?
- Top
- Bottom
Leave a comment:
-
Amazing! Even to the name of the backup (/backups) our approaches are essentially identical! I hope your mind is great, because we think alike! (Yours has to be, because mine is not)
- Top
- Bottom
Leave a comment:
-
After lots of playing around with BTRFS. I've decided the simplest approach is the best for me. My primary BTRFS file system is on two Samsung SSDs. On there reside my two current installs and homes and a subvolume named @snapshots. I've added the root volume to my fstab so the whole drive is mounted at /subvol and @snapshots is mounted at /snapshot. I then have a BTRFS file system for backups on a hard drive mounted at - strangely enough - /backup.
My simple method is to keep all snapshots on /snapshot. That way they're all easily visible and together. Since they're all on the same mount point I have to use unique names for them which prevents accidental confusion of what is what. So here's how those three mountpoints looks now:
Code:[FONT=monospace][COLOR=#54FF54][B] stuart@office[/B][/COLOR][COLOR=#000000]:[/COLOR][COLOR=#5454FF][B]/mnt/samsung[/B][/COLOR][COLOR=#000000]$ ll /subvol/[/COLOR] total 4 drwxr-xr-x 1 root root 262 Apr 6 13:44 [COLOR=#5454FF][B].[/B][/COLOR][COLOR=#000000]/[/COLOR] drwxr-xr-x 1 root root 124 Feb 27 14:40 [COLOR=#5454FF][B]..[/B][/COLOR][COLOR=#000000]/[/COLOR] drwxr-xr-x 1 root root 286 Apr 9 09:42 [COLOR=#5454FF][B]@KDEneon[/B][/COLOR][COLOR=#000000]/[/COLOR] drwxr-xr-x 1 root root 38 Apr 1 09:30 [COLOR=#5454FF][B]@KDEneon_home[/B][/COLOR][COLOR=#000000]/[/COLOR] drwxr-xr-x 1 root root 262 Dec 13 08:08 [COLOR=#5454FF][B]@Kubuntu_16_04[/B][/COLOR][COLOR=#000000]/[/COLOR] drwxr-xr-x 1 root root 32 Dec 22 17:05 [COLOR=#5454FF][B]@Kubuntu_16_04_home[/B][/COLOR][COLOR=#000000]/[/COLOR] drwxr-xr-x 1 root root 0 Apr 9 09:41 [COLOR=#5454FF][B]@snapshots[/B][/COLOR][COLOR=#000000]/[/COLOR] [COLOR=#54FF54][B]stuart@office[/B][/COLOR][COLOR=#000000]:[/COLOR][COLOR=#5454FF][B]/[/B][/COLOR][COLOR=#000000]$ ll /snapshot/[/COLOR] total 4 drwxr-xr-x 1 root root 0 Apr 9 09:41 [COLOR=#5454FF][B].[/B][/COLOR][COLOR=#000000]/[/COLOR] drwxr-xr-x 1 root root 286 Apr 9 09:42 [COLOR=#5454FF][B]..[/B][/COLOR][COLOR=#000000]/ [/COLOR][/FONT][FONT=monospace]drwxr-xr-x 1 root root 270 Apr 1 13:21 [/FONT][COLOR=#5454FF][FONT=monospace][B]@KDEneon1[/B][/FONT][/COLOR][COLOR=#000000][FONT=monospace]/[/FONT][/COLOR] [FONT=monospace]drwxr-xr-x 1 root root 270 Apr 1 13:21 [/FONT][COLOR=#5454FF][FONT=monospace][B]@KDEneon2[/B][/FONT][/COLOR][COLOR=#000000][FONT=monospace]/[/FONT][/COLOR][FONT=monospace][COLOR=#000000] [/COLOR][/FONT][FONT=monospace]drwxr-xr-x 1 root root 38 Apr 1 09:30 [/FONT][COLOR=#5454FF][FONT=monospace][B]@KDEneon_home1[/B][/FONT][/COLOR][COLOR=#000000][FONT=monospace]/[/FONT][/COLOR][FONT=monospace][COLOR=#000000] [/COLOR][/FONT][FONT=monospace]drwxr-xr-x 1 root root 262 Dec 13 08:08 [/FONT][COLOR=#5454FF][FONT=monospace][B]@Kubuntu_16_041[/B][/FONT][/COLOR][COLOR=#000000][FONT=monospace]/[/FONT][/COLOR][FONT=monospace][COLOR=#000000] [/COLOR][/FONT][FONT=monospace]drwxr-xr-x 1 root root 32 Dec 22 17:05 [/FONT][COLOR=#5454FF][FONT=monospace][B]@Kubuntu_16_04_home1[/B][/FONT][/COLOR][COLOR=#000000][FONT=monospace]/[/FONT][/COLOR][FONT=monospace] [COLOR=#54FF54][B]stuart@office[/B][/COLOR][COLOR=#000000]:[/COLOR][COLOR=#5454FF][B]/[/B][/COLOR][COLOR=#000000]$ ll /backup/[/COLOR] total 16 drwxrwsr-x 1 root backup 290 Apr 3 21:41 [COLOR=#5454FF][B].[/B][/COLOR][COLOR=#000000]/[/COLOR] drwxr-xr-x 1 root root 286 Apr 9 09:42 [COLOR=#5454FF][B]..[/B][/COLOR][COLOR=#000000]/[/COLOR] drwxr-xr-x 1 root root 270 Apr 3 21:49 [COLOR=#5454FF][B]@KDEneon1[/B][/COLOR][COLOR=#000000]/[/COLOR] drwxr-xr-x 1 root root 38 Apr 4 08:08 [COLOR=#5454FF][B]@KDEneon_home1[/B][/COLOR][COLOR=#000000]/[/COLOR] drwxr-xr-x 1 root root 48 Dec 11 07:49 [COLOR=#5454FF][B]@Kubuntu_14_04_home_ro[/B][/COLOR][COLOR=#000000]/[/COLOR] drwxr-xr-x 1 stuart stuart 86 Dec 11 09:06 [COLOR=#5454FF][B]@Kubuntu_15_04_home_ro[/B][/COLOR][COLOR=#000000]/[/COLOR] drwxr-xr-x 1 root root 262 Apr 4 09:53 [COLOR=#5454FF][B]@Kubuntu_16_041[/B][/COLOR][COLOR=#000000]/[/COLOR] drwxr-xr-x 1 root root 32 Apr 4 09:04 [COLOR=#5454FF][B]@Kubuntu_16_04_home1[/B][/COLOR][COLOR=#000000]/[/COLOR] drwxr-xr-x 1 stuart stuart 26 Dec 26 13:21 [COLOR=#5454FF][B]@other_backups[/B][/COLOR][COLOR=#000000]/[/COLOR] [/FONT]
The simplicity kicks in when I'm doing snapshots:
bt su sn -r /subvol/@KDEneon /snapshot/@KDEneon3
I usually do "sudo -i" when I'm doing send|receive so its:
sudo -i
btrfs send /snapshot/@KDEneon1 | btrfs receive /backup
The simple mount points help keep it straight in my old memory and keeping the snaps in one location makes accidental duplication less likely. You might notice from the above listing I used to add "_ro" when I did a read-only snapshot, but I've stopped doing that. Now I use the trailing number on the snapshot name to keep multiple snapshots of the same subvolume for incremental backup purposes which also indicates it's read-only to me - since it has to be for send|receive.
- Top
- Bottom
Leave a comment:
-
I deleted Snapper and ...
its snapshots.
The primary reason is that, after due consideration, I don't think they are necessary. They exist in two locations: /.snapshots and /home/.snapshots. Both are accessible without mounting the fs on /mnt. Neither are preserved in my btrfs /mnt snapshots. And, I can extract files from my /mnt mounted fs using mc just as easily as I can do the same from a snapper snapshot. I was, effectively, wasting disk space using snapper and keeping my read only backup snapshots on /mnt/bkup/snapshots. Keeping a copy of my system on a 2nd HD is more secure than in a local snapper snapshot. Farewell, snapper!
- Top
- Bottom
Leave a comment:
-
Thank you for your long reply.
BTRFS send and receive are applied only to subvolumes, not an entire file system. So "send -f" sends a subvolume to a file and "receive -f' restores that file as a subvolume to a BTRFS file system. On the case of multiple installs on a single file system like I have, you would need to send|receive each subvolume separately. I don't see any reason why you couldn't image the entire BTRFS partition like you are now if that's the best solution.
You don't say it, but I assume the backup drive you refer to is a USB device. As I said before, the BTRFS devs do not recommend using send]receive over the USB subsystem. Likely, they're being over-cautious. Personally, I wouldn't trust NTFS for backups either, but that's just me.
I see a couple options right away: The likelihood of your computer actually blowing up are very slight. So the simplest backup solution is to use "send -f" to make copies of your subvolumes and copy the backup subvolume files to the USB drive.
Slightly more complicated, but not too much so; If you kept a backup on the PC itself, you could still do incremental backups on the PC itself, then do the send -f and copy to the USB drive periodically. That way you'd have a "live" backup on the PC's for easy access but still have a "all blowed up" copy on the USB drive.
Another idea but more work; You could partition the backup drive leaving the NTFS partition as the first partition, thus all your Windows PCs could use the backup drive. Copy the backup subvolume files to the NTFS partition, and restore (receive -f) them to a BTRFS file system on the USB drive. Then your backup files are accessible if desired. You wouldn't have to do the receive operation until you wanted to access the files.
Also, you can get a low profile USB thumb drive of 32,64, or 128 GB for less than $20-30, leave it in the PC, and use it to hold the copy of your install subvolume, while using the USB backup drive to backup your /home in the traditional way.
Which solution works for you will depend on your fault tolerance and willingness to spend the time doing it. In your case, maybe BTRFS isn't the best solution given your mixed OS environment. You could still use BTRFS on your PC but rely on other methods for backups. Also, I agree, rsync can be a mess.
- Top
- Bottom
Leave a comment:
-
Thank you for your long reply.
Not really -
Previously, I would image my root partition onto a backup drive. Now, I can image the btrfs partition, but I may have several installs in different subvolumes, so that's not the same. I was thinking, does btrts subvolume send -f suit that use case?
Hmm, I suppose I'd be better to put a btrfs file system on my backup drive, so that I can do incremental backups. But my backup drives have backups from other systems, like my family's windows laptops, so are formatted NTFS. (I tried doing incremental backups with rsync some years ago, but with NTFS it was a mess.)
- Top
- Bottom
Leave a comment:
-
Originally posted by jlittle View PostIt seems to me that btfrs send of a subvolume is the btrfs way of making an image of a partition.- Is that correct?
I think the primary cause of the confusion here is caused by the use of incorrect terminology. You don't actually mount or "image" or duplicate a partition. Partitions are simply walls on your device that separate it into sections. What you actually mount or image are "file systems". Your hard drive (any block device, really) can be divided by partitions. In these partitions, you create file systems (AKA formatting). You can then put files on the file systems. Now if you have 3 partitions on a hard drive and each one holds a file system, data (files) cannot move across the partition boundaries except at the user level - copied from one file system to another. Most file systems require a partition table because they can only exist within, and fully occupy, the boundaries of a partition.
BTRFS is an advanced file system that adds a feature called subvolumes that allow you to separate data into logical sections within a single file system. When using BTRFS, you can divide a single file system (whether it's on a partition or not is irrelevant) into subvolumes, Subvolumes can be mounted just like individual file systems (partitions). When they are - they behave like a partitioned file system - data does not move across subvolume boundaries. However, you can also mount the root or main file system. Doing this reveals the individual subvolumes. A snapshot is a way to have the same data (files) accessible in more than one subvolume. At creation, a snapshot (a way to create a subvolume by copying an existing subvolume) is an exact duplicate of the source subvolume.- all the files are the same in both. However, if you add, delete, or edit a file in the source subvolume the same changes do not occur in the snapshot subvolume. With a snapshot, you have the same data accessible across subvolume boundaries. This may change as the data is manipulated - much different than a partitioned file system.
So the answer to the above query is no, no one actually ever makes an image of a partition. You are actually making an image of a file system. If you're using BTRFS you can separate and relocate your data by using subvolumes and transmitting them. Using another file system, you would have to image the entire file system, replicate the partition it came from (same exact size, etc.) and then restore it, or in many cases, the image software does the re-creation of the partition boundaries for you. With BTRFS and subvolumes, the size of the file system and it's partition boundaries (if there are any) are irrelevant - excepting, of course, the receiving file system must have enough free space to accept the subvolume.
Originally posted by jlittle View Post2. Is the format portable? By which I mean, can the output be stored, and be received on another machine?
Originally posted by jlittle View Post3... or the same machine, some time later?
Originally posted by jlittle View Post4. Is the format efficient, or would it benefit from compression?
Originally posted by jlittle View Post5. Is the there any other way of imaging a subvolume?
A use case I could think of is wanting to copy a subvolume from one computer to another when no network connection was possible. On computer A, you could "send" a subvolume to a file, then copy it to a thumb drive or CD-ROM. On computer B, you would then "receive" the subvolume from the thumb drive or CD-ROM to a BTRFS file system. You could actually format a thumb drive or USB drive with BTRFS and send|receive to it, but the BTRFS developers advise against doing that because the USB subsystem is not reliable enough to handle bit level transfers like BTRFS does, so you could corrupt your data.
Originally posted by jlittle View PostI've googled the above, and I'm not sure about 1., 2. seems yes, but I think so only because the wiki publishes the format, 3. I think so, 4. I don't know, and 5. I've no idea.Last edited by oshunluvr; Apr 05, 2017, 07:58 AM.
- Top
- Bottom
Leave a comment:
-
It seems to me that btfrs send of a subvolume is the btrfs way of making an image of a partition.- Is that correct?
- Is the format portable? By which I mean, can the output be stored, and be received on another machine?
- ... or the same machine, some time later?
- Is the format efficient, or would it benefit from compression?
- Is the there any other way of imaging a subvolume?
I've googled the above, and I'm not sure about 1., 2. seems yes, but I think so only because the wiki publishes the format, 3. I think so, 4. I don't know, and 5. I've no idea.
- Top
- Bottom
Leave a comment:
-
Originally posted by oshunluvr View PostThis morning, I did a fresh set of backups to a secondary HDD from my SSDs (2x250GB btrfs file system) for KDEneon and Kubuntu 16.04 and their respective homes - 4 subvolumes in all. I then deleted a few old snaps I had in a folder.
Right now df says:Code:/dev/sdc3 460G 142G 312G 32% /
Code:stuart@office:~$ sudo btrfs fi df / [sudo] password for stuart: Data, RAID0: total=387.88GiB, used=138.63GiB System, RAID1: total=32.00MiB, used=48.00KiB Metadata, RAID1: total=5.00GiB, used=1.07GiB GlobalReserve, single: total=512.00MiB, used=0.00B
With this i7 8GB Acer V30771G running NVidia GT650M and a new 750GB HD, I have installed EVERYTHING I ever had on my Linux distros, putting on data dating from the 1980s and my Turbo Pascal Days. I have Steam, Obiter 2010, the IQAN dev tool, and I've put on Flight Gear and a ton of Linux games I've played in the past. I even have Penquin Pinball!I looked at Pingus and decided my grandson would hate it. I've installed PostgreSQL 9.5 and the Qt 5.8.0 SDK from qt.io, and loaded my Qt apps from work into it. Those work files had a 2008 date on them. When the DVD Caddy comes and I put in the WD HD this laptop will be the most powerful computer I've ever run. And it was made in 2012.
- Top
- Bottom
Leave a comment:
-
This morning, I did a fresh set of backups to a secondary HDD from my SSDs (2x250GB btrfs file system) for KDEneon and Kubuntu 16.04 and their respective homes - 4 subvolumes in all. I then deleted a few old snaps I had in a folder.
Right now df says:Code:/dev/sdc3 460G 142G 312G 32% /
Code:stuart@office:~$ sudo btrfs fi df / [sudo] password for stuart: Data, RAID0: total=387.88GiB, used=138.63GiB System, RAID1: total=32.00MiB, used=48.00KiB Metadata, RAID1: total=5.00GiB, used=1.07GiB GlobalReserve, single: total=512.00MiB, used=0.00B
- Top
- Bottom
Leave a comment:
-
Originally posted by oshunluvr View PostA "snapshot" can only exist on the same device as the source subvolume. Technically, when you execute "send|receive" on a snapshot, it's not a snapshot on the receiving end. It's now a copy of a subvolume.
Originally posted by oshunluvr View PostRemember; a snapshot does not actually contain any data, it simply holds the current state of inodes of data that already exist in the file system. Thus when created, a snapshot occupies no free space (no data space anyway). As the data referenced by the snapshot's inodes are released (deleted) from the source subvolume, they remain in the snapshot, thus no data space is freed on the device.
When doing send|receive, the inodes don't transfer to another device, the receiving file system assigns it's own inodes to the incoming data. Therefore, the received volume is now a subvolume on it's own and not a snapshot.
Yes, you can transmit a subvolume via any method that you can normally transfer data through. Although the receiving device either has to be btrfs or you have to send the snapshot as a file and restore it to a btrfs file system to access it.)
When I put in that 2nd WD HD in the DVD Caddy and format it, I wll mount it as "/dev/sdb1 /bkup" after I that line in fstab, using that HD's uuid. I'm going to do that rather than do a btrfs add to pool it with sda1's subvolume. That way I can unmount it when I am not using it. I'm also going to continue using the WD USB 320Gb Passport HD as a bkup destination like I've been doing, until it dies, which I suspect will be "real soon" if the first one is any indication.
Thanks, Oshunluver!
- Top
- Bottom
Leave a comment:
-
A "snapshot" can only exist on the same device as the source subvolume. Technically, when you execute "send|receive" on a snapshot, it's not a snapshot on the receiving end. It's now a copy of a subvolume.
Remember; a snapshot does not actually contain any data, it simply holds the current state of inodes of data that already exist in the file system. Thus when created, a snapshot occupies no free space (no data space anyway). As the data referenced by the snapshot's inodes are released (deleted) from the source subvolume, they remain in the snapshot, thus no data space is freed on the device.
When doing send|receive, the inodes don't transfer to another device, the receiving file system assigns it's own inodes to the incoming data. Therefore, the received volume is now a subvolume on it's own and not a snapshot.
Yes, you can transmit a subvolume via any method that you can normally transfer data through. Although the receiving device either has to be btrfs or you have to send the snapshot as a file and restore it to a btrfs file system to access it.
- Top
- Bottom
Leave a comment:
Users Viewing This Topic
Collapse
There are 0 users viewing this topic.
Leave a comment: