1. Preliminary understanding
The Btrfs system is a file system type developed by Oracle to replace the EXT series file system. With the rapid development of the network, the file system of EXT system does not meet the need in many aspects. Core features: Multi-Physical volume support: Btrfs can be composed of multiple underlying physical volumes, RAID support for online "add", "Remove", "modify", copy-on-write update mechanism (CoW): Copy, update and replace pointers, instead of "in-place" updates; Data and meta-data checksum: Checksum ; Sub-volume: sub_volume; snapshot: snapshot support snapshot; transparent compression.
2. Further information
2.1, before the demonstration process, preparation work
Prepare the corresponding number of disks as needed, keeping the disk space consistent.
2.2, confirm that the added hard drive has been recognized by the system
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/73/E6/wKiom1YJTBvT16oDAAEKaQURDKo537.jpg "title=" Picture 1.png "alt=" Wkiom1yjtbvt16odaaekaqurdko537.jpg "/>
2.3, create a Btrfs type of file system (here also need to remind, CENTOS6 above default is not installed Btrfs file system name. Need to be installed)
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/73/E3/wKioL1YJTC7RVReEAABmykW-STU390.jpg "title=" Picture 2.png "alt=" Wkiol1yjtc7rvreeaabmykw-stu390.jpg "/>
As simple as creating a Btrfs file system, you need only one command. You will find that the operation is very convenient,
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/73/E6/wKiom1YJTDXDVD2zAAE_XzAwtBM603.jpg "title=" Picture 3.png "alt=" Wkiom1yjtdxdvd2zaae_xzawtbm603.jpg "/>
Compared to the Btrfs command, it actually has more options to manipulate! But it's not complicated!
2.4, confirm whether to create a successful, relative to confirm whether the command has been created too many, the following general:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/73/E3/wKioL1YJTEiRRW04AAEOEDJvjDo049.jpg "title=" Picture 4.png "alt=" Wkiol1yjteirrw04aaeoedjvjdo049.jpg "/>
Many methods, according to the needs of their own choice can
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/73/E6/wKiom1YJTFHRQf7eAAEf_EaHd6k731.jpg "title=" Picture 5.png "alt=" Wkiom1yjtfhrqf7eaaef_eahd6k731.jpg "/>
2.5, after the completion of the creation, you can mount the Btrfs file system to confirm the normal use
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/73/E6/wKiom1YJTKniWIlNAABdeATPUj8571.jpg "title=" Picture 39.png "alt=" Wkiom1yjtkniwilnaabdeatpuj8571.jpg "/>
Confirm that the mount is complete by using the Moun command
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/73/E3/wKioL1YJTGTiZkxpAAF2j7VBSm8181.jpg "title=" Picture 6.png "alt=" Wkiol1yjtgtizkxpaaf2j7vbsm8181.jpg "/>
2.6. Go to mount point to create file test
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/73/E6/wKiom1YJTGbhYCP3AACp9CkyMEw845.jpg "title=" Picture 7.png "alt=" Wkiom1yjtgbhycp3aacp9ckymew845.jpg "/>
2.7, for Btrfs file system type, there is a place to pay attention to the next
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/73/E6/wKiom1YJTL6TIa1wAAFMGPzc3xQ018.jpg "title=" Picture 8.png "alt=" Wkiom1yjtl6tia1waafmgpzc3xq018.jpg "/>
A newly mounted file system, you can be very good to find, have not used the time will be used 2G, this part of the file system itself is used
3. Btrfs Extended Part One
3.1, if after the creation of a good file system, found to give too much space, need to reduce, that what to do le?
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/73/E3/wKioL1YJTNTCZzXrAACAL7JsUHk952.jpg "title=" Picture 9.png "alt=" Wkiol1yjtntczzxraacal7jsuhk952.jpg "/>
This requires such a command, is not feeling particularly simple, so easy things, compared to LVM is much simpler! For LVM, the data in the file system is lost if the operation is inappropriate.
Verify that the reduction was successful and that the data is intact
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/73/E6/wKiom1YJTO7zmEoVAAFEXNkADqc323.jpg "title=" Picture 10.png "alt=" Wkiom1yjto7zmeovaafexnkadqc323.jpg "/>
It can be determined that the reduction has been successful. However, it is important to note that btrfs reduction is not unlimited. Btrfs reduction cannot be less than the available size of a single hard drive. Otherwise, the reduction will fail.
3.2, but if one day, suddenly created before the file system needs to expand the space, then what???
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/73/E3/wKioL1YJTQewbwPAAABrmMRaysY590.jpg "title=" Picture 11.png "alt=" Wkiol1yjtqewbwpaaabrmmraysy590.jpg "/>
In fact, the expansion or reduction is very simple thing, it is necessary to resize after the {-|+} plus a number. Where-representative reduction; + represents capacity expansion. However, if you add max after resize, it represents the largest capacity expansion. As follows
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/73/E3/wKioL1YJTRziPf44AAGPmaSRL6Y777.jpg "title=" Picture 12.png "alt=" Wkiol1yjtrzipf44aagpmasrl6y777.jpg "/>
3.3. How to use the space of btrfs, can be viewed by the following command
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/73/E6/wKiom1YJTR7zj3b7AAEntkFm94w513.jpg "title=" Picture 13.png "alt=" Wkiom1yjtr7zj3b7aaentkfm94w513.jpg "/>
The above command can be seen, the file system created Btrfs, the default is to use the raid: Data is RAID0; the system is RAID1; the metadata is RAID1.
3.4, one day, the disk space to use full, which has the transformation to do??
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/73/E6/wKiom1YJTS3Dd5LIAAAy9nwHMDs440.jpg "title=" Picture 14.png "alt=" Wkiom1yjts3dd5liaaay9nwhmds440.jpg "/>
Simple above a command can be, here you are not more and more feel, btrfs easy to use it.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/73/E3/wKioL1YJTUqCp9sEAAFQ1-X0AqA631.jpg "title=" Picture 15.png "alt=" Wkiol1yjtuqcp9seaafq1-x0aqa631.jpg "/>
4. Extension Part Two
For Btrfs Systems, in addition to being able to manage themselves, you can create sub-file systems, file system snapshots, and so on. It's actually pretty good.
4.1, to have Btrfs file system, in fact, support the file system content compression mechanism.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/73/E6/wKiom1YJTVLzUb7DAAH-Pps7JIc808.jpg "title=" Picture 16.png "alt=" Wkiom1yjtvlzub7daah-pps7jic808.jpg "/>
Compress data in the file system in LZO format
4.2. Create a sub-file system within a file system created by Btrfs
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/73/E3/wKioL1YJTWqR-lOBAABiYUeFpKw409.jpg "title=" Picture 17.png "alt=" Wkiol1yjtwqr-lobaabiyuefpkw409.jpg "/>
A simple command above will create a sub-file system
The following command enables you to confirm the success of the creation
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/73/E3/wKioL1YJTfOgcXL1AABd73Zua84028.jpg "title=" Picture 40.png "alt=" Wkiol1yjtfogcxl1aabd73zua84028.jpg "/>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/73/E3/wKioL1YJTX2QCsLAAACW07nFMMk946.jpg "title=" Picture 18.png "alt=" Wkiol1yjtx2qcslaaacw07nfmmk946.jpg "/>
4.3, for the sub-file system, in fact, he can actually be mounted independently. However, there is a premise that the parent file system must be uninstalled before it can be mounted, then download the parent file system, mount the sub-file system to
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/73/E6/wKiom1YJTYGTpzXbAAB2aVcfBdI107.jpg "title=" Picture 19.png "alt=" Wkiom1yjtygtpzxbaab2avcfbdi107.jpg "/>
When you mount a sub-file system, you need to be aware of specifying the sub-file system type,
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/73/E6/wKiom1YJTaSx4lbMAAEtHMiOdTA325.jpg "title=" Picture 20.png "alt=" Wkiom1yjtasx4lbmaaethmiodta325.jpg "/>
By default, the size of the parent file system, how much space can be used by the sub-file system
After the mount is complete, the sub-file system can be used normally after the test.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/73/E6/wKiom1YJTiThqiRkAADMRqlxfxc090.jpg "title=" Picture 21.png "alt=" Wkiom1yjtithqirkaadmrqlxfxc090.jpg "/>
4.4, for the sub-file system, when the parent file system is mounted, the default sub-question price system will be automatically mounted, and the previous sub-file system saved data is not lost, still exists. If you don't believe, look at the results.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/73/E3/wKioL1YJTkuAw0gqAABq4WAPJDY164.jpg "title=" Picture 22.png "alt=" Wkiol1yjtkuaw0gqaabq4wapjdy164.jpg "/>
When the parent file system is mounted, the sub-file system is viewed and the data from the sub-file system is still stored
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/73/E6/wKiom1YJTlaxOSh9AABOLSljrpQ878.jpg "title=" Picture 23.png "alt=" Wkiom1yjtlaxosh9aabolsljrpq878.jpg "/>
4.5, relative to the sub-file system, in fact, the best use of btrfs is to be able to use the snapshot function, when a file system needs to be a real backup, then the function of the snapshot is good enough to show its ability.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/73/E3/wKioL1YJTmrgKfBjAACkFzrP6To304.jpg "title=" Picture 24.png "alt=" Wkiol1yjtmrgkfbjaackfzrp6to304.jpg "/>
Many of the Btrfs file systems require a single command to get it done. Go to the test and see if that's true.
Switch to create a directory in the logs sub-file system
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/73/E6/wKiom1YJTnLQnGoqAAB7vo9sHu0612.jpg "title=" Picture 25.png "alt=" Wkiom1yjtnlqngoqaab7vo9shu0612.jpg "/>
Then go to the snapshot file system you created before, and you can determine that the file data in the snapshot does not change.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/73/E6/wKiom1YJTxLhaRoVAABwtXJk9Ws098.jpg "title=" Picture 41.png "alt=" Wkiom1yjtxlharovaabwtxjk9ws098.jpg "/>
4.6, for Btrfs type of file system, in fact, can also create a snapshot of a single file;
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/73/E6/wKiom1YJToLAORHcAAA3W06apag277.jpg "title=" Picture 26.png "alt=" Wkiom1yjtolaorhcaaa3w06apag277.jpg "/>
4.7. now that you can create a Btrfs file system, you need to be able to delete it.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/73/E6/wKiom1YJTpCj-_QYAADBbRrmz0U157.jpg "title=" Picture 27.png "alt=" Wkiom1yjtpcj-_qyaadbbrrmz0u157.jpg "/>
4.8, to delete the sub-file system is relatively simple, but remove the parent Btrfs added disk, you need to be careful. Remember to first reduce the raid disk array by 0 or 1 basic. Otherwise there must be a problem.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/73/E6/wKiom1YJTqOD7yKDAADS-h80hM0192.jpg "title=" Picture 28.png "alt=" Wkiom1yjtqod7ykdaads-h80hm0192.jpg "/>
After the basic of the array goes down, you can remove the disks that need to be removed
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/73/E3/wKioL1YJTzKgdXXmAAF1aG9McNE671.jpg "title=" Picture 29.png "alt=" Wkiol1yjtzkgdxxmaaf1ag9mcne671.jpg "/>
5. Btrfs Extended Part III
5.1, for the Btrfs file system, in fact, it also supports, from other file systems to replace the Btrfs file system, but also to reverse the Btrfs file system back.
5.2, prepare the required environment, prepared a ETX4 type of file system, and has been mounted, while storing some data inside
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/73/E6/wKiom1YJT1HRXpynAAIRuO_-fbU330.jpg "title=" Picture 30.png "alt=" Wkiom1yjt1hrxpynaairuo_-fbu330.jpg "/>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/73/E3/wKioL1YJT23AqYpFAAELIzbjD1c425.jpg "title=" Picture 31.png "alt=" Wkiol1yjt23aqypfaaelizbjd1c425.jpg "/>
5.3, uninstall and mount the file system, and then to the Btrfs file system before you also need to check the file system, to ensure that the file system does not exist files
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/73/E3/wKioL1YJT3_hD1-UAAFWKt9G_sQ757.jpg "title=" Picture 32.png "alt=" Wkiol1yjt3_hd1-uaafwkt9g_sq757.jpg "/>
5.4. Replace the Ext4 file system with the Btrfs type file system
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/73/E3/wKioL1YJT5LhDAQFAACdo_b-2OQ087.jpg "title=" Picture 33.png "alt=" Wkiol1yjt5lhdaqfaacdo_b-2oq087.jpg "/>
After the conversion is complete, confirm and complete
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/73/E6/wKiom1YJT5ORCQf1AAGF-XLEtlg542.jpg "title=" Picture 34.png "alt=" Wkiom1yjt5orcqf1aagf-xletlg542.jpg "/>
After the conversion is complete, follow the file system to verify that the file data is working properly
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/73/E3/wKioL1YJT6zyNsC8AAEWIltms1s184.jpg "title=" Picture 35.png "alt=" Wkiol1yjt6zynsc8aaewiltms1s184.jpg "/>
For the file system types that have been converted, after mounting the file system, you can see a special file in the internal, which saved the original system data, it is recommended not to delete, otherwise you cannot revert to the previous system type
5.5, to the file system type has been converted, if mounted, unloaded, then reversed, and can go back to the previous file system class
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/73/E6/wKiom1YJT7WjHrKcAAAeNvCch2c631.jpg "title=" Picture 36.png "alt=" Wkiom1yjt7wjhrkcaaaenvcch2c631.jpg "/>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/73/E3/wKioL1YJUA7w1C7oAAA18wHmAFU262.jpg "title=" Picture 42.png "alt=" Wkiol1yjua7w1c7oaaa18whmafu262.jpg "/>
and check to see if it's switched back.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/73/E3/wKioL1YJT8jwNyOCAAHMOjfkT2c896.jpg "title=" Picture 37.png "alt=" Wkiol1yjt8jwnyocaahmojfkt2c896.jpg "/>
Then switch to the directory central to verify that the original data is accurate and complete.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/73/E6/wKiom1YJT8nzPOKUAADJMwK5o6o062.jpg "title=" Picture 38.png "alt=" Wkiom1yjt8nzpokuaadjmwk5o6o062.jpg "/>
This article from the "Thinking Summary" blog, reproduced please contact the author!
Btrfs of the Linux file system