lvdisplaynode
vgdisplaylinux
lvcreate -L 100G centosdocker
Volume group "centos" has insufficient free space (1 extents): 25600 required.centos
lvcreate -L 100G -n docker-btr centos架構
--------------------------------------------------app
https://wiki.zentyal.org/wiki/Resize_Root_LVM_Partitionless
http://unix.stackexchange.com/questions/163969/resize-root-lvm-and-fs-in-debian-7ide
---------------------------------------------------ui
https://docs.docker.com/engine/userguide/storagedriver/btrfs-driver/this
mkfs.btrfs -f /dev/centos/docker-btr
--------------------------------------
https://access.redhat.com/articles/1196333
~]# umount /dev/vdb1
~]# e2fsck -f /dev/vdb1
e2fsck 1.41.12 (17-May-2010)
Pass 1:Checking inodes, blocks, and sizes
Pass 2:Checking directory structure
Pass 3:Checking directory connectivity
Pass 4:Checking reference counts
Pass 5:Checking group sumary information
ext4-1:11/131072 files (0.0% non-contiguous),27050/524128 blocks
~]# resize2fs /dev/vdb1 200M
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/vdb1 to 204800 (1k) blocks.
The filesystem /dev/vdb1 is now 204800 blocks long.
~]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them. Be careful before using the write command.
Command (m for help):
------
Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): *Enter*
Using default response p.
Partition number (2-4, default 2): *Enter*
First sector (1026048-854745087, default 1026048): *Enter*
Last sector, +sectors or +size{K,M,G,T,P} (1026048-854745087, default 854745087): +500M
Created a new partition 2 of type 'Linux' and of size 500 MiB.
------
Command (m for help): p
Disk /dev/vda: 407.6 GiB, 437629485056 bytes, 854745088 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0xf6e2b6cb
Device Boot Start End Blocks Id System
/dev/vda1 2048 1026047 512000 83 Linux
/dev/vda2 1026048 2050047 512000 83 Linux
-------
Write the changes with the w option when you are sure they are correct
------------------------------------------------------------------------------------------------
Install parted 3.2
wget http://ftp.gnu.org/gnu/parted/parted-3.2.tar.xz
tar -xvf parted-3.2.tar.xz
cd parted-3.2
sudo yum install -y libuuid-devel device-mapper-devel termcap-devel
./configure --without-readline
make
make install
-----------------------
/usr/local/sbin/parted /dev/sdb
resizepart 1 5T
mkpart primary btrfs 6000GB 7000GB
mkfs.btrfs -f /dev/sdb2
mkdir -p /data/btrfs/docker
[root@WUSHUU-KAFKA docker]# blkid /dev/sdb2
/dev/sdb2: UUID="421caab3-b9e9-4572-adcd-3f741eb33411" UUID_SUB="80d62d39-3a49-4e6e-9a17-0f47c09bdf91" TYPE="btrfs" PARTLABEL="primary" PARTUUID="39a502b7-1253-45be-9358-17624b23f275"
add to /etc/fstab
/dev/sdb2 /data/btrfs/docker btrfs defaults 0 0
UUID="421caab3-b9e9-4572-adcd-3f741eb33411" /data/btrfs/docker btrfs defaults 0 0
add --storage-driver=btrfs to docker start script
----------------------------------------
https://blog.shadypixel.com/how-to-shrink-an-lvm-volume-safely/
stop emu-kvm
-----------
virsh list --all
virsh shutdown Police
---------
resize lvm partition
---------
umount /dev/mapper/centos-data
e2fsck -f /dev/mapper/centos-data
resize2fs /dev/mapper/centos-data 1000G
lvreduce -L 1000G /dev/mapper/centos-data
create docker btrfs
------------------
lvcreate -L 1000G -n docker-btr centos
mkfs.btrfs -f /dev/mapper/centos-docker--btr
[root@WUSHUU-KAFKA centos]# blkid /dev/mapper/centos-docker--btr
/dev/mapper/centos-docker--btr: UUID="94fd4ac3-58c6-4448-93eb-1bbb7ad8fc32" UUID_SUB="fdfd4893-076e-42c3-bfcb-fd927e6201b7" TYPE=「btrfs」
echo -e "/dev/mapper/centos-docker--btr /var/lib/docker btrfs defaults 0 0 \nUUID=\"94fd4ac3-58c6-4448-93eb-1bbb7ad8fc32\" /var/lib/docker btrfs defaults 0 0" >>/etc/fstab
mount -a
================================================================================
[root@localhost ~]# lvdisplay
--- Logical volume ---
LV Path /dev/centos/swap
LV Name swap
VG Name centos
LV UUID ymunkB-9D3Z-jrWt-aEwi-Ertw-zqnM-ZHCBJg
LV Write Access read/write
LV Creation host, time localhost, 2016-09-06 17:53:33 +0800
LV Status available
# open 2
LV Size 11.81 GiB
Current LE 3024
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
--- Logical volume ---
LV Path /dev/centos/home
LV Name home
VG Name centos
LV UUID YNVcCh-cR6r-3eAB-yMDc-5fre-LcJM-YhbEPD
LV Write Access read/write
LV Creation host, time localhost, 2016-09-06 17:53:33 +0800
LV Status available
# open 1
LV Size 216.51 GiB
Current LE 55426
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
--- Logical volume ---
LV Path /dev/centos/root
LV Name root
VG Name centos
LV UUID pDpa2u-mpTV-T51N-gFZ8-JfzL-O9qO-XOlfo7
LV Write Access read/write
LV Creation host, time localhost, 2016-09-06 17:53:36 +0800
LV Status available
# open 1
LV Size 50.00 GiB
Current LE 12800
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--------------------------------------------------------------------------------------------------------
[root@localhost /]# yum install wget
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.tuna.tsinghua.edu.cn
* extras: mirrors.neusoft.edu.cn
* updates: mirrors.tuna.tsinghua.edu.cn
正在解決依賴關係
--> 正在檢查事務
---> 軟件包 wget.x86_64.0.1.14-10.el7_0.1 將被 安裝
--> 解決依賴關係完成
依賴關係解決
=============================================================
Package 架構 版本 源 大小
=============================================================
正在安裝:
wget x86_64 1.14-10.el7_0.1 base 545 k
事務概要
=============================================================
安裝 1 軟件包
總下載量:545 k
安裝大小:2.0 M
Is this ok [y/d/N]: y
wget http://ftp.gnu.org/gnu/parted/parted-3.2.tar.xz
tar -xvf parted-3.2.tar.xz
cd parted-3.2
sudo yum install -y libuuid-devel device-mapper-devel termcap-devel
./configure --without-readline
make
make install
[root@localhost parted-3.2]# fdisk -l
磁盤 /dev/sda:36 MB, 36700160 字節,71680 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/物理):512 字節 / 512 字節
I/O 大小(最小/最佳):512 字節 / 512 字節
磁盤標籤類型:dos
磁盤標識符:0x0008e13c
設備 Boot Start End Blocks Id System
磁盤 /dev/sdb:15 MB, 15000576 字節,29298 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/物理):512 字節 / 512 字節
I/O 大小(最小/最佳):512 字節 / 512 字節
磁盤標籤類型:dos
磁盤標識符:0x000a9276
設備 Boot Start End Blocks Id System
磁盤 /dev/sdc:299.4 GB, 299439751168 字節,584843264 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/物理):512 字節 / 512 字節
I/O 大小(最小/最佳):512 字節 / 512 字節
磁盤標籤類型:dos
磁盤標識符:0x0003c8da
設備 Boot Start End Blocks Id System
/dev/sdc1 * 2048 1026047 512000 83 Linux
/dev/sdc2 1026048 584843263 291908608 8e Linux LVM
磁盤 /dev/mapper/centos-root:53.7 GB, 53687091200 字節,104857600 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/物理):512 字節 / 512 字節
I/O 大小(最小/最佳):512 字節 / 512 字節
磁盤 /dev/mapper/centos-swap:12.7 GB, 12683575296 字節,24772608 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/物理):512 字節 / 512 字節
I/O 大小(最小/最佳):512 字節 / 512 字節
磁盤 /dev/mapper/centos-home:232.5 GB, 232473493504 字節,454049792 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/物理):512 字節 / 512 字節
I/O 大小(最小/最佳):512 字節 / 512 字節
===========================================================================
對於linux下的文件系統和邏輯卷管理的相關概念須要深刻理解,而且要對掛載文件系統的概念有個清晰的認識,這樣才能知道下面的文檔的用意所在,而且須要先創建docker的掛載路徑,而且將該掛載路徑掛載到相應的btrfs文件系統下,這樣才能夠按照下面的文檔中描述的那樣實現開機時的自動掛載,在進行了這個步驟以後,再進行docker 的安裝,就能夠實現docker info的信息的正確輸出。
b. Create an
/etc/fstab
entry to automatically mount/var/lib/docker
each time the system boots. Either of the following lines will work, just remember to substitute the UUID value with the value obtained from the previous command./dev/xvdb /var/lib/docker btrfs defaults 0 0 UUID="a0ed851e-158b-4120-8416-c9b072c8cf47" /var/lib/docker btrfs defaults 0 0
如下是在系統分區所有準備完之後的主要的步驟,固然,也簡略的提到了創建文件系統的過程,對於那些不瞭解LVM以及linux下磁盤分區相關概念的小夥伴們,就應當多多參考一下這篇文章,這裏對於怎樣對linux的磁盤進行管理有詳細的介紹。
Configure Btrfs on Ubuntu 14.04 LTS
Assuming your system meets the prerequisites, do the following:
Install the 「btrfs-tools」 package.
$ sudo apt-get install btrfs-tools Reading package lists... Done Building dependency tree <output truncated>Create the Btrfs storage pool.
Btrfs storage pools are created with the
mkfs.btrfs
command. Passing multiple devices to themkfs.btrfs
command creates a pool across all of those devices. Here you create a pool with a single device at/dev/xvdb
.$ sudo mkfs.btrfs -f /dev/xvdb WARNING! - Btrfs v3.12 IS EXPERIMENTAL WARNING! - see http://btrfs.wiki.kernel.org before using Turning ON incompat feature 'extref': increased hardlink limit per file to 65536 fs created label (null) on /dev/xvdb nodesize 16384 leafsize 16384 sectorsize 4096 size 4.00GiB Btrfs v3.12Be sure to substitute
/dev/xvdb
with the appropriate device(s) on your system.Warning: Take note of the warning about Btrfs being experimental. As noted earlier, Btrfs is not currently recommended for production deployments unless you already have extensive experience.
If it does not already exist, create a directory for the Docker host’s local storage area at
/var/lib/docker
.$ sudo mkdir /var/lib/dockerConfigure the system to automatically mount the Btrfs filesystem each time the system boots.
a. Obtain the Btrfs filesystem’s UUID.
$ sudo blkid /dev/xvdb /dev/xvdb: UUID="a0ed851e-158b-4120-8416-c9b072c8cf47" UUID_SUB="c3927a64-4454-4eef-95c2-a7d44ac0cf27" TYPE="btrfs"b. Create an
/etc/fstab
entry to automatically mount/var/lib/docker
each time the system boots. Either of the following lines will work, just remember to substitute the UUID value with the value obtained from the previous command./dev/xvdb /var/lib/docker btrfs defaults 0 0 UUID="a0ed851e-158b-4120-8416-c9b072c8cf47" /var/lib/docker btrfs defaults 0 0Mount the new filesystem and verify the operation.
$ sudo mount -a $ mount /dev/xvda1 on / type ext4 (rw,discard) <output truncated> /dev/xvdb on /var/lib/docker type btrfs (rw)The last line in the output above shows the
/dev/xvdb
mounted at/var/lib/docker
as Btrfs.Now that you have a Btrfs filesystem mounted at
/var/lib/docker
, the daemon should automatically load with thebtrfs
storage driver.
Start the Docker daemon.
$ sudo service docker start docker start/running, process 2315The procedure for starting the Docker daemon may differ depending on the Linux distribution you are using.
You can force the Docker daemon to start with the
btrfs
storage driver by either passing the--storage-driver=btrfs
flag to thedocker daemon
at startup, or adding it to theDOCKER_OPTS
line to the Docker config file.Verify the storage driver with the
docker info
command.$ sudo docker info Containers: 0 Images: 0 Storage Driver: btrfs [...]Your Docker host is now configured to use the
btrfs
storage driver.