There are a few assumptions made in the process outlined below:
- Your /boot partition is located at /dev/sda1.
- Your /boot partition is using the ext2 or ext3 filesystems.
- Your SWAP partition is located at /dev/sda2.
- Your /dev/sda2 partition is at least 512MB.
- You have a far understanding of the ext filesystem.
- You have a far understanding of resizing and partitioning.
- You are not performing this on a system currently in production.
- You are responsible for any and all damages that may occur from this process.
Resizing the /boot partition
1. List the partition table contents.
[root@linux ~]# fdisk -l Disk /dev/sda: 750.2 GB, 750156374016 bytes 255 heads, 63 sectors/track, 91201 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0001a00e Device Boot Start End Blocks Id System /dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 1057 8385930 82 Linux swap / Solaris /dev/sda3 1058 91201 724081680 83 Linux |
2. Ensure that /dev/sda1 is the boot partition and /dev/sda2 is the swap partition, note swap partition label.
[root@linux ~]# blkid /dev/sda1 /dev/sda2 /dev/sda1: LABEL="/boot" UUID="9d056123-abcc-4522-aaaa-126dc8b27890" SEC_TYPE="ext2" TYPE="ext3" /dev/sda2: TYPE="swap" LABEL="SWAP-sda2" |
3. Disable swap space.
[root@linux ~]# swapoff -a |
4. Unmount the /boot partition.
[root@linux ~]# umount /boot |
5. Remove journal from /dev/sda1.
[root@linux ~]# tune2fs -O ^has_journal /dev/sda1 |
6. Open partition table.
[root@linux ~]# fdisk /dev/sda |
7. Delete swap partition.
Command (m for help): d Partition number (1-4): 2 |
8. Create new swap partition whose starting cylinder is 2-3 times greater than the original.
Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First cylinder (14-91201, default 14): 42 Last cylinder, +cylinders or +size{K,M,G} (42-1057, default 1057): Using default value 1057 |
9. Change disk type on /dev/sda2 to 82 - Linux swap / Solaris.
Command (m for help): t Partition number (1-4): 2 Hex code (type L to list codes): 82 Changed system type of partition 2 to 82 (Linux swap / Solaris) |
10. Delete /dev/sda1 partition.
Command (m for help): d Partition number (1-4): 1 |
11. Add new /dev/sda1 partition using default sizes.
Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-91201, default 1): Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-41, default 41): Using default value 41 |
12. Verify new partition table.
Command (m for help): p Disk /dev/sda: 750.2 GB, 750156374016 bytes 255 heads, 63 sectors/track, 91201 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0001a00e Device Boot Start End Blocks Id System /dev/sda1 1 41 329301 83 Linux /dev/sda2 42 1057 8161020 82 Linux swap / Solaris /dev/sda3 1058 91201 724081680 83 Linux |
13. If partition table is correct, write to disk with w. If not, quit with q.
Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks. |
14. Check /dev/sda1 for errors to make sure we didn’t corrupt anything in /boot.
[root@linux ~]# e2fsck -f /dev/sda1 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 /boot1: 90/26104 files (7.8% non-contiguous), 72369/104388 blocks |
15. Reboot system.
[root@linux ~]# reboot |
16. Disable swap.
[root@linux ~]# swapoff -a |
17. Recreate swap, using swap partition label from step 2.
[root@linux ~]# mkswap -L SWAP-sda2 /dev/sda2 |
18. Enable swap.
[root@linux ~]# swapon -a |
19. Unmount /boot.
[root@linux ~]# umount /boot |
20. Resize /dev/sda1 partition.
[root@linux ~]# resize2fs /dev/sda1 resize2fs 1.41.12 (17-May-2010) Resizing the filesystem on /dev/sda1 to 329300 (1k) blocks. The filesystem on /dev/sda1 is now 329300 blocks long. |
21. Add journal to /dev/sda1.
[root@linux ~]# tune2fs -j /dev/sda1 tune2fs 1.41.12 (17-May-2010) Creating journal inode: done This filesystem will be automatically checked every -1 mounts or 0 days, whichever comes first. Use tune2fs -c or -i to override. |
22. Mount /boot.
[root@linux ~]# mount /boot |
Done!
At this point, you should be able to use the system with the newly resized /boot partition. I often reboot one more time for good measure, but it should not be necessary.