Hope that your are enjoying Linux. Now in this post we’ll learn, partition management in Linux.
Partition management in Linux (CentOS/Red Hat)
Generally, Window File Systems are FAT32, NTFS.
And, Linux file systems are ext2, ext3, ext4, XFS (current), vfat, swap, ZFS, GlusterFS.
All device files location: /dev/*
* hdd, dvd, cdrom, usb, serial, swap, tty
Total Partition: (MBR – Master Boot Record)- (sata) – BIOS
Linux Partition = 15 (4 Primary + 11 Logical)
Windows Partition: 24 C-Z, A- Floppy, B-zip
Total Partition: (GPT – which is stands for Guid Partition Table)- UEFI (which is stands for United Extensibel Firmware Interface)
Total Partition: 128
SATA/SCSI HDD is marked as sda, sdb, sdc
USB devices is considered in Linux as sda1, sdb1
DVD drivers are markes in Linux (CentOS) as dvd/sr0
So we want to see all partition, just type these command in CLI.
[root@ns1 Desktop]# fdisk -lsda = 1st sata
sdb = 2nd stata
sdc = 3rd sata
Command to see Linux mounted partition(s)
[root@ns1 Desktop]# df -HT
/dev/sda6 xfs 52G 7.0G 43G 15% /
/dev/sda5 xfs 204M 27M 167M 14% /boot
[root@desktop1 /]# du -ch home
Partition ID of Linux:
NTFS – 7
Extended – 5
ext3/ext4/xfs – 83
swap – 82
LVM – 8e
vfat – f
RAID – fd
Now we want to create a new Partition. So we just’ll just type the command
[root@ns1 dev]# fdisk /dev/sda
Command (m for help): m
d delete a partition
l list known partition types
m is for print this menu
n is for adding a new partition
p is to print the partition table
q is to quit without saving changes
t is for changing a partition’s system id
w is to write table to disk and exit
Command (m for help): n
[root@ns1 Desktop]# fdisk /dev/sda
Command (m for help): n
First sector (415141888-976773119, default 415141888): {press Enter}
Using default value 415141888
Last sector, +sectors or +size{K,M,G} (415141888-976773119, default 976773119): +350M
Command (m for help): p
Command (m for help): w
Now if you want to update the partition table, just follow this command.
[root@desktop1 ~]# partprobe /dev/sda
Want to format a partition? Just follow the command:
[root@ns1 Desktop]# mkfs.xfs /dev/sdaX
Want to mount a partition?? Follow this:
[root@ns1 Desktop]# mkdir /data [root@ns1 Desktop]# df -HT [root@ns1 Desktop]# mount /dev/sda9 /data[root@ns1 Desktop]# df -HT [root@ns1 Desktop]# cd /data [root@ns1 data]# ls [root@ns1 data]# df -HT
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda6 xfs 16G 6.4G 8.4G 44% /
/dev/sda5 xfs 204M 27M 167M 14% /boot
/dev/sda9 xfs 508M 11M 471M 3% /data
[root@ns1 data]# cd .. ; This command is going to the previous directory. [root@ns1 /]# umount /data [root@ns1 /]# df -HTFilesystem Type Size Used Avail Use% Mounted on
/dev/sda6 xfs 16G 6.4G 8.4G 44% /
tmpfs tmpfs 2.0G 267k 2.0G 1% /dev/shm
/dev/sda5 xfs 204M 27M 167M 14% /boot
Permanent Mount:
[root@localhost ~]# blkid /dev/sda8[root@ns1 ~]# vi /etc/fstab
UUID=1b42c7df-717a-420d-b054-81d5a48594b5 /data xfs defaults 0 0
or
/dev/sda9 /data xfs defaults 0 0
1 2 3 4 5 6
1 – partition
2 – mountpoint
3 – filesystem
4 – options(quota,acl)
5-6 – file system check options
[root@ns1 ~]# mount -a ;fstab file update [root@ns1 ~]# df-HT ; view
Now, want to delete a partition?? Follow this:
[root@ns1 ~]# fdisk /dev/sda
Command (m for help): d
Partition number , generally there is displayed (1-10).
Command (m for help): p
Command (m for help): w
Note: Before delete, you should unmount partition and delete fstab entry.
[root@ns1 ~]# fdisk -l
Mount USB pen drive:
[root@ns1 Desktop]# fdisk -lDisk /dev/sdb: 32.2 GB, 32176472064 bytes
[root@ns1 Desktop]# mount /dev/sdb1 /mnt [root@ns1 mnt]# cd /mnt [root@ns1 mnt]# ls [root@ns1 mnt]# cp cv.docx /root/Desktop [root@ns1 mnt]# cp /etc/passwd /mnt [root@ns1 mnt]# cd [root@ns1 ~]# umount /mnt [root@ns1 ~]# cd /mnt [root@ns1 mnt]# ls
Mount DVD:
[root@ns1 Desktop]# mount /dev/sr0 /media [root@ns1 Desktop]# cd /media [root@ns1 media]# ls [root@ns1 media]# cd Packages [root@ns1 Packages]# ls [root@ns1 Packages]# cd [root@ns1 ~]# umount /media [root@ns1 ~]#
Screenshots for you:
Leave a Reply