Welcome to fdisk (util-linux 2.33.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command.
Device does not contain a recognized partition table. Created a new DOS disklabel with disk identifier 0x2f5191a8.
Command (m for help): g Created a new GPT disklabel (GUID: 8B7DFDAA-0514-0146-9F52-1FDCF9F3D6E5).
Command (m for help): n Partition number (1-128, default 1): 1 First sector (2048-41943006, default 2048): Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-41943006, default 41943006):
Created a new partition 1 of type 'Linux filesystem' and of size 20 GiB.
Command (m for help): t Selected partition 1 Partition type (type L to list all types): L
Partition type (type L to list all types): 31 Changed type of partition 'Linux filesystem' to 'Linux LVM'.
Command (m for help): p Disk /dev/sdb: 20 GiB, 21474836480 bytes, 41943040 sectors Disk model: VMware Virtual S Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: gpt Disk identifier: 8B7DFDAA-0514-0146-9F52-1FDCF9F3D6E5
Device Start End Sectors Size Type /dev/sdb1 2048 41943006 41940959 20G Linux LVM
Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.
linux-wugz:/home/lengqing # vgs VG #PV #LV #SN Attr VSize VFree VG1 1 0 0 wz--n- 20.00g 20.00g system 1 1 0 wz--n- 15.99g 0 linux-wugz:/home/lengqing # vgdisplay --- Volume group --- VG Name system System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 2 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 1 Max PV 0 Cur PV 1 Act PV 1 VG Size 15.99 GiB PE Size 4.00 MiB Total PE 4093 Alloc PE / Size 4093 / 15.99 GiB Free PE / Size 0 / 0 VG UUID BfPwXl-TBTe-N6Rd-NaJT-xU2T-Ce0V-HqIN8L
--- Volume group --- VG Name VG1 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 20.00 GiB PE Size 4.00 MiB Total PE 5119 Alloc PE / Size 0 / 0 Free PE / Size 5119 / 20.00 GiB VG UUID ojpEne-jsFm-uB6R-azHU-zJmt-wP46-JvFeNc
linux-wugz:/home/lengqing # lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert LV1 VG1 -wi-a----- 20.00g root system -wi-ao---- 15.99g linux-wugz:/home/lengqing # lvdisplay --- Logical volume --- LV Path /dev/system/root LV Name root VG Name system LV UUID fsZvJJ-NCk9-rHvR-rSOh-80tK-9GxZ-H5BRSw LV Write Access read/write LV Creation host, time install, 2019-10-04 00:06:45 +0800 LV Status available # open 1 LV Size 15.99 GiB Current LE 4093 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 1024 Block device 254:0
--- Logical volume --- LV Path /dev/VG1/LV1 LV Name LV1 VG Name VG1 LV UUID xAccOh-PRJd-jtuR-jx7F-F9Qr-N3nw-Cxm7yh LV Write Access read/write LV Creation host, time linux-wugz, 2019-12-02 02:22:10 +0800 LV Status available # open 0 LV Size 20.00 GiB Current LE 5119 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 1024 Block device 254:1
Welcome to fdisk (util-linux 2.33.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command.
Device does not contain a recognized partition table. Created a new DOS disklabel with disk identifier 0xe5b9393b.
Command (m for help): g Created a new GPT disklabel (GUID: F8A76081-C61D-6A41-A62E-F39B89C0D886).
Command (m for help): n Partition number (1-128, default 1): First sector (2048-41943006, default 2048): Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-41943006, default 41943006):
Created a new partition 1 of type 'Linux filesystem' and of size 20 GiB.
Command (m for help): t Selected partition 1 Partition type (type L to list all types): 31 Changed type of partition 'Linux filesystem' to 'Linux LVM'.
Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.
linux-wugz:/home/lengqing # fdisk /dev/sdc -l Disk /dev/sdc: 20 GiB, 21474836480 bytes, 41943040 sectors Disk model: VMware Virtual S Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: gpt Disk identifier: F8A76081-C61D-6A41-A62E-F39B89C0D886
Device Start End Sectors Size Type /dev/sdc1 2048 41943006 41940959 20G Linux LVM linux-wugz:/home/lengqing # pvcreate /dev/sdc1 Physical volume "/dev/sdc1" successfully created. linux-wugz:/home/lengqing # vgextend VG1 /dev/sdc1 Volume group "VG1" successfully extended
linux-wugz:/home/lengqing # vgs VG #PV #LV #SN Attr VSize VFree VG1 2 1 0 wz--n- 39.99g 20.00g system 1 1 0 wz--n- 15.99g 0 linux-wugz:/home/lengqing # vgdisplay --- Volume group --- VG Name system System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 2 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 1 Max PV 0 Cur PV 1 Act PV 1 VG Size 15.99 GiB PE Size 4.00 MiB Total PE 4093 Alloc PE / Size 4093 / 15.99 GiB Free PE / Size 0 / 0 VG UUID BfPwXl-TBTe-N6Rd-NaJT-xU2T-Ce0V-HqIN8L
--- Volume group --- VG Name VG1 System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 3 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 1 Max PV 0 Cur PV 2 Act PV 2 VG Size 39.99 GiB PE Size 4.00 MiB Total PE 10238 Alloc PE / Size 5119 / 20.00 GiB Free PE / Size 5119 / 20.00 GiB VG UUID ojpEne-jsFm-uB6R-azHU-zJmt-wP46-JvFeNc
将剩余空间分配到逻辑卷LV1,注意+不能省,加号代表加空间,而不带加号代表就分配这么多
1 2 3
linux-wugz:/home/lengqing # lvextend -l +5119 /dev/VG1/LV1 Size of logical volume VG1/LV1 changed from 20.00 GiB (5119 extents) to 39.99 GiB (10238 extents). Logical volume VG1/LV1 successfully resized.
linux-wugz:/home/lengqing # lvreduce -L 15G /dev/VG1/LV1 -t TEST MODE: Metadata will NOT be updated and volumes will not be (de)activated. WARNING: Reducing active logical volume to 15.00 GiB. THIS MAY DESTROY YOUR DATA (filesystem etc.) Do you really want to reduce VG1/LV1? [y/n]: y Size of logical volume VG1/LV1 changed from 39.99 GiB (10238 extents) to 15.00 GiB (3840 extents). Logical volume VG1/LV1 successfully resized.
linux-wugz:/home/lengqing # lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert LV1 VG1 -wi-ao---- 39.99g root system -wi-ao---- 15.99g linux-wugz:/home/lengqing # lvdisplay --- Logical volume --- LV Path /dev/system/root LV Name root VG Name system LV UUID fsZvJJ-NCk9-rHvR-rSOh-80tK-9GxZ-H5BRSw LV Write Access read/write LV Creation host, time install, 2019-10-04 00:06:45 +0800 LV Status available # open 1 LV Size 15.99 GiB Current LE 4093 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 1024 Block device 254:0
--- Logical volume --- LV Path /dev/VG1/LV1 LV Name LV1 VG Name VG1 LV UUID xAccOh-PRJd-jtuR-jx7F-F9Qr-N3nw-Cxm7yh LV Write Access read/write LV Creation host, time linux-wugz, 2019-12-02 02:22:10 +0800 LV Status available # open 1 LV Size 39.99 GiB Current LE 10238 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 1024 Block device 254:1
首先调整文件系统,先缩减逻辑卷到比文件系统小,文件系统大概也保不住
1 2 3 4
linux-wugz:/home/lengqing # resize2fs /dev/mapper/VG1-LV1 15G resize2fs 1.43.8 (1-Jan-2018) Resizing the filesystem on /dev/mapper/VG1-LV1 to 3932160 (4k) blocks. The filesystem on /dev/mapper/VG1-LV1 is now 3932160 (4k) blocks long.
linux-wugz:/home/lengqing # lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert LV1 VG1 -wi-a----- 15.00g root system -wi-ao---- 15.99g linux-wugz:/home/lengqing # lvdisplay --- Logical volume --- LV Path /dev/system/root LV Name root VG Name system LV UUID fsZvJJ-NCk9-rHvR-rSOh-80tK-9GxZ-H5BRSw LV Write Access read/write LV Creation host, time install, 2019-10-04 00:06:45 +0800 LV Status available # open 1 LV Size 15.99 GiB Current LE 4093 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 1024 Block device 254:0
--- Logical volume --- LV Path /dev/VG1/LV1 LV Name LV1 VG Name VG1 LV UUID xAccOh-PRJd-jtuR-jx7F-F9Qr-N3nw-Cxm7yh LV Write Access read/write LV Creation host, time linux-wugz, 2019-12-02 02:22:10 +0800 LV Status available # open 0 LV Size 15.00 GiB Current LE 3840 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 1024 Block device 254:1
linux-wugz:/home/lengqing # vgdisplay --- Volume group --- VG Name system System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 2 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 1 Max PV 0 Cur PV 1 Act PV 1 VG Size 15.99 GiB PE Size 4.00 MiB Total PE 4093 Alloc PE / Size 4093 / 15.99 GiB Free PE / Size 0 / 0 VG UUID BfPwXl-TBTe-N6Rd-NaJT-xU2T-Ce0V-HqIN8L
--- Volume group --- VG Name VG1 System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 5 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 0 Max PV 0 Cur PV 2 Act PV 2 VG Size 39.99 GiB PE Size 4.00 MiB Total PE 10238 Alloc PE / Size 3840 / 15.00 GiB Free PE / Size 6398 / 24.99 GiB VG UUID ojpEne-jsFm-uB6R-azHU-zJmt-wP46-JvFeNc
gpg --help gpg (GnuPG) 2.2.5 libgcrypt 1.8.2 Copyright (C) 2018 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
Syntax: gpg [options] [files] Sign, check, encrypt or decrypt Default operation depends on the input data
指令: -s, --sign make a signature --clear-sign make a clear text signature -b, --detach-sign 生成一份分离的签名 -e, --encrypt 加密数据 -c, --symmetric 仅使用对称加密 -d, --decrypt 解密数据(默认) --verify 验证签名 -k, --list-keys 列出密钥 --list-signatures 列出密钥和签名 --check-signatures 列出并检查密钥签名 --fingerprint 列出密钥和指纹 -K, --list-secret-keys 列出私钥 --generate-key 生成一副新的密钥对 --quick-generate-key quickly generate a new key pair --quick-add-uid quickly add a new user-id --quick-revoke-uid quickly revoke a user-id --quick-set-expire quickly set a new expiration date --full-generate-key full featured key pair generation --generate-revocation 生成一份吊销证书 --delete-keys 从公钥钥匙环里删除密钥 --delete-secret-keys 从私钥钥匙环里删除密钥 --quick-sign-key quickly sign a key --quick-lsign-key quickly sign a key locally --sign-key 为某把密钥添加签名 --lsign-key 为某把密钥添加本地签名 --edit-key 编辑某把密钥或为其添加签名 --change-passphrase change a passphrase --export 导出密钥 --send-keys 把密钥导出到某个公钥服务器上 --receive-keys 从公钥服务器上导入密钥 --search-keys 在公钥服务器上搜寻密钥 --refresh-keys 从公钥服务器更新所有的本地密钥 --import 导入/合并密钥 --card-status 打印卡状态 --edit-card 更改卡上的数据 --change-pin 更改卡的 PIN --update-trustdb 更新信任度数据库 --print-md print message digests --server run in server mode --tofu-policy VALUE set the TOFU policy for a key
选项: -a, --armor 输出经 ASCII 封装 -r, --recipient USER-ID encrypt for USER-ID -u, --local-user USER-ID use USER-ID to sign or decrypt -z N set compress level to N (0 disables) --textmode 使用标准的文本模式 -o, --output FILE write output to FILE -v, --verbose 详细模式 -n, --dry-run 不做任何改变 -i, --interactive 覆盖前先询问 --openpgp 行为严格遵循 OpenPGP 定义
(请参考在线说明以获得所有命令和选项的完整清单)
Examples:
-se -r Bob [file] sign and encrypt for user Bob --clear-sign [file] make a clear text signature --detach-sign [file] make a detached signature --list-keys [names] show keys --fingerprint [names] show fingerprints
gpg --full-generate-key gpg (GnuPG) 2.2.5; Copyright (C) 2018 Free Software Foundation, Inc. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
请选择您要使用的密钥种类: (1) RSA and RSA (default) (2) DSA and Elgamal (3) DSA (仅用于签名) (4) RSA (仅用于签名) 您的选择? RSA 密钥长度应在 1024 位与 4096 位之间。 您想要用多大的密钥尺寸?(2048) 您所要求的密钥尺寸是 2048 位 请设定这把密钥的有效期限。 0 = 密钥永不过期 <n> = 密钥在 n 天后过期 <n>w = 密钥在 n 周后过期 <n>m = 密钥在 n 月后过期 <n>y = 密钥在 n 年后过期 密钥的有效期限是?(0) 密钥永远不会过期 以上正确吗?(y/n)y
You need a user ID to identify your key; the software constructs the user ID from the Real Name, Comment and Email Address in this form: "Heinrich Heine (Der Dichter) <[email protected]>"
gpg --edit-key FD88ED069146EA37 gpg (GnuPG) 2.2.5; Copyright (C) 2018 Free Software Foundation, Inc. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
* The 'sign' command may be prefixed with an 'l' for local signatures (lsign), a 't' for trust signatures (tsign), an 'nr' for non-revocable signatures (nrsign), or any combination thereof (ltsign, tnrsign, etc.).