Ask Your Question
1

shrink partition by empty lvm space

asked 2018-12-21 14:47:56 -0600

tmdag gravatar image

updated 2018-12-22 13:41:44 -0600

Hi! I want to install 2nd distro along side my fedora. It's a laptop with single drive. I already have installation of fedora with boot, swap and lvm which takes 100% of disk space. I managed to shrink down biggest lvm (home), so have have 'free lvm space'.

> resize2fs /dev/fedora/home 320G
> lvreduce -L 350G /dev/fedora/home
> resize2fs /dev/fedora/home

>  pvs
  PV             VG     Fmt  Attr PSize   PFree  
  /dev/nvme0n1p3 fedora lvm2 a--  475.74g <67.97g

> lsblk
NAME            MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
nvme0n1         259:0    0   477G  0 disk 
├─nvme0n1p1     259:1    0   200M  0 part /boot/efi
├─nvme0n1p2     259:2    0     1G  0 part /boot
└─nvme0n1p3     259:3    0 475.8G  0 part 
  ├─fedora-root 253:0    0    50G  0 lvm  /
  ├─fedora-swap 253:1    0   7.8G  0 lvm  [SWAP]
  └─fedora-home 253:2    0   350G  0 lvm  /home

Now, how can I shrink partition by that free lvm space on physical volume nvme0n1p3 ? I've tried using Gparted from liveCD for that task, but I was getting an error:

image description

Archiving volume group "fedora" metadata (seqno 9).
WARNING: /dev/nvme0n1p3: Pretending size is 855164928 not 997705728 sectors.
Resizing volume "/dev/nvme0n1p3" to 855164928 sectors.
Resizing physical volume /dev/nvme0n1p3 from 121790 to 104390 extents.
 /dev/nvme0n1p3: cannot resize to 104390 extents as later ones are allocated.
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2018-12-22 14:23:38 -0600

tmdag gravatar image

updated 2018-12-22 14:29:13 -0600

found my answer here: (https://superuser.com/questions/73446...) what I had to do is move free space to the end of parition:

> pvs -v --segments /dev/nvme0n1p3
  PV             VG     Fmt  Attr PSize   PFree   Start  SSize LV   Start Type   PE Ranges                   
  /dev/nvme0n1p3 fedora lvm2 a--  475.74g <67.97g      0  1990 swap     0 linear /dev/nvme0n1p3:0-1989       
  /dev/nvme0n1p3 fedora lvm2 a--  475.74g <67.97g   1990 89600 home     0 linear /dev/nvme0n1p3:1990-91589   
  /dev/nvme0n1p3 fedora lvm2 a--  475.74g <67.97g  91590 17400          0 free                               
  /dev/nvme0n1p3 fedora lvm2 a--  475.74g <67.97g 108990 12800 root     0 linear /dev/nvme0n1p3:108990-121789

> pvmove --alloc anywhere /dev/nvme0n1p3:108990-121789
  /dev/nvme0n1p3: Moved: 0.05%
  /dev/nvme0n1p3: Moved: 13.64%
  /dev/nvme0n1p3: Moved: 27.18%
  /dev/nvme0n1p3: Moved: 40.77%
  /dev/nvme0n1p3: Moved: 53.30%
  /dev/nvme0n1p3: Moved: 60.37%
  /dev/nvme0n1p3: Moved: 66.26%
  /dev/nvme0n1p3: Moved: 71.84%
  /dev/nvme0n1p3: Moved: 77.28%
  /dev/nvme0n1p3: Moved: 82.55%
  /dev/nvme0n1p3: Moved: 87.74%
  /dev/nvme0n1p3: Moved: 92.86%
  /dev/nvme0n1p3: Moved: 97.85%
  /dev/nvme0n1p3: Moved: 100.00%

> pvs -v --segments /dev/nvme0n1p3
  PV             VG     Fmt  Attr PSize   PFree   Start  SSize LV   Start Type   PE Ranges                  
  /dev/nvme0n1p3 fedora lvm2 a--  475.74g <67.97g      0  1990 swap     0 linear /dev/nvme0n1p3:0-1989      
  /dev/nvme0n1p3 fedora lvm2 a--  475.74g <67.97g   1990 89600 home     0 linear /dev/nvme0n1p3:1990-91589  
  /dev/nvme0n1p3 fedora lvm2 a--  475.74g <67.97g  91590 12800 root     0 linear /dev/nvme0n1p3:91590-104389
  /dev/nvme0n1p3 fedora lvm2 a--  475.74g <67.97g 104390 17400          0 free

Now, I could shrink partition (I have used GParted as it was easy, I didn't have to worry about removing and re-creating partitions again).

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-12-21 14:47:56 -0600

Seen: 37 times

Last updated: Dec 22 '18