Resizing the filesystem on linux [root@ip-10-0-0-242 opt]# fdisk -l WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion. Disk /dev/xvda: 8589 MB, 8589934592 bytes, 16777216 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 4096 16777182 8G Linux filesyste Linux 128 2048 4095 1M BIOS boot parti BIOS Boot Partition Disk /dev/xvdb: 536.9 GB, 536870912000 bytes, 1048576000 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 [root@ip-10-0-0-242 opt]# df -h Filesystem Size Used Avail Use% Mounted on /dev/xvda1 7.8G 2.9G 4.8G 38% / devtmpfs 15G 64K 15G 1% /dev tmpfs 15G 0 15G 0% /dev/shm /dev/xvdb 197G 173G 15G 93% /vol The /dev/xvdb still shows 200GB even though it has been upgraded to 500 GB (fdisk) Following are the commands to resizing the filesystem [root@ip-10-0-0-242 opt]# mount proc on /proc type proc (rw,relatime) sysfs on /sys type sysfs (rw,relatime) /dev/xvda1 on / type ext4 (rw,noatime,data=ordered) devtmpfs on /dev type devtmpfs (rw,relatime,size=15427064k,nr_inodes=3856766,mode=755) devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620,ptmxmode=000) tmpfs on /dev/shm type tmpfs (rw,relatime) /dev/xvdb on /vol type ext4 (rw,noatime,data=ordered) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,relatime) [root@ip-10-0-0-242 opt]# mkfs.ext4 /dev/xvdb mke2fs 1.42.12 (29-Aug-2014) /dev/xvdb contains a ext4 file system last mounted on /vol on Fri Jul 1 10:59:32 2016 Proceed anyway? (y,n) y /dev/xvdb is mounted; will not make a filesystem here! [root@ip-10-0-0-242 opt]# umount /dev/xvdb [root@ip-10-0-0-242 opt]# resize2fs /dev/xvdb resize2fs 1.42.12 (29-Aug-2014) Please run 'e2fsck -f /dev/xvdb' first. [root@ip-10-0-0-242 opt]# e2fsck -f /dev/xvdb e2fsck 1.42.12 (29-Aug-2014) 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/xvdb: 73444/13107200 files (2.1% non-contiguous), 46060290/52428800 blocks [root@ip-10-0-0-242 opt]# resize2fs /dev/xvdb resize2fs 1.42.12 (29-Aug-2014) Resizing the filesystem on /dev/xvdb to 131072000 (4k) blocks. The filesystem on /dev/xvdb is now 131072000 (4k) blocks long. [root@ip-10-0-0-242 opt]# mount -a [root@ip-10-0-0-242 opt]# mount proc on /proc type proc (rw,relatime) sysfs on /sys type sysfs (rw,relatime) /dev/xvda1 on / type ext4 (rw,noatime,data=ordered) devtmpfs on /dev type devtmpfs (rw,relatime,size=15427064k,nr_inodes=3856766,mode=755) devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620,ptmxmode=000) tmpfs on /dev/shm type tmpfs (rw,relatime) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,relatime) /dev/xvdb on /vol type ext4 (rw,noatime,data=ordered) [root@ip-10-0-0-242 opt]# df -h Filesystem Size Used Avail Use% Mounted on /dev/xvda1 7.8G 2.9G 4.8G 38% / devtmpfs 15G 64K 15G 1% /dev tmpfs 15G 0 15G 0% /dev/shm /dev/xvdb 493G 173G 295G 37% /vol [root@ip-10-0-0-242 opt]#
Friday, 1 July 2016
Resizing a filesystem in Linux to reflect new EBS volume size
Subscribe to:
Post Comments (Atom)
Nice blog! very useful information AWS Online Training
ReplyDelete