0

So I have a need to expand a partition (/tmp) on a system and not understanding exactly how to proceed with this (I did not initially set the partitions up).

The following commands show:

fdisk -l
Disk /dev/sda: 4798.6 GB, 4798552211456 bytes, 9372172288 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 label type: gpt

#         Start          End    Size  Type            Name
1         2048       411647    200M  EFI System      EFI System Partition
2       411648      1435647    500M  Microsoft basic
3      1435648    395407359  187.9G  Microsoft basic
4    395407360    446607359   24.4G  Microsoft basic
5    446607360    497807359   24.4G  Microsoft basic
6    497807360    549007359   24.4G  Microsoft basic
7    549007360    569487359    9.8G  Microsoft basic
8    569487360    585871359    7.8G  Linux swap
9    585871360   6585871360    2.8T  Linux filesyste

The various partitions I have created are:

/dev/sda3 on / type xfs (rw,relatime,attr2,inode64,noquota)
/dev/sda4 on /var type xfs (rw,relatime,attr2,inode64,noquota)
/dev/sda9 on /home type ext4 (rw,relatime,data=ordered)
/dev/sda7 on /tmp type xfs (rw,relatime,attr2,inode64,noquota)
/dev/sda2 on /boot type xfs (rw,relatime,attr2,inode64,noquota)
/dev/sda1 on /boot/efi type vfat (rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=ascii,shortname=winnt,errors=remount-ro)
/dev/sda5 on /var/log type xfs     (rw,relatime,attr2,inode64,noquota)
/dev/sda6 on /var/log/audit type xfs (rw,relatime,attr2,inode64,noquota)

I see the following sizes allocated:

Filesystem   Size  Used Avail Use% Mounted on
/dev/sda3    188G  123G   66G  66% /
/dev/sda4    25G  3.8G   21G  16% /var
/dev/sda9    2.8T  224G  2.4T   9% /home
/dev/sda7    9.8G   46M  9.8G   1% /tmp
/dev/sda2    497M  161M  337M  33% /boot
/dev/sda1    200M  9.8M  191M   5% /boot/efi
/dev/sda5    25G  151M   25G   1% /var/log
/dev/sda6    25G   71M   25G   1% /var/log/audit

From what I can see, /dev/sda8 must have been deleting and recreated from an XFS to EXT4 partition.

I need to expand /dev/sda7 to have more space and from a quick tally, /dev/sda is roughly 5TB and we are only using a bit over 3TB for /dev/sda1 --> /dev/sda9. Leads me to believe I have 1-2TB left sitting on /dev/sda. I need to grow this without losing data and preferably without downtime.

I "think" I will need to create another partition (/dev/sda10) and assign this with the desired space. From there I would run "mkfs -t ext4 /dev/sda10" to assign it a filesystem. Then update /etc/fstab to point /dev/sda10 to /tmp (maybe mount /dev/sda10 first and copy all of /tmp over?).

Am I on the correct path for this? Thanks

1 Answer 1

1

Your mount and df outputs confirm that /tmp is a mounted filesystem residing on /dev/sda7.

Your fdisk output shows that /dev/sda7 is immediately followed on /dev/sda by a partition /dev/sda8 of type "Linux Swap". Chances are this partition is in use as a swap partition. (You can verify that with the swapon command.) If you want to grow /dev/sda7 in place you'll have to remove /dev/sda8 first.

Your fdisk output also shows that the total size of the disk is 9372172288 sectors, but the last partition /dev/sda9 ends at sector 6585871360. So there is 9372172288 - 6585871360 = 2786300928 sectors, or 1.3 TB, of unpartitioned free space after the last partition.

This leaves you with two possible avenues:

a) Move the swap partition to the unpartitioned space and extend the /tmp partition to the space formerly occupied by the swap partition. You can do that without downtime, by first creating a new swap partition /dev/sda10 of the required size starting at sector 6585871360, activating it with swapon /dev/sda10, then deactivating the old swap partition with swapoff /dev/sda7. After the old swap partition has drained you can delete partition 8 and extend partition 7 to that space. This will give you a /tmp partition of at most 585871360 - 549007360 = 36864000 sectors, or 17.6 GB.

b) Move the /tmp partition to the unpartitioned space. This will allow you to extend it up to 1.3 TB. It will however require a (short) downtime since you'll need to unmount the current /tmp partition which is not possible while the system is running.

1
  • Thanks. Created sda10 and just copied data over then remounted tmp to this instead. Appreciate the assistance!
    – IT_User
    Feb 14, 2022 at 21:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .