In this post I have taken some space from /home and extend the / file system.
I have followed these below steps for re-sizing the root file system and it worked.
[root@localhost ~]# df -h
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 12G 1.8G 9.3G 16% /
tmpfs 939M 0 939M 0% /dev/shm
/dev/sda1 194M 32M 152M 18% /boot
/dev/sda3 2.0G 35M 1.8G 2% /home
[root@localhost ~]# cat /etc/fstab
* Baisc logic behind is we need to delete the partion (/) and create a new partition with same number having new file size.
EX- In below example I have extend a / file system 12G to 14G. Used fdisk utils and Rhel6.4
[root@localhost ~]# fdisk /dev/sda
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): p ---> To print the current file system.
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x000dac65
Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 26 1556 13449426 83 Linux -> root file sysetm
/dev/sda3 1556 1811 2048000 83 Linux -> /home
/dev/sda4 1811 2611 6429696 5 Extended
/dev/sda5 1811 1837 204800 82 Linux swap / Solaris
Command (m for help): d -> dleted the /home
Partition number (1-5): 3
Command (m for help): d -> /deleted the /root (SN# is 2)
Partition number (1-5): 2
Command (m for help): n -> create a new partition with same SN# 2
Command action
l logical (5 or over)
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (26-2610, default 26): 26
Last cylinder, +cylinders or +size{K,M,G} (26-1810, default 1810): 1800
Command (m for help): wq
The partition table has been altered!
# Note- Remove the /home from /etc/fstab.
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.
# Reboot the system
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 12G 1.8G 9.3G 16% /
tmpfs 939M 0 939M 0% /dev/shm
/dev/sda1 194M 32M 152M 18% /boot
# excute the below to resize the file system.
[root@localhost ~]# resize2fs /dev/sda2
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/sda2 is mounted on /; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/sda2 to 3563169 (4k) blocks.
The filesystem on /dev/sda2 is now 3563169 blocks long.
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 14G 1.8G 11G 14% /
tmpfs 939M 0 939M 0% /dev/shm
/dev/sda1 194M 32M 152M 18% /boot
[root@localhost ~]#
I have followed these below steps for re-sizing the root file system and it worked.
[root@localhost ~]# df -h
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 12G 1.8G 9.3G 16% /
tmpfs 939M 0 939M 0% /dev/shm
/dev/sda1 194M 32M 152M 18% /boot
/dev/sda3 2.0G 35M 1.8G 2% /home
[root@localhost ~]# cat /etc/fstab
* Baisc logic behind is we need to delete the partion (/) and create a new partition with same number having new file size.
EX- In below example I have extend a / file system 12G to 14G. Used fdisk utils and Rhel6.4
[root@localhost ~]# fdisk /dev/sda
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): p ---> To print the current file system.
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x000dac65
Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 26 1556 13449426 83 Linux -> root file sysetm
/dev/sda3 1556 1811 2048000 83 Linux -> /home
/dev/sda4 1811 2611 6429696 5 Extended
/dev/sda5 1811 1837 204800 82 Linux swap / Solaris
Command (m for help): d -> dleted the /home
Partition number (1-5): 3
Command (m for help): d -> /deleted the /root (SN# is 2)
Partition number (1-5): 2
Command (m for help): n -> create a new partition with same SN# 2
Command action
l logical (5 or over)
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (26-2610, default 26): 26
Last cylinder, +cylinders or +size{K,M,G} (26-1810, default 1810): 1800
Command (m for help): wq
The partition table has been altered!
# Note- Remove the /home from /etc/fstab.
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.
# Reboot the system
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 12G 1.8G 9.3G 16% /
tmpfs 939M 0 939M 0% /dev/shm
/dev/sda1 194M 32M 152M 18% /boot
# excute the below to resize the file system.
[root@localhost ~]# resize2fs /dev/sda2
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/sda2 is mounted on /; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/sda2 to 3563169 (4k) blocks.
The filesystem on /dev/sda2 is now 3563169 blocks long.
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 14G 1.8G 11G 14% /
tmpfs 939M 0 939M 0% /dev/shm
/dev/sda1 194M 32M 152M 18% /boot
[root@localhost ~]#
No comments:
Post a Comment