Skip to main content

beforeBefore I extended an ext4 filesystem from the free space of the beginning of the block device, I performed a search to see how others did it and it looks like your question was the closest match I could find. But the provided answer is not exactly what you have asked or I needed. Because I have just managed to resize/grow from the beginning of the disk successfully, I decided to share my thoughts.

The procedure in a nutshell: 1.) The filesystem to be grown/extended: ext4 filesystem on a partition starting at 1026048 sector and ending at the end of the block device (/dev/sdb/dev/sdb in my case) 2.) To allocate the unused sectors inat the beginning of the block device for this filesystem, I had to move the data using 'dd'dd to the start of my future/new partition 3.) Delete the old partition and recreate it with the new start sector 4.) resize2fsresize2fs to extend to the new partition size

Commands used and details on the method:


Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
(above info revealed by fdisk -l /dev/sdb)
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes

(Above info revealed by fdisk -l /dev/sdb.)

Calculate 'dd'dd seek and skip offsets and bsbs (in our case bsbs matches sector size):

# dd seek=2048 skip=1026048 if=/dev/sdb bs=512 of=/dev/sdb

# dd seek=2048 skip=1026048 if=/dev/sdb bs=512 of=/dev/sdb

So we want to move our data from sector 1026048 and onwards to start at sector 2048 where our new partition is going to start. We should not be able to lose anything as the more we read from the input, the further we get, so by the time we start overwriting with the output  (it will eventually reach sector 1026048), we would have copied what was there at the beginning of the device and move on.

thenThen use 'fdisk'fdisk to delete the old partition and recreate it to start at sector 2048.

Once that is done, you can run:


# partprobe /dev/sdb or
# blockdev --rereadpt /dev/sdb
# resize2fs /dev/sdb # partprobe /dev/sdb or
# blockdev --rereadpt /dev/sdb
# resize2fs /dev/sdb<num>

to extend the filesystem.

Please, always make backups of your data before doing low-level procedures like that. Failure in some of the steps or system crash or power failure will result in data loss. This is an example which describes a single partition on a block device, your. Your setups may vary, so do not use as it is, learn. Learn and understand how it works, then test, and if you get the expected results, run on your live data at your own risk!

Hope that helps others as well. Feedback and where to improve/make more verbose is welcome.

Thank you!

before I extended an ext4 filesystem from the free space of the beginning of the block device I performed a search to see how others did it and it looks like your question was the closest match I could find. But the provided answer is not exactly what you have asked or I needed. Because I have just managed to resize/grow from the beginning of the disk successfully, I decided to share my thoughts.

The procedure in a nutshell: 1.) The filesystem to be grown/extended: ext4 filesystem on a partition starting at 1026048 sector and ending at the end of the block device (/dev/sdb in my case) 2.) To allocate the unused sectors in the beginning of the block device for this filesystem, I had to move the data using 'dd' to the start of my future/new partition 3.) Delete the old partition and recreate it with the new start sector 4.) resize2fs to extend to the new partition size

Commands used and details on the method:


Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
(above info revealed by fdisk -l /dev/sdb)

Calculate 'dd' seek and skip offsets and bs(in our case bs matches sector size):

# dd seek=2048 skip=1026048 if=/dev/sdb bs=512 of=/dev/sdb

So we want to move our data from sector 1026048 and onwards to start at sector 2048 where our new partition is going to start. We should not be able to lose anything as the more we read from the input, the further we get, so by the time we start overwriting with the output(it will eventually reach sector 1026048), we would have copied what was there at the beginning of the device and move on.

then use 'fdisk' to delete the old partition and recreate it to start at sector 2048.

Once that is done, you can run:


# partprobe /dev/sdb or
# blockdev --rereadpt /dev/sdb
# resize2fs /dev/sdb 

to extend the filesystem.

Please, always make backups of your data before doing low-level procedures like that. Failure in some of the steps or system crash or power failure will result in data loss. This is example which describes a single partition on a block device, your setups may vary, so do not use as it is, learn and understand how it works, then test and if you get the expected results, run on your live data at your own risk!

Hope that helps others as well. Feedback and where to improve/make more verbose is welcome.

Thank you!

Before I extended an ext4 filesystem from the free space of the beginning of the block device, I performed a search to see how others did it and it looks like your question was the closest match I could find. But the provided answer is not exactly what you have asked or I needed. Because I have just managed to resize/grow from the beginning of the disk successfully, I decided to share my thoughts.

The procedure in a nutshell: 1.) The filesystem to be grown/extended: ext4 filesystem on a partition starting at 1026048 sector and ending at the end of the block device (/dev/sdb in my case) 2.) To allocate the unused sectors at the beginning of the block device for this filesystem, I had to move the data using dd to the start of my future/new partition 3.) Delete the old partition and recreate it with the new start sector 4.) resize2fs to extend to the new partition size

Commands used and details on the method:

Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes

(Above info revealed by fdisk -l /dev/sdb.)

Calculate dd seek and skip offsets and bs (in our case bs matches sector size):

# dd seek=2048 skip=1026048 if=/dev/sdb bs=512 of=/dev/sdb

So we want to move our data from sector 1026048 and onwards to start at sector 2048 where our new partition is going to start. We should not be able to lose anything as the more we read from the input, the further we get, so by the time we start overwriting with the output  (it will eventually reach sector 1026048), we would have copied what was there at the beginning of the device and move on.

Then use fdisk to delete the old partition and recreate it to start at sector 2048.

Once that is done, you can run:

# partprobe /dev/sdb or
# blockdev --rereadpt /dev/sdb
# resize2fs /dev/sdb<num>

to extend the filesystem.

Please, always make backups of your data before doing low-level procedures like that. Failure in some of the steps or system crash or power failure will result in data loss. This is an example which describes a single partition on a block device. Your setups may vary, so do not use as it is. Learn and understand how it works, then test, and if you get the expected results, run on your live data at your own risk!

Hope that helps others as well. Feedback and where to improve/make more verbose is welcome.

Thank you!

Source Link

before I extended an ext4 filesystem from the free space of the beginning of the block device I performed a search to see how others did it and it looks like your question was the closest match I could find. But the provided answer is not exactly what you have asked or I needed. Because I have just managed to resize/grow from the beginning of the disk successfully, I decided to share my thoughts.

The procedure in a nutshell: 1.) The filesystem to be grown/extended: ext4 filesystem on a partition starting at 1026048 sector and ending at the end of the block device (/dev/sdb in my case) 2.) To allocate the unused sectors in the beginning of the block device for this filesystem, I had to move the data using 'dd' to the start of my future/new partition 3.) Delete the old partition and recreate it with the new start sector 4.) resize2fs to extend to the new partition size

Commands used and details on the method:

Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
(above info revealed by fdisk -l /dev/sdb)

Calculate 'dd' seek and skip offsets and bs(in our case bs matches sector size):

# dd seek=2048 skip=1026048 if=/dev/sdb bs=512 of=/dev/sdb

So we want to move our data from sector 1026048 and onwards to start at sector 2048 where our new partition is going to start. We should not be able to lose anything as the more we read from the input, the further we get, so by the time we start overwriting with the output(it will eventually reach sector 1026048), we would have copied what was there at the beginning of the device and move on.

then use 'fdisk' to delete the old partition and recreate it to start at sector 2048.

Once that is done, you can run:

# partprobe /dev/sdb or
# blockdev --rereadpt /dev/sdb
# resize2fs /dev/sdb 

to extend the filesystem.

Please, always make backups of your data before doing low-level procedures like that. Failure in some of the steps or system crash or power failure will result in data loss. This is example which describes a single partition on a block device, your setups may vary, so do not use as it is, learn and understand how it works, then test and if you get the expected results, run on your live data at your own risk!

Hope that helps others as well. Feedback and where to improve/make more verbose is welcome.

Thank you!