0% found this document useful (0 votes)
33 views4 pages

Ch-7-Lab: Partitions Objective

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 4

CH-7-LAB: PARTITIONS

OBJECTIVE:
To create a new partition on the hard disk
PRE-REQUISITE:
Machine with Linux Installed
TOPOLOGY:

1. Check the existing partitions on the hard disk

Syntax:
[root@clientl ~]# fdisk <option>
[root@clientl ~]# fdisk -I

Result:
Disk/dev/sda: 41.9 GB, 41875931136 bytes, 81788928 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: 0x00040059
Device Boot Start End Blocks Id System /dev/sdal * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 21506047 10240000 83 Linux /dev/sda3 21506048 37890047
8192000 83 Linux
/dev/sda4 37890048 81788927 21949440 5 Extended
/dev/sda5 37894144 54278143 8192000 83 Linux
/dev/sda6 54280192 58376191 2048000 83 Linux
/dev/sda7 58378240 62474239 2048000 82 Linux swap / Solaris

2. Enter the hard disk by using fdisk command

[root@clientl ~]# fdisk /dev/sda


Command (m for help): m
d delete a partition m print this menu n add a new partition p print the partition table q
quit without saving changes w write table to disk and exit
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.

Command (m for help): n


First cylinder (1098-2434, default 1098): Press enter (key to skip cylinders option)
Using default value 1098
Last cylinder or +size or +sizeM or +sizeK (1098-2434, default 2434): +100M (partition
size)

Command (m for help): p (to print new changes)


Disk/dev/sda: 41.9 GB, 41875931136 bytes, 81788928 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: 0x00040059

Command (m for help): w (to save and quit)


The partition table has been altered!
Calling ioctlQ 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.

3. Update new partition changes to kernel

Syntax:
[root@clientl ~]# partprobe <disk_name>
[root@clientl ~]# partprobe /dev/sda

Verification:
No error message means updated successfully
[root@clientl ~]# fdisk -I

Disk/dev/sda: 41.9 GB, 41875931136 bytes, 81788928 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: 0x00040059

4. Make file system i.e... (format the partition)

Syntax:
[root@clientl ~]# mkfs.ext4 <partition no>
[root@clientl ~]# mkfs.ext4 /dev/sda8

Result:
mke2fs 1.42.9 (28-Dec-2013)
Filesystem too small for a journal Filesystem label=
OS type: Linux Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks 128 inodes, 1024 blocks 51 blocks (4.98%)
reserved for the super user First data block=l
Maximum filesystem blocks=1048576 1 block group
8192 blocks per group, 8192 fragments per group 128 inodes per group
Allocating group tables: done

Writing inode tables: done


Writing superblocks and filesystem accounting information: done
########## OR ##########
[root@clientl ~]# mkfs.vfat /dev/sda8
Result:
mkfs.fat 3.0.20 (12 Jun 2013)

5. To check file system type of partition

[root@clientl ~]# blkid /dev/sda8

Result:
/dev/sda8: UUID=M08b85639-6ce3-4d4c-8d55-19c24ab0756aM TYPE=Mext4M

6. Create a folder and mount the partition to use


[root@clientl ~]# mkdir/mnt/linux

Syntax:
[root@clientl ~]# mount <partition_no.> <directory>
[root@clientl ~]# mount /dev/sda8 /mnt/linux

7. Check the mounted partition


[root@clientl ~]# mount | grep/mnt/linux
/dev/sda8 on /mnt/linux type ext4 (rw,relatime,seclabel)

8. Write the data on the partition

[root@clientl ~]# cd /mnt/linux


[root@clientl linux]#

[root@clientl linux]# touch myfile myfill myfiie2


[root@clientl linux]# mkdir dsnr secbad bhills ameerpet

[root@clientl linux]# Is
ameerpet bhills dsnr lost+found myfile myfilel myfile2 secbad

END

You might also like