Cheat sheet
parted -l fix fix fdisk /dev/sda d 3 n 3 t 3 Linux LVM w reboot pvresize /dev/sda3 lvresize -l +100%FREE /dev/mapper/centos-root xfs_growfs /dev/mapper/centos-root
Detailed output
[root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos-root 98G 836M 97G 1% / devtmpfs 896M 0 896M 0% /dev tmpfs 906M 0 906M 0% /dev/shm tmpfs 906M 8.3M 898M 1% /run tmpfs 906M 0 906M 0% /sys/fs/cgroup /dev/sda2 494M 114M 380M 24% /boot /dev/sda1 200M 9.5M 191M 5% /boot/efi tmpfs 182M 0 182M 0% /run/user/0 [root@localhost ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda3 centos lvm2 a-- 99.31g 4.00m [root@localhost ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root centos -wi-ao---- 97.31g swap centos -wi-ao---- 2.00g [root@localhost ~]# lvdisplay --- Logical volume --- LV Path /dev/centos/root LV Name root VG Name centos LV UUID dP1AgA-0tzB-yOmy-ecKu-XWBK-PA7H-JaLAQL LV Write Access read/write LV Creation host, time localhost.localdomain, 2017-02-16 05:05:09 -0500 LV Status available # open 1 LV Size 97.31 GiB Current LE 24911 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:0 --- Logical volume --- LV Path /dev/centos/swap LV Name swap VG Name centos LV UUID 70p9Ai-vl24-FdLP-1shr-ORns-btb0-B4z34S LV Write Access read/write LV Creation host, time localhost.localdomain, 2017-02-16 05:05:10 -0500 LV Status available # open 2 LV Size 2.00 GiB Current LE 512 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:1 [root@localhost ~]# fdisk -l Disk /dev/sda: 214.7 GB, 214748364800 bytes, 419430400 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 Disk label type: dos Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/sda1 1 209715199 104857599+ ee GPT Partition 1 does not start on physical sector boundary. Disk /dev/mapper/centos-root: 104.5 GB, 104484306944 bytes, 204070912 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 Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 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 # PRESS F BUTTON TWICE [root@localhost ~]# parted -l Error: The backup GPT table is not at the end of the disk, as it should be. This might mean that another operating system believes the disk is smaller. Fix, by moving the backup to the end (and removing the old backup)?
Fix/Ignore/Cancel? F
Warning: Not all of the space available to /dev/sda appears to be used, you can fix the GPT to use all of the space (an extra 209715200 blocks) or continue with the current
setting?
Fix/Ignore? F
Model: Msft Virtual Disk (scsi) Disk /dev/sda: 215GB Sector size (logical/physical): 512B/4096B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 211MB 210MB fat16 EFI System Partition boot 2 211MB 735MB 524MB xfs 3 735MB 107GB 107GB lvm Model: Linux device-mapper (linear) (dm) Disk /dev/mapper/centos-swap: 2147MB Sector size (logical/physical): 512B/4096B Partition Table: loop Disk Flags: Number Start End Size File system Flags 1 0.00B 2147MB 2147MB linux-swap(v1) Model: Linux device-mapper (linear) (dm) Disk /dev/mapper/centos-root: 104GB Sector size (logical/physical): 512B/4096B Partition Table: loop Disk Flags: Number Start End Size File system Flags 1 0.00B 104GB 104GB xfs [root@localhost ~]# fdisk /dev/sda WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion. 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): p Disk /dev/sda: 214.7 GB, 214748364800 bytes, 419430400 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 Disk label type: gpt # Start End Size Type Name 1 2048 411647 200M EFI System EFI System Partition 2 411648 1435647 500M Microsoft basic 3 1435648 209713151 99.3G Linux LVM Command (m for help): d Partition number (1-3, default 3): 3 Partition 3 is deleted Command (m for help): n Partition number (3-128, default 3): 3 First sector (34-419430366, default 1435648): Last sector, +sectors or +size{K,M,G,T,P} (1435648-419430366, default 419430366): Created partition 3 Command (m for help): t Partition number (1-3, default 3): 3 Partition type (type L to list all types): L 1 EFI System C12A7328-F81F-11D2-BA4B-00A0C93EC93B 2 MBR partition scheme 024DEE41-33E7-11D3-9D69-0008C781F39F 3 BIOS boot partition 21686148-6449-6E6F-744E-656564454649 4 Microsoft reserved E3C9E316-0B5C-4DB8-817D-F92DF00215AE 5 Microsoft basic data EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 6 Microsoft LDM metadata 5808C8AA-7E8F-42E0-85D2-E1E90434CFB3 7 Microsoft LDM data AF9B60A0-1431-4F62-BC68-3311714A69AD 8 Windows recovery evironmnet DE94BBA4-06D1-4D40-A16A-BFD50179D6AC 9 IBM General Parallel Fs 37AFFC90-EF7D-4E96-91C3-2D7AE055B174 10 HP-UX data partition 75894C1E-3AEB-11D3-B7C1-7B03A0000000 11 HP-UX service partition E2A1E728-32E3-11D6-A682-7B03A0000000 12 Linux filesystem 0FC63DAF-8483-4772-8E79-3D69D8477DE4 13 Linux RAID A19D880F-05FC-4D3B-A006-743F0F84911E 14 Linux swap 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F 15 Linux LVM E6D6D379-F507-44C2-A23C-238F2A3DF928 16 Linux reserved 8DA63339-0007-60C0-C436-083AC8230908 17 FreeBSD data 516E7CB4-6ECF-11D6-8FF8-00022D09712B 18 FreeBSD boot 83BD6B9D-7F41-11DC-BE0B-001560B84F0F 19 FreeBSD swap 516E7CB5-6ECF-11D6-8FF8-00022D09712B 20 FreeBSD UFS 516E7CB6-6ECF-11D6-8FF8-00022D09712B 21 FreeBSD ZFS 516E7CBA-6ECF-11D6-8FF8-00022D09712B 22 FreeBSD Vinum 516E7CB8-6ECF-11D6-8FF8-00022D09712B 23 Apple HFS/HFS+ 48465300-0000-11AA-AA11-00306543ECAC 24 Apple UFS 55465300-0000-11AA-AA11-00306543ECAC 25 Apple RAID 52414944-0000-11AA-AA11-00306543ECAC 26 Apple RAID offline 52414944-5F4F-11AA-AA11-00306543ECAC 27 Apple boot 426F6F74-0000-11AA-AA11-00306543ECAC 28 Apple label 4C616265-6C00-11AA-AA11-00306543ECAC 29 Apple TV recovery 5265636F-7665-11AA-AA11-00306543ECAC 30 Apple Core storage 53746F72-6167-11AA-AA11-00306543ECAC 31 Solaris boot 6A82CB45-1DD2-11B2-99A6-080020736631 32 Solaris root 6A85CF4D-1DD2-11B2-99A6-080020736631 33 Solaris /usr & Apple ZFS 6A898CC3-1DD2-11B2-99A6-080020736631 34 Solaris swap 6A87C46F-1DD2-11B2-99A6-080020736631 35 Solaris backup 6A8B642B-1DD2-11B2-99A6-080020736631 36 Solaris /var 6A8EF2E9-1DD2-11B2-99A6-080020736631 37 Solaris /home 6A90BA39-1DD2-11B2-99A6-080020736631 38 Solaris alternate sector 6A9283A5-1DD2-11B2-99A6-080020736631 39 Solaris reserved 1 6A945A3B-1DD2-11B2-99A6-080020736631 40 Solaris reserved 2 6A9630D1-1DD2-11B2-99A6-080020736631 41 Solaris reserved 3 6A980767-1DD2-11B2-99A6-080020736631 42 Solaris reserved 4 6A96237F-1DD2-11B2-99A6-080020736631 43 Solaris reserved 5 6A8D2AC7-1DD2-11B2-99A6-080020736631 44 NetBSD swap 49F48D32-B10E-11DC-B99B-0019D1879648 45 NetBSD FFS 49F48D5A-B10E-11DC-B99B-0019D1879648 46 NetBSD LFS 49F48D82-B10E-11DC-B99B-0019D1879648 47 NetBSD concatenated 2DB519C4-B10E-11DC-B99B-0019D1879648 48 NetBSD encrypted 2DB519EC-B10E-11DC-B99B-0019D1879648 49 NetBSD RAID 49F48DAA-B10E-11DC-B99B-0019D1879648 50 ChromeOS kernel FE3A2A5D-4F32-41A7-B725-ACCC3285A309 51 ChromeOS root fs 3CB8E202-3B7E-47DD-8A3C-7FF2A13CFCEC 52 ChromeOS reserved 2E0A753D-9E48-43B0-8337-B15192CB1B5E 53 MidnightBSD data 85D5E45A-237C-11E1-B4B3-E89A8F7FC3A7 54 MidnightBSD boot 85D5E45E-237C-11E1-B4B3-E89A8F7FC3A7 55 MidnightBSD swap 85D5E45B-237C-11E1-B4B3-E89A8F7FC3A7 56 MidnightBSD UFS 0394Ef8B-237C-11E1-B4B3-E89A8F7FC3A7 57 MidnightBSD ZFS 85D5E45D-237C-11E1-B4B3-E89A8F7FC3A7 58 MidnightBSD Vinum 85D5E45C-237C-11E1-B4B3-E89A8F7FC3A7 Partition type (type L to list all types): 15 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. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks. [root@localhost ~]# fdisk -l WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion. Disk /dev/sda: 214.7 GB, 214748364800 bytes, 419430400 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 Disk label type: gpt # Start End Size Type Name 1 2048 411647 200M EFI System EFI System Partition 2 411648 1435647 500M Microsoft basic 3 1435648 419430366 199.3G Linux LVM Disk /dev/mapper/centos-root: 104.5 GB, 104484306944 bytes, 204070912 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 Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 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
[root@localhost ~]# reboot
[root@localhost ~]# pvresize /dev/sda3 Physical volume "/dev/sda3" changed 1 physical volume(s) resized / 0 physical volume(s) not resized [root@localhost ~]# lvresize -l +100%FREE /dev/mapper/centos-root Size of logical volume centos/root changed from 97.31 GiB (24911 extents) to 197.31 GiB (50512 extents). Logical volume root successfully resized. [root@localhost ~]# xfs_growfs /dev/mapper/centos-root meta-data=/dev/mapper/centos-root isize=256 agcount=4, agsize=6377216 blks = sectsz=4096 attr=2, projid32bit=1 = crc=0 finobt=0 data = bsize=4096 blocks=25508864, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=0 log =internal bsize=4096 blocks=12455, version=2 = sectsz=4096 sunit=1 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 25508864 to 51724288 [root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos-root 198G 837M 197G 1% / devtmpfs 896M 0 896M 0% /dev tmpfs 906M 0 906M 0% /dev/shm tmpfs 906M 8.2M 898M 1% /run tmpfs 906M 0 906M 0% /sys/fs/cgroup /dev/sda2 494M 114M 380M 24% /boot /dev/sda1 200M 9.5M 191M 5% /boot/efi tmpfs 182M 0 182M 0% /run/user/0 [root@localhost ~]#