Re: Resizing partitions on a headless server
csanyipal@gmail.com a écrit :
>
> Finally, I solved the problem by doing the followings:
> # lvresize --size 455.5G /dev/mapper/bubba-storage
> # e2fsck -f /dev/mapper/bubba-storage
Glad you were lucky.
> Now, I can to use parted to resize my partitions.
> What is my goal?
>
> Filesystem Size Used Avail Use% Mounted on
> /dev/root 9.2G 8.0G 815M 91% /
> devtmpfs 125M 0 125M 0% /dev
> tmpfs 125M 4.0K 125M 1% /dev/shm
> tmpfs 125M 5.6M 120M 5% /run
> tmpfs 5.0M 0 5.0M 0% /run/lock
> tmpfs 125M 0 125M 0% /sys/fs/cgroup
> /dev/mapper/bubba-storage 449G 8.2G 418G 2% /home
> tmpfs 25M 0 25M 0% /run/user/1001
>
> # fdisk -l
>
> Device Boot Start End Sectors Size Id Type
> /dev/sda1 63 19551104 19551042 9.3G 83 Linux
> /dev/sda2 19551105 974647484 955096380 455.4G 8e Linux LVM
> /dev/sda3 974647485 976768064 2120580 1G 82 Linux swap / Solaris
>
> # lvs
> LV VG Attr LSize Pool Origin Data% Meta% Move Log
> Cpy%Sync Convert
> storage bubba -wi-ao---- 455.40g
>
> # pvs
> PV VG Fmt Attr PSize PFree
> /dev/sda2 bubba lvm2 a-- 455.42g 20.00m
I'm curious : what's the use of LVM if you have only one LV taking all
the space in the VG, and plain partitions outside the VG ?
> As one can see, my /dev/root partition is almost full.
> I want to increase /dev/root partition to be maximum available size and
> decrease /home partition to only 20 GiB.
>
> So can be the /var directory large enough to encompass the web and other
> contents.
>
> What are your advises, what do I do to reach my goal?
Do not resize partitions. This is difficult and risky. Use LVM.
Reduce the filesystem in the LV and the LV to a adequate size (without
mistake this time).
Create a new LV of adequate size. DON'T take all the available space in
the VG. Leave some space for future needs. Increasing a LV and its
filesystem is easy and can be done online while it's mounted. Reducing
is risky, as you experienced.
Move the data in /var from the root filesystem to the new LV and mount
it on /var. Update /etc/fstab accordingly.
Or :
Create a var directory in /home
Move the data in /var to /home/var
Bind-mount /home/var on /var and update /etc/fstab.
Reply to: