LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-11-2016, 11:02 PM   #1
jobart08
Member
 
Registered: Sep 2014
Posts: 68

Rep: Reputation: Disabled
Creating new partition from /var


I recently commissioned a RHEL server and I was made aware of a partition requirement after I was done. I need to create a partition for the software that the client will install.

I have 80GB free from /var and I was wondering if I could reduce its size and create a new partition from the space that I would recover.

Thanks!
 
Old 01-11-2016, 11:16 PM   #2
Elizine
Member
 
Registered: Aug 2015
Posts: 46
Blog Entries: 1

Rep: Reputation: Disabled
Creating new partition from /var

You might need to move the /var to new partition instead of creating a new one. Follow the steps mentions in the link below for the same -
https://outhereinthefield.wordpress....her-partition/
 
Old 01-11-2016, 11:24 PM   #3
berndbausch
Senior Member
 
Registered: Nov 2013
Location: Tokyo
Distribution: Redhat/Centos, Ubuntu, Raspbian, Fedora
Posts: 1,687

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
Quote:
Originally Posted by Elizine View Post
You might need to move the /var to new partition instead of creating a new one. Follow the steps mentions in the link below for the same -
https://outhereinthefield.wordpress....her-partition/
If the OP can do that, it would be easier to just create that partition for the application.

If the server uses LVM, and /var is on an ext filesystem, you can do that by booting into single user mode, shrinking the /var filesystem with resize2fs, then shrinking the logical volume with lvreduce. In that order. I.e., don't shrink the logical volume before shrinking the filesystem.

Be careful not to shrink /var too much though. How much space you need depends on the amount of log data your system is likely to generate, and the configuration of logrotate.

Before you do this, check if there is room in any volume group. The easiest command for that is vgs.

If this is too much for you, first give us a map of your disks and partitions. E.g. the output of commands lsblk, vgs, lvs and fdisk -l.
 
Old 01-11-2016, 11:39 PM   #4
jobart08
Member
 
Registered: Sep 2014
Posts: 68

Original Poster
Rep: Reputation: Disabled
Additional info.

[root@BDOULXXXX var]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 19G 1.1G 18G 6% /
devtmpfs 7.8G 0 7.8G 0% /dev
tmpfs 7.8G 0 7.8G 0% /dev/shm
tmpfs 7.8G 169M 7.6G 3% /run
tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
/dev/mapper/rhel-usr 9.3G 1.4G 8.0G 15% /usr
/dev/mapper/rhel-var 81G 1019M 80G 2% /var
/dev/mapper/rhel-home 19G 1002M 18G 6% /home
tmpfs 1.6G 0 1.6G 0% /run/user/1000
 
Old 01-12-2016, 01:34 AM   #5
berndbausch
Senior Member
 
Registered: Nov 2013
Location: Tokyo
Distribution: Redhat/Centos, Ubuntu, Raspbian, Fedora
Posts: 1,687

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
Quote:
Originally Posted by jobart08 View Post
Additional info.

[root@BDOULXXXX var]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 19G 1.1G 18G 6% /
devtmpfs 7.8G 0 7.8G 0% /dev
tmpfs 7.8G 0 7.8G 0% /dev/shm
tmpfs 7.8G 169M 7.6G 3% /run
tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
/dev/mapper/rhel-usr 9.3G 1.4G 8.0G 15% /usr
/dev/mapper/rhel-var 81G 1019M 80G 2% /var
/dev/mapper/rhel-home 19G 1002M 18G 6% /home
tmpfs 1.6G 0 1.6G 0% /run/user/1000
Good - we can see that you use LVM.

What we don't see is whether there is still room on the hard disk, or in the volume group. The output of fdisk -l and vgs will help us understand that.
 
Old 01-12-2016, 01:38 AM   #6
jobart08
Member
 
Registered: Sep 2014
Posts: 68

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by berndbausch View Post
Good - we can see that you use LVM.

What we don't see is whether there is still room on the hard disk, or in the volume group. The output of fdisk -l and vgs will help us understand that.
Thanks for your help. Vendor says that /var can be reduced to 20GB and allocate the remaining to their application partition.

[root@BDOULXXXX tmp]# fdisk -l

Disk /dev/sda: 146.8 GB, 146780121600 bytes, 286679925 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 262144 bytes
Disk label type: dos
Disk identifier: 0x000934d4

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 39063551 19530752 83 Linux
/dev/sda2 39063552 286679039 123807744 8e Linux LVM

Disk /dev/mapper/rhel-swap: 9999 MB, 9999220736 bytes, 19529728 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 262144 bytes


Disk /dev/mapper/rhel-usr: 9999 MB, 9999220736 bytes, 19529728 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 262144 bytes


Disk /dev/mapper/rhel-home: 20.0 GB, 20002635776 bytes, 39067648 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 262144 bytes


Disk /dev/mapper/rhel-var: 86.8 GB, 86763372544 bytes, 169459712 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 262144 bytes

[root@BDOULXXXX tmp]# vgs
VG #PV #LV #SN Attr VSize VFree
rhel 1 4 0 wz--n- 118.07g 12.00m
 
Old 01-12-2016, 04:26 AM   #7
berndbausch
Senior Member
 
Registered: Nov 2013
Location: Tokyo
Distribution: Redhat/Centos, Ubuntu, Raspbian, Fedora
Posts: 1,687

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
This indicates that there is practically no free space in the volume group:
Code:
[root@BDOULXXXX tmp]# vgs
VG #PV #LV #SN Attr VSize VFree
rhel 1 4 0 wz--n- 118.07g 12.00m
This indicates that you are wasting a lot of space for the root filesystem:
Code:
[root@BDOULXXXX var]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 19G 1.1G 18G 6% /
but it's not easy to change this.

If you or your vendor think that /var can be, say, 15GB, you could just
  • include /var in the root filesystem, i.e. not give it a different filesystem
  • use /dev/mapper/rhel-var for your application (I think LVM allows renaming volumes, too).

Or do as I suggested above - boot into single-user mode, resize the /var filesystem, resize the /var volume, then create a new volume from the freed-up space.
 
Old 01-18-2016, 02:20 AM   #8
jobart08
Member
 
Registered: Sep 2014
Posts: 68

Original Poster
Rep: Reputation: Disabled
I might have given the wrong details for the server. This is the correct server details for the /var that I want to resize.

[root@BDOULXYYYY ~]# df -h
Filesystem Size Used Avail Use Mounted on
/dev/sdb2 19G 1.2G 18G 7% /
devtmpfs 16G 0 16G 0% /dev
tmpfs 16G 0 16G 0% /dev/shm
tmpfs 16G 281M 16G 2% /run
tmpfs 16G 0 16G 0% /sys/fs/cgroup
/dev/mapper/rhel00-usr 9.4G 1.3G 8.1G 14% /usr
/dev/sdb3 782G 1.2G 781G 1% /var
/dev/mapper/rhel00-home 19G 1.9G 17G 10% /home
tmpfs 3.2G 0 3.2G 0% /run/user/1000

[root@BDOULXYYY ~]# vgs
VG #PV #LV #SN Attr VSize VFree
rhel 1 4 0 wz--n- 1.07t 12.00m
rhel00 1 3 0 wz--n- 37.26g 8.00m

[root@BDOULXYYY ~]# fdisk -l

Disk /dev/sdb: 899.9 GB, 899899242496 bytes, 1757615708 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 786432 bytes
Disk label type: dos
Disk identifier: 0x00092631

Device Boot Start End Blocks Id System
/dev/sdb1 1536 78154751 39076608 8e Linux LVM
/dev/sdb2 * 78154752 117216767 19531008 83 Linux
/dev/sdb3 117216768 1757611007 820197120 83 Linux

Disk /dev/sda: 1199.9 GB, 1199865640960 bytes, 2343487580 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 524288 bytes
Disk label type: dos
Disk identifier: 0x0004fdbf

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 39063551 19530752 83 Linux
/dev/sda2 39063552 2343487487 1152211968 8e Linux LVM

Disk /dev/mapper/rhel00-usr: 9999 MB, 9999220736 bytes, 19529728 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 786432 bytes


Disk /dev/mapper/rhel00-swap: 9999 MB, 9999220736 bytes, 19529728 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 786432 bytes


Disk /dev/mapper/rhel00-home: 20.0 GB, 20002635776 bytes, 39067648 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 786432 bytes


Disk /dev/mapper/rhel-home: 20.0 GB, 20002635776 bytes, 39067648 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 524288 bytes


Disk /dev/mapper/rhel-usr: 9999 MB, 9999220736 bytes, 19529728 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 524288 bytes


Disk /dev/mapper/rhel-swap: 9999 MB, 9999220736 bytes, 19529728 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 524288 bytes


Disk /dev/mapper/rhel-var: 1139.8 GB, 1139848249344 bytes, 2226266112 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 524288 bytes
 
  


Reply

Tags
partition, rhel


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Have multiple partitions for /var along with a partition for /var itself useful? JockVSJock Linux - Newbie 13 03-27-2015 08:35 AM
[SOLVED] Problem with sudo after creating new logical volume and mount to /var swilsy Linux - Newbie 8 11-25-2012 11:15 PM
I am creating a website Server what is the best partition for /var /root /home etc. RMLinux Linux - Newbie 3 12-01-2008 08:46 AM
Partition mounting/KDE errors after creating Fat32 Partition BertBert Linux - General 1 07-07-2004 11:59 AM
Newbie Installing Debian3 on m68k w/250M Partition Needs help creating swap partition AppleMac Linux - Newbie 2 11-01-2002 09:45 AM


All times are GMT -5. The time now is 06:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration