On 2020-05-06 06:12, linux guy wrote:
> I would appreciate them, Ed, just to make sure I'm not missing something.   
> No rush.  Don't get up early. 

I do normally get up early.  But had some other things to take care of first.

In my case I don't have separate / and /home.  So, I am going to decrease / and 
increase swap.
Decreasing is more dangerous than Increasing.  You'll be decreasing /home and 
increasing /.

This is the system normally booted before modification.

[egreshko@f31m ~]$ df -t ext4
Filesystem                              1K-blocks    Used Available Use% 
Mounted on
/dev/mapper/fedora_localhost--live-root  17410832 7037660   9465704  43% /
/dev/vda1                                  999320  263436    667072  29% /boot

[egreshko@f31m ~]$ swapon
NAME      TYPE      SIZE USED PRIO
/dev/dm-1 partition   2G   0B   -2

[egreshko@f31m ~]$ sudo lvs
  LV   VG                    Attr       LSize   Pool Origin Data%  Meta%  Move 
Log Cpy%Sync Convert
  root fedora_localhost-live -wi-ao---- <17.00g                                 
                  
  swap fedora_localhost-live -wi-ao----   2.00g

My goal is to reduce / by 2 GB and add to swap.  So, I then boot from the F31 
Mate Spin image and
do the following.

[root@localhost-live ~]# e2fsck -ff /dev/fedora_localhost-live/root
e2fsck 1.45.3 (14-Jul-2019)
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 summary information
/dev/fedora_localhost-live/root: 226041/1114112 files (0.2% non-contiguous), 
1855851/4455424 blocks

I now resize the filesystem to 15GB.  Failure to resize the FS will result in 
disaster.

[root@localhost-live ~]# resize2fs /dev/fedora_localhost-live/root 15G
resize2fs 1.45.3 (14-Jul-2019)
Resizing the filesystem on /dev/fedora_localhost-live/root to 3932160 (4k) 
blocks.
The filesystem on /dev/fedora_localhost-live/root is now 3932160 (4k) blocks 
long.

Make the LV inactive

[root@localhost-live ~]# lvchange -a n /dev/fedora_localhost-live/root

Now, shrink the LV....but not as much as the FS. 
I can't recall the reason for this....but that is what I've done in the past. 
0.5 difference is probably excessive
but....

[root@localhost-live ~]# lvresize /dev/fedora_localhost-live/root -L 15.5GB
  Size of logical volume fedora_localhost-live/root changed from <17.00 GiB 
(4351 extents) to 15.50 GiB (3968 extents).
  Logical volume fedora_localhost-live/root successfully resized.

Activate the LV

[root@localhost-live ~]# lvchange -a y /dev/fedora_localhost-live/root

And run a check on the new size

[root@localhost-live ~]# e2fsck -ff /dev/fedora_localhost-live/root
e2fsck 1.45.3 (14-Jul-2019)
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 summary information
/dev/fedora_localhost-live/root: 226041/983040 files (0.3% non-contiguous), 
1846611/3932160 blocks

Then I want to increase swap.  But I intentionally make it too big to find out 
what is really available.
This is where you'd increase /.

[root@localhost-live ~]# lvresize /dev/fedora_localhost-live/swap -L 4GB
  Insufficient free space: 512 extents needed, but only 383 available

So then I do this.  In this case I'm adding extents rather than giving a 
specific size.

[root@localhost-live ~]# lvresize /dev/fedora_localhost-live/swap -l +383
  Size of logical volume fedora_localhost-live/swap changed from 2.00 GiB (512 
extents) to <3.50 GiB (895 extents).
  Logical volume fedora_localhost-live/swap successfully resized.

I then boot normally and see.

[egreshko@f31m ~]$ df -t ext4
Filesystem                              1K-blocks    Used Available Use% 
Mounted on
/dev/mapper/fedora_localhost--live-root  15350728 7033772   7514144  49% /
/dev/vda1                                  999320  263436    667072  29% /boot

[egreshko@f31m ~]$ sudo lvs
  LV   VG                    Attr       LSize  Pool Origin Data%  Meta%  Move 
Log Cpy%Sync Convert
  root fedora_localhost-live -wi-ao---- 15.50g                                  
                 
  swap fedora_localhost-live -wi-ao---- <3.50g

[egreshko@f31m ~]$ sudo swapon
NAME      TYPE      SIZE USED PRIO
/dev/dm-1 partition   2G   0B   -2

So, / is now smaller.  But I have to fix swap manually.  This wouldn't be 
needed with /home

Originally

root@f31m ~]# swapon
NAME      TYPE      SIZE USED PRIO
/dev/dm-1 partition   2G   0B   -2

Turn it off
[root@f31m ~]# swapoff /dev/dm-1

Remake it
[root@f31m ~]# mkswap /dev/dm-1
mkswap: /dev/dm-1: warning: wiping old swap signature.
Setting up swapspace version 1, size = 3.5 GiB (3753897984 bytes)
no label, UUID=bfc61bdb-3252-42e1-9b4c-e72b154c6c30

And now the new size

[root@f31m ~]# swapon /dev/dm-1
[root@f31m ~]# swapon
NAME      TYPE      SIZE USED PRIO
/dev/dm-1 partition 3.5G   0B   -2


-- 
The key to getting good answers is to ask good questions.
_______________________________________________
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org

Reply via email to