Creating /home partition on existing server without reformatting and adding new Disks

Latest response

Hello,
We have a server with two disks (2 Disks) of 300 GB each, configured as RAID 1 (hardware raid). The vendor created default partitions and did not create /home partition while installing RHEL 7.2. When we asked them to create /home so that we can give quotas to users , they said they need another two disks and can not use gparted to create new partition as it is RAID 1.
Our question is there a way to create /home with adding disks or reformating disks. ? can Virtual file systems be used?

Responses

You could create a large file, make a filesystem on that file, and mount the filesystem at /home

Thank you, Is there a guide or list of commands that will enable us to create this large file, make a filesystem, mount the filesystem at /home and create quotas on it.?

Hi Majid Ali Syed Amjad Ali Sayed,

May I demonstrate the simple process... Done on RHEL7 system using EXT4 file system type. It creates a sparse file, then file system, and then enables quotas.

# cd /opt

# truncate -s 512M newfs

# mke2fs -t ext4 -m 1 newfs
mke2fs 1.42.9 (28-Dec-2013)
newfs is not a block special device.
Proceed anyway? (y,n) y
Discarding device blocks: done                            
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
32768 inodes, 131072 blocks
1310 blocks (1.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=134217728
4 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
        32768, 98304
Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

# mkdir /newfs

# mount -o loop,usrjquota=aquota.user,grpjquota=aquota.grp,jqfmt=vfsv1 /opt/newfs /newfs

# df -h /newfs
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop0      488M  780K  472M   1% /newfs

# quotacheck -cug -F vfsv1 /newfs 

Regards,

Dusan Baljevic (amateur radio VK2COT)

My example uses journal quota, by the way...

Dusan Baljevic

Thank you dusan So in the above example I can replace mount point from newfs to home.

Secondly can this newfs be NFS mounted on other systems and be shared.

Thirdly Are there any disadvantages of using this method against buying a new disk and partitioning it?

Hi again,

Yes, you can change the mount point to any other name. Just watch out that nobody is currently using /home as part of their login session. If they are, ask them to log off, move files in /home to some other location temporarily, then create a new file system, and move the files back.

Having new disks is always going to be the best option.

And yes, you can use NFS. Here is a simple example by using NFSv3 on the same machine:

# cat /etc/exports
/newfs            *(ro,insecure,all_squash)

# mkdir /nfsclient

# mount -t nfs myhost.dom:/newfs /nfsclient

# df -h |grep newfs
/dev/loop0                        488M  796K  472M   1% /newfs
myhost.dom:/newfs        488M     0  472M   0% /nfsclient

Disadvantages of loopback file system built from file, the quick summary I could think of:

a) Uses disk space from another already-assigned file system.

b) One needs to be mindful how to back it up and restore files if required.

c) Accidental removal of files. This worked without any warning:

# rm newfs 
rm: remove regular file ‘newfs’? y

# ls /opt/newfs
ls: cannot access /opt/newfs: No such file or directory

#df -h |grep newfs
/dev/loop0                           488M  796K  472M   1% /newfs
myhost.dom:/newfs        488M     0  472M   0% /nfsclient

I did not have time to check the consequences of this deletion.

Regards,

Dusan Baljevic

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.