- ANKUSH THAVALI
- 03 Sep, 2021
- 0 Comments
- 3 Mins Read
How to create new partition in Linux
Create New partition or new mount point in linux
If you are using vmware workstation then you can add additional disk. I have added disk
Verify the partitions available on the server: fdisk -l
[root@asm ~]# fdisk -l Disk /dev/sda: 85.9 GB, 85899345920 bytes, 167772160 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: dos Disk identifier: 0x0003f827 Device Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 167772159 82836480 8e Linux LVM Disk /dev/sdb: 96.6 GB, 96636764160 bytes, 188743680 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 /dev/mapper/ol-root: 37.6 GB, 37580963840 bytes, 73400320 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 /dev/mapper/ol-swap: 5368 MB, 5368709120 bytes, 10485760 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 /dev/mapper/ol-data: 36.5 GB, 36503027712 bytes, 71294976 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 /dev/mapper/ol-tmp: 5368 MB, 5368709120 bytes, 10485760 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
Choose which device you wish to use (such as /dev/sda or /dev/sdb) Run fdisk /dev/sdX (where X is the device you would like to add the partition to) Lets create partition for /dev/sdb device
[root@asm ~]# fdisk /dev/sdb Welcome to fdisk (util-linux 2.23.2). 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 Building a new DOS disklabel with disk identifier 0x2e3d7a49.
Type 'n' to create a new partition. Specify where you would like the partition to end and start. You can set the number of MB of the partition instead of the end cylinder. For example: +1000M Type 'p' to view the partition, and type 'w' to save the partition
Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): 1 First sector (2048-188743679, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-188743679, default 188743679): Using default value 188743679 Partition 1 of type Linux and of size 90 GiB is set Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
Format the partition by doing: mkfs -t ext3 /dev/sdb1
[root@asm ~]# mkfs -t ext3 /dev/sdb1 mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 5898240 inodes, 23592704 blocks 1179635 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 720 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done
Create new directory to mount the partition
[root@asm ~]# mkdir /u01 [root@asm ~]#
Mount the directory
[root@asm ~]# mount /dev/sdb1 /u01 [root@asm ~]#
Verify if the partition available. Here we can see partition created as /u01
[root@asm ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 1.7G 0 1.7G 0% /dev tmpfs 1.7G 0 1.7G 0% /dev/shm tmpfs 1.7G 9.7M 1.7G 1% /run tmpfs 1.7G 0 1.7G 0% /sys/fs/cgroup /dev/mapper/ol-root 35G 5.3G 30G 16% / /dev/sda1 1014M 275M 740M 28% /boot /dev/mapper/ol-tmp 5.0G 33M 5.0G 1% /tmp /dev/mapper/ol-data 34G 33M 34G 1% /data tmpfs 342M 4.0K 342M 1% /run/user/42 tmpfs 342M 28K 342M 1% /run/user/0 /dev/sdb1 89G 56M 84G 1% /u01
Edit the fstab to mount the directory automatically.
[root@asm ~]# cat /etc/fstab # # /etc/fstab # Created by anaconda on Thu Sep 2 15:39:39 2021 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/mapper/ol-root / xfs defaults 0 0 UUID=9a266fcd-22c7-40ad-a70e-3bd158a054c0 /boot xfs defaults 0 0 /dev/mapper/ol-data /data xfs defaults 0 0 /dev/mapper/ol-tmp /tmp xfs defaults 0 0 /dev/mapper/ol-swap swap swap defaults 0 0 /dev/sdb1 /u01 ext3 defaults 0 0