Here, we are going to provide all remaining free space of hard disk to /motadata partition.
root@ubuntu:~# df -kh
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg0-root 14G 1.9G 12G 14% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 2.0G 4.0K 2.0G 1% /dev
tmpfs 395M 400K 395M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 2.0G 0 2.0G 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/xvda1 361M 36M 303M 11% /boot
/dev/mapper/vg0-motadata 71G 52M 67G 1% /motadata
root@ubuntu:~# pvs
PV VG Fmt Attr PSize PFree
/dev/xvda2 vg0 lvm2 a-- 129.62g 36.17g
root@ubuntu:~# lvextend /dev/mapper/vg0-motadata /dev/xvda2
Extending logical volume motadata to 107.69 GiB
Logical volume motadata successfully resized
root@ubuntu:~# resize2fs /dev/mapper/vg0-motadata
resize2fs 1.42.9 (4-Feb-2014)
Filesystem at /dev/mapper/vg0-motadata is mounted on /motadata; on-line resizing required
old_desc_blocks = 5, new_desc_blocks = 7
The filesystem on /dev/mapper/vg0-motadata is now 28230656 blocks long.
root@ubuntu:~# df -kh
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg0-root 14G 1.9G 12G 14% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 2.0G 4.0K 2.0G 1% /dev
tmpfs 395M 400K 395M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 2.0G 0 2.0G 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/xvda1 361M 36M 303M 11% /boot
/dev/mapper/vg0-motadata 106G 60M 101G 1% /motadata
Reduce space from /motadata partition.
root@ubuntu:~# lvs
LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
motadata vg0 -wi-ao--- 107.69g
root vg0 -wi-ao--- 14.30g
swap vg0 -wi-ao--- 7.63g
root@ubuntu:~# df -kh
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg0-root 14G 1.9G 12G 14% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 2.0G 4.0K 2.0G 1% /dev
tmpfs 395M 400K 395M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 2.0G 0 2.0G 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/xvda1 361M 36M 303M 11% /boot
/dev/mapper/vg0-motadata 106G 60M 101G 1% /motadata
root@ubuntu:~# umount -v /motadata
/dev/mapper/vg0-motadata has been unmounted
root@ubuntu:~# e2fsck -f /dev/mapper/vg0-motadata
e2fsck 1.42.9 (4-Feb-2014)
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/mapper/vg0-motadata: 27/7061504 files (0.0% non-contiguous), 491233/28230656 blocks
root@ubuntu:~# resize2fs /dev/mapper/vg0-motadata 36G
resize2fs 1.42.9 (4-Feb-2014)
Resizing the filesystem on /dev/mapper/vg0-motadata to 9437184 (4k) blocks.
The filesystem on /dev/mapper/vg0-motadata is now 9437184 blocks long.
root@ubuntu:~# lvreduce -L -36G /dev/mapper/vg0-motadata
WARNING: Reducing active logical volume to 71.69 GiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce motadata? [y/n]: y
Reducing logical volume motadata to 71.69 GiB
Logical volume motadata successfully resized
root@ubuntu:~# resize2fs /dev/vg0/motadata
resize2fs 1.42.9 (4-Feb-2014)
Resizing the filesystem on /dev/vg0/motadata to 18793472 (4k) blocks.
The filesystem on /dev/vg0/motadata is now 18793472 blocks long.
root@ubuntu:~# mount /dev/vg0/motadata /motadata/
root@ubuntu:~# lvs
LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
motadata vg0 -wi-ao--- 71.69g
root vg0 -wi-ao--- 14.30g
swap vg0 -wi-ao--- 7.63g
No comments:
Post a Comment