Knowledgebase
Knowledgebase
Extend or Expand a SATA partition
Posted by Will Kruss on 01 August 2022 12:25 PM

Know the all tricks that extend or expand a SATA partition. This method is only valid for Linux systems where you have purchased SATA space.

This article is only valid for Linux systems where you have purchased SATA space, and then increased the SATA space, and need to extend the existing SATA partition. These instructions will NOT work for extending your main NVME/Flash partition. If you are unsure please contact support and we are happy to do this for you.

Extend Partition and Filesystem

Before we start, let’s check the current disk configuration. /backup mount point is the partition we want to extend. We can see that the partition has 494MB of available space and 401MB is already used. We have already purchased the extra SATA space through the control panel, and we want to extend the partition to 1GB:

[root@foo1 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_foo-LogVol01
                       13G  4.6G  7.7G  38% /
tmpfs                 376M     0  376M   0% /dev/shm
/dev/sda1             485M  105M  355M  23% /boot
/dev/sdb1             494M  402M   67M  86% /backup
Note that the SATA partition is /dev/sdb1 and mounted at /backup

1. Unmount the partition

[root@foo1 ~]# umount /backup
[root@foo1 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_foo-LogVol01
                       13G  4.6G  7.7G  38% /
tmpfs                 376M     0  376M   0% /dev/shm
/dev/sda1             485M  105M  355M  23% /boot

2. Delete the partition

[root@foo1 ~]# fdisk /dev/sdb -c=dos
Command (m for help): c
Switch to dos compatibility mode (this is important as likely the partition starts on 63)

Command (m for help): unit s
If it says "Changing display/entry units to cylinders" then you should type it again until you see "Changing display/entry units to sectors."

Command (m for help): p

Disk /dev/sdb: 64.4 GB, 64424509440 bytes, 125829120 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0xc546eb5a

Device Boot Start End Blocks Id System
/dev/sdb1 2048 83886079 41942016 83 Linux

Note the start sector (2048 usually or sometimes 63)

Command (m for help): d
Selected partition 1
Command (m for help): p
Disk /dev/sdb: 1073 MB, 1073741824 bytes 255 heads, 63 sectors/track, 130 cylinders, total 2097152 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: 0x2dbb9f13   

Device Boot      Start         End      Blocks   Id  System

Command (m for help): w
The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.

3. Create a new (larger) partition

[root@foo1 ~]# fdisk /dev/sdb -c=dos


Command (m for help): c
Switch to dos compatibility mode (this is important as likely the partition starts on 63)

Command (m for help): unit s
If it says "Changing display/entry units to cylinders" then you should type it again until you see "Changing display/entry units to sectors."
 
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First sector (2048-2097151, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151): 
Using default value 2097151

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders, total 2097152 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: 0x2dbb9f13

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     2097151     1047552   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

4. Run fsck on your filesystem

[root@foo1 ~]# e2fsck -f /dev/sdb1
e2fsck 1.41.12 (17-May-2010)
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/sdb1: 16/130560 files (0.0% non-contiguous), 426988/522080 blocks

5. Resize your filesystem with resize2fs

[root@foo1 ~]# resize2fs /dev/sdb1 
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/sdb1 to 1044192 (1k) blocks.
The filesystem on /dev/sdb1 is now 1044192 blocks long.

6. Re-mount extended partition

[root@foo1 ~]# mount /dev/sdb1 /backup
[root@foo1 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_foo-LogVol01
                       13G  4.6G  7.7G  38% /
tmpfs                 376M     0  376M   0% /dev/shm
/dev/sda1             485M  105M  355M  23% /boot
/dev/sdb1             988M  402M  536M  43% /backup

 
Congratulations! The partition was successfully extended, as we can see all of the data was retained!

(0 vote(s))
Helpful
Not helpful