Following are steps to Create And Mount New Filesystem With New Extended Storage (Extend Volume / Filesystem / Hard Drive)
STEP 1. Attach the desired size disk to the Linux Machine.
In this example lets assume we are attaching 200GB disk.
STEP 2. Validate that the 200GB disk is seen on the Linux host.
For this use fdisk -l command. You should see output as follows:
Disk /dev/sdb: 200 GiB, 214748364800 bytes, 419430400 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
STEP 3. Validate that the 200GB added disk is seen in partitions.
For this run below command.
cat /proc/partitions
From below output we see that it is available as sdb partition
# cat /proc/partitions
major minor #blocks name
8 0 104857600 sda
8 1 2048000 sda1
8 2 102808576 sda2
8 16 209715200 sdb
STEP 4. Now to run fdisk command on /dev/sdb partition to add 200GB size to the Linux host OS.
fdisk /dev/sdb
Below is sample output.
Please enter the entries when prompted as shown in blue bold font below.
# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xa66f30f6.
Command (m for help): p >>>>> Enter p here to print partition size details.
Disk /dev/sdb: 200 GiB, 214748364800 bytes, 419430400 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
Disklabel type: dos
Disk identifier: 0xa66f30f6
Command (m for help): n >>>>>> Enter n here to create new partition.
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): >>>>>> Just hit Enter and go with defaults
Using default response p.
Partition number (1-4, default 1): >>>>>> Just hit Enter and go with defaults
First sector (2048-419430399, default 2048): >>>>>> Just hit Enter and go with defaults
Last sector, +sectors or +size{K,M,G,T,P} (2048-419430399, default 419430399): >>>>>> Just hit Enter and go with defaults
Created a new partition 1 of type 'Linux' and of size 200 GiB.
Command (m for help): p >>>>> Enter p here to check the created partition.
Disk /dev/sdb: 200 GiB, 214748364800 bytes, 419430400 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
Disklabel type: dos
Disk identifier: 0xa66f30f6
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 419430399 419428352 200G 83 Linux
Command (m for help): w >>>> Enter w here to write the changes.
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
STEP 5. Format the created partition
For this use below command.
sudo mkfs.xfs -f /dev/sdb
Below is sample output.
meta-data=/dev/sdb isize=512 agcount=4, agsize=13107200 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1
data = bsize=4096 blocks=52428800, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=25600, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
STEP 6. Create a directory on which you want to mount the new sdb partition.
For e.g. lets assume apps
mkdir /apps
STEP 7. Mount newly created /apps partition on sbd partition which has 200GB storage.
In this example we are having xfs for apps partition, it can be other filesystem type as well other than xfs
sudo mount -t xfs /dev/sdb /apps
STEP 8. Run "df -Th" command and verify that the partition is mounted as /apps mount is mounted with 200GB size.
Below is snippet.
/dev/sdb xfs 200G 1.5G 199G 1% /apps
STEP 9. Update /etc/fstab and add below entry to have newly filesystem with /dev/sdb partition.
Update /etc/fstab and add below entry to have newly filesystem with /dev/sdb partition.
/dev/sdb /apps xfs defaults 0 0
This is to make sure that filesystem gets automounted during the reboot.
STEP 10. Reboot the node. After the reboot you would notice that the XFS filesystem is auto mounted.
This can be verified using "df -H" command.
No comments:
Post a Comment