Change the partitions size

General support questions
Post Reply
jejedu67
Posts: 44
Joined: 2015/12/07 20:01:46

Change the partitions size

Post by jejedu67 » 2019/02/21 21:45:25

Hello :)

I have a dedicated server on Centos 6.9
1 x 240GB SSD

Root has only 20 GB and and sda1 has 20 GB and sda3 has 200 GB.

I want to know if it is possible, without any data loss, to reduce the size of sd3 by 50 GB, and increase the root partition by 50 GB. Indeed, root is 98% full because of databases.

Thank you :)

User avatar
TrevorH
Forum Moderator
Posts: 26862
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Change the partitions size

Post by TrevorH » 2019/02/21 22:04:32

Post the output from the following commands, all run as root:

fdisk -lu /dev/sd[a-z]
pvs
vgs
lvs

and the output from df -m though that can be run as any user.
CentOS 5 died in March 2017 - migrate NOW!
CentOS 6 goes EOL sooner rather than later, get upgrading!
Full time Geek, part time moderator. Use the FAQ Luke

jejedu67
Posts: 44
Joined: 2015/12/07 20:01:46

Re: Change the partitions size

Post by jejedu67 » 2019/02/22 00:46:32

[**********@********** ~]# fdisk -lu /dev/sd[a-z]

Disk /dev/sda: 240.1 GB, 240057409536 bytes
255 heads, 63 sectors/track, 29185 cylinders, total 468862128 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x1466a9d7

Device Boot Start End Blocks Id System
/dev/sda1 * 4096 526335 261120 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 526336 41484287 20478976 83 Linux
/dev/sda3 41484288 467806207 213160960 83 Linux
/dev/sda4 467806208 468852735 523264 82 Linux swap / Solaris


[**********@********** ~]# df -m
Filesystem 1M-blocks Used Available Use% Mounted on
rootfs 19557 17392 1166 94% /
/dev/root 19557 17392 1166 94% /
devtmpfs 7956 1 7956 1% /dev
/dev/sda1 243 14 217 6% /boot
/dev/sda3 204770 2179 192167 2% /home
tmpfs 7989 0 7989 0% /dev/shm
/dev/root 19557 17392 1166 94% /var/named/chroot/etc/named
/dev/root 19557 17392 1166 94% /var/named/chroot/var/named
/dev/root 19557 17392 1166 94% /var/named/chroot/etc/named.conf
/dev/root 19557 17392 1166 94% /var/named/chroot/etc/named.rfc1912.zones
/dev/root 19557 17392 1166 94% /var/named/chroot/etc/rndc.key
/dev/root 19557 17392 1166 94% /var/named/chroot/usr/lib64/bind
/dev/root 19557 17392 1166 94% /var/named/chroot/etc/named.iscdlv.key
/dev/root 19557 17392 1166 94% /var/named/chroot/etc/named.root.key
/dev/root 19557 17392 1166 94% /var/named/chroot/etc/services
/dev/root 19557 17392 1166 94% /var/named/chroot/etc/protocols
/dev/root 19557 17392 1166 94% /var/named/chroot/lib64/libnss_files.so.2


pvs
vgs
lvs
nothing is displayed, but no error message.

User avatar
TrevorH
Forum Moderator
Posts: 26862
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Change the partitions size

Post by TrevorH » 2019/02/22 09:13:01

Unfortunately you're using plain partitions and not the default of LVM so what you want to do is difficult.
CentOS 5 died in March 2017 - migrate NOW!
CentOS 6 goes EOL sooner rather than later, get upgrading!
Full time Geek, part time moderator. Use the FAQ Luke

tyler2016
Posts: 13
Joined: 2019/02/07 16:06:54
Contact:

Re: Change the partitions size

Post by tyler2016 » 2019/02/25 16:06:48

How about you move your data to the other partion and create symlinks where your data was on the small partition

Here is what you MIGHT be able to do if you can't just use the other partition, I haven't resized a root disk outside of LVM, so will someone look over my steps and verify that I didn't miss anything? It is risky because a mistake can leave you hosed.

1. BACKUP EVERYTHING
2. yum clean all;rm -rf /var/cache/yum/x86_64/*
3. STOP ALL SERVICES the server is hosting
4. tune2fs -m 0 /dev/root # or the xfs equivalent-i don't know off hand, but you need the space for now.
5. login directly as root
6. kick everyone off
7. unmount /home
8. mount /dev/sda3 to /mnt
9. copy everything from /mnt to /home
10. unmount /dev/sda3
11. swapoff /dev/sda4
12. delete partions 2, 3 and 4.
13. create partitions 2 as a linux partition and 3 as swap with the sizes you need.
14. comment out your swap and home entries from fstab
15. reboot into single user mode (You need the partition table updated in kernel space, so don't just init s)
16. resize2fs /dev/root
17. mkswap /dev/sda$whatever
18. tune2fs -m 5 /dev/sda2
19. update your /etc/fstab with the new swap device and delete the old home.
20. reboot

Edited to clarify step 13.

jejedu67
Posts: 44
Joined: 2015/12/07 20:01:46

Re: Change the partitions size

Post by jejedu67 » 2019/02/28 22:56:21

Wow it is so hard ...

I think that it's better to install again the server and choose and other partition size ...

Post Reply

Return to “CentOS 6 - General Support”