<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                [TOC] LVM是在磁盤分區和文件系統之間添加的一個邏輯層,來為文件系統屏蔽下層磁盤分區布局,提供一個抽象的盤卷,在盤卷上建立文件系統。比普通的分區管理(沒有LVm)具有靈活性,可也改變掛載點的大小. ![](https://box.kancloud.cn/5024d255db3987d6abb56a5ca93a98c6_359x297.png) 在進行下一步之前,我們說明一下pv、vg、lv的關系。 一個硬盤f分區組成一個pv(物理卷) 一個或者多個pv組成一個vg(卷組) 一個vg可以劃分出多個lv(邏輯卷) ![](https://box.kancloud.cn/613a551769cd96e12854dcf73e922212_448x367.png) ## 1. 創建分區 ### 1.1 查看磁盤信息 ~~~ root@ubuntu01:~# fdisk -l Disk /dev/sda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000a2636 Device Boot Start End Blocks Id System /dev/sda1 * 2048 37847039 18922496 83 Linux /dev/sda2 37849086 41940991 2045953 5 Extended /dev/sda5 37849088 41940991 2045952 82 Linux swap / Solaris Disk /dev/sdb: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 cylinders, total 20971520 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/sdb doesn't contain a valid partition table ~~~ /dev/sdb整個盤都沒有進行過分區 ### 1.2 分區 ~~~ root@ubuntu01:~# fdisk /dev/sdb Command (m for help): n #輸入n創建分區 Partition type: p primary (1 primary, 0 extended, 3 free) e extended Select (default p): p Partition number (1-4, default 2): 2 # 分區號,前邊已經分過一個了 First sector (1026048-20971519, default 1026048): Using default value 1026048 Last sector, +sectors or +size{K,M,G} (1026048-20971519, default 20971519): 1G Value out of range. Last sector, +sectors or +size{K,M,G} (1026048-20971519, default 20971519): +1G Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. root@ubuntu01:~# fdisk -l # 此時sdb設備有兩個分區 Disk /dev/sda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000a2636 Device Boot Start End Blocks Id System /dev/sda1 * 2048 37847039 18922496 83 Linux /dev/sda2 37849086 41940991 2045953 5 Extended /dev/sda5 37849088 41940991 2045952 82 Linux swap / Solaris Disk /dev/sdb: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 cylinders, total 20971520 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xc00d75b4 Device Boot Start End Blocks Id System /dev/sdb1 2048 1026047 512000 83 Linux /dev/sdb2 1026048 3123199 1048576 83 Linux ~~~ ### 1.3 創建lvm(邏輯卷) ~~~ root@ubuntu01:~# fdisk /dev/sdb Command (m for help): t # 修改分區編碼(8e為邏輯分區) Partition number (1-4): 2 # 分區編號 Hex code (type L to list codes): 8e Changed system type of partition 2 to 8e (Linux LVM) Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. ~~~ 此時sdb2分區的系統類別變成了 Linux LVM ~~~ root@ubuntu01:~# fdisk -l Disk /dev/sda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000a2636 Device Boot Start End Blocks Id System /dev/sda1 * 2048 37847039 18922496 83 Linux /dev/sda2 37849086 41940991 2045953 5 Extended /dev/sda5 37849088 41940991 2045952 82 Linux swap / Solaris Disk /dev/sdb: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 cylinders, total 20971520 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xc00d75b4 Device Boot Start End Blocks Id System /dev/sdb1 2048 1026047 512000 83 Linux /dev/sdb2 1026048 3123199 1048576 8e Linux LVM ~~~ ### 1.4 整合lvm,創建vg(卷組) 1. 創建pv(物理卷) ~~~ root@ubuntu01:~# pvcreate /dev/sdb2 Physical volume "/dev/sdb2" successfully created root@ubuntu01:~# root@ubuntu01:~# pvdisplay "/dev/sdb2" is a new physical volume of "1.00 GiB" --- NEW Physical volume --- PV Name /dev/sdb2 VG Name PV Size 1.00 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID nnMYmf-1xnO-LwyN-mYd5-3NTC-GOm2-lhfwmk ~~~ 2. 創建卷組 `vgcreate +組名 + PV Name ` ~~~ root@ubuntu01:~# vgcreate vgroup /dev/sdb2 # 根據pv:/dev/sdb2 創建vgroup組 Volume group "vgroup" successfully created root@ubuntu01:~# root@ubuntu01:~# root@ubuntu01:~# vgdisplay --- Volume group --- VG Name vgroup System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 1 VG Access read/write VG Status resizable MAX LV 0 Cur LV 0 Open LV 0 Max PV 0 Cur PV 1 Act PV 1 VG Size 1020.00 MiB PE Size 4.00 MiB Total PE 255 Alloc PE / Size 0 / 0 Free PE / Size 255 / 1020.00 MiB VG UUID EBCApt-lI68-OG4H-o6Yh-oGCB-1UQY-xphKJu ~~~ 4. 創建lvm 從卷組中分配出lvm邏輯卷 `lvcreate -L 【size】 -n 【lvm名】 【組名】` ~~~ root@ubuntu01:~# lvcreate -L 500M -n lvm1 vgroup Logical volume "lvm1" created ~~~ 5.格式化 ~~~ root@ubuntu01:~# mkfs -t ext4 /dev/vgroup/lvm1 mke2fs 1.42.9 (4-Feb-2014) Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) Stride=0 blocks, Stripe width=0 blocks 128016 inodes, 512000 blocks 25600 blocks (5.00%) reserved for the super user First data block=1 Maximum filesystem blocks=67633152 63 block groups 8192 blocks per group, 8192 fragments per group 2032 inodes per group Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409 Allocating group tables: done Writing inode tables: done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: done ~~~ 此時查看外部設備多了 /dev/mapper/vgroup-lvm1 在/dev/mapper/目錄下(感覺映射的意思),vgroup-lvm1 (組名-lvm名) ~~~ root@ubuntu01:~# fdisk -l Disk /dev/sdb: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 cylinders, total 20971520 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xc00d75b4 Device Boot Start End Blocks Id System /dev/sdb1 2048 1026047 512000 83 Linux /dev/sdb2 1026048 3123199 1048576 8e Linux LVM Disk /dev/mapper/vgroup-lvm1: 524 MB, 524288000 bytes 255 heads, 63 sectors/track, 63 cylinders, total 1024000 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/mapper/vgroup-lvm1 doesn't contain a valid partition table ~~~ 6. 掛載 ~~~ root@ubuntu01:~# mount /dev/vgroup/lvm1 /lvmdata root@ubuntu01:~# root@ubuntu01:~# df -h Filesystem Size Used Avail Use% Mounted on udev 966M 4.0K 966M 1% /dev tmpfs 196M 532K 195M 1% /run /dev/sda1 18G 3.0G 14G 18% / none 4.0K 0 4.0K 0% /sys/fs/cgroup none 5.0M 0 5.0M 0% /run/lock none 977M 0 977M 0% /run/shm none 100M 0 100M 0% /run/user /dev/mapper/vgroup-lvm1 477M 2.3M 445M 1% /lvmdata ~~~ 7. 修改配置文件 ~~~ root@ubuntu01:~# vim /etc/fstab # /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # <file system> <mount point> <type> <options> <dump> <pass> # / was on /dev/sda1 during installation UUID=39960f15-013d-4b48-a437-002fd8e57a28 / ext4 errors=remount-ro 0 1 # swap was on /dev/sda5 during installation UUID=12c20ef4-19f1-4721-aa45-2da6db2826a7 none swap sw 0 0 /dev/vgroup/lvm1 /lvmdata ext4 errors=remount-ro 0 0 ~~~ 新形成的/dev/vgroup/lvm1 /dev/組名/lvm名 ## 2. LVM大小修改 ### 2.1 ext2/ext3/ext4文件系統 ext2/ext3/ext4文件系統的調整命令是resize2fs(增大和減小都支持) ~~~ lvextend -L 120G /dev/mapper/centos-home //增大至120G lvextend -L +20G /dev/mapper/centos-home //增加20G lvreduce -L 50G /dev/mapper/centos-home //減小至50G lvreduce -L -8G /dev/mapper/centos-home //減小8G resize2fs /dev/mapper/centos-home //執行調整 ~~~ ### 2.1 xfs文件系統 調整命令是xfs_growfs(只支持增大) ~~~ lvextend -L 120G /dev/mapper/centos-home //增大至120G lvextend -L +20G /dev/mapper/centos-home //增加20G xfs_growfs /dev/mapper/centos-home //執行調整 ~~~ ~~~ 就是說:xfs文件系統只支持增大分區空間的情況,不支持減小的情況(切記!!!!!)。 硬要減小的話,只能在減小后將邏輯分區重新通過mkfs.xfs命令重新格式化才能掛載 ~~~ 例子1: 增加ext4文件系統lvm大小 ~~~ root@ubuntu01:~# lvextend -L +200M /dev/vgroup/lvm1 Extending logical volume lvm1 to 700.00 MiB Logical volume lvm1 successfully resized root@ubuntu01:~# root@ubuntu01:~# root@ubuntu01:~# root@ubuntu01:~# df -hT Filesystem Type Size Used Avail Use% Mounted on udev devtmpfs 966M 4.0K 966M 1% /dev tmpfs tmpfs 196M 540K 195M 1% /run /dev/sda1 ext4 18G 3.0G 14G 18% / none tmpfs 4.0K 0 4.0K 0% /sys/fs/cgroup none tmpfs 5.0M 0 5.0M 0% /run/lock none tmpfs 977M 0 977M 0% /run/shm none tmpfs 100M 0 100M 0% /run/user /dev/mapper/vgroup-lvm1 ext4 477M 2.3M 445M 1% /lvmdata ~~~ 如圖,沒有生效,因為沒有執行調整: ~~~ root@ubuntu01:~# resize2fs /dev/vgroup/lvm1 resize2fs 1.42.9 (4-Feb-2014) Filesystem at /dev/vgroup/lvm1 is mounted on /lvmdata; on-line resizing required old_desc_blocks = 2, new_desc_blocks = 3 The filesystem on /dev/vgroup/lvm1 is now 716800 blocks long. root@ubuntu01:~# df -hT Filesystem Type Size Used Avail Use% Mounted on udev devtmpfs 966M 4.0K 966M 1% /dev tmpfs tmpfs 196M 540K 195M 1% /run /dev/sda1 ext4 18G 3.0G 14G 18% / none tmpfs 4.0K 0 4.0K 0% /sys/fs/cgroup none tmpfs 5.0M 0 5.0M 0% /run/lock none tmpfs 977M 0 977M 0% /run/shm none tmpfs 100M 0 100M 0% /run/user /dev/mapper/vgroup-lvm1 ext4 670M 2.6M 631M 1% /lvmdata ~~~ 重啟服務器依然生效 例子2: 減少ext4文件系統lvm大小 若是減小分區空間,減小前必須要先卸載這個分區。如果卸載有問題,解決如下: ~~~ [root@localhost ~]# umount /home/ umount: /home: device is busy. (In some cases useful info about processes that use the device is found by lsof(8) or fuser(1)) 提示無法卸載,則是有進程占用/home,使用如下命令來終止占用進程: [root@localhost ~]# fuser -m -k /home /home: 1409 1519ce 1531e 1532e 1533e 1534e 1535e 1536e 1537e 1538e 1539e 1541e 1543e 1544e 1545e 1546e 1547e 1548e 1549e 1550e 1601m ~~~ 再次卸載home分區就成功了。 ### 減小分區 https://blog.csdn.net/sd4493091/article/details/66976078
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看