HOW TO CREATE PARTITION AND MOUNT (FILE SYSTEM)
[root@dev ~]# 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.
Command (m for help): p
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Partition number (1-4, default 1): 1
First sector (2048-16777215, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-16777215, default 16777215): +2048M
Partition 1 of type Linux and of size 2 GiB is set
Command (m for help): w
The partition table has been altered!
[root@dev ~]# mkfs.ext4 /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Temporary mount
[root@dev ~]# mount /dev/sdb1 linux
[root@dev ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 60G 0 disk
├─sda1 8:1 0 1G 0 part
└─sda2 8:2 0 59G 0 part
├─centos-root 253:0 0 37G 0 lvm /
├─centos-swap 253:1 0 3.9G 0 lvm [SWAP]
└─centos-home 253:2 0 18.1G 0 lvm
sdb 8:16 0 8G 0 disk
└─sdb1 8:17 0 2G 0 part /root/linux
Fuser command used
[root@dev ~]# fuser -cu linux
/root/linux: 23963c(root)
Note :- It is show how many user used this directory
[root@dev ~]# fuser -ck linux
/root/linux: 23963c
Note :- forcefully kill user and log out
To view the usage information of mounted partition:
[root@dev ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 34M 1.9G 2% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/mapper/centos-root 38G 4.6G 33G 13% /
/dev/sda1 1014M 149M 866M 15% /boot
/dev/mapper/centos-home 19G 33M 19G 1% /home
/dev/sdb1 2.0G 6.0M 1.8G 1% /root/linux
10. Creating a Swap Partition:
[root@dev ~]# 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.
Command (m for help): p
Disk /dev/sdb: 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: dos
Disk identifier: 0x13fe498e
Device Boot Start End Blocks Id System
/dev/sdb1 2048 4196351 2097152 83 Linux
/dev/sdb2 4196352 8390655 2097152 8e Linux LVM
Command (m for help): n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p): p
Partition number (3,4, default 3): 3
First sector (8390656-16777215, default 8390656):
Using default value 8390656
Last sector, +sectors or +size{K,M,G} (8390656-16777215, default 16777215): +2048M
Partition 3 of type Linux and of size 2 GiB is set
Command (m for help): p
Disk /dev/sdb: 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: dos
Disk identifier: 0x13fe498e
Device Boot Start End Blocks Id System
/dev/sdb1 2048 4196351 2097152 83 Linux
/dev/sdb2 4196352 8390655 2097152 8e Linux LVM
/dev/sdb3 8390656 12584959 2097152 83 Linux
Command (m for help): t
Partition number (1-3, default 3): 3
Hex code (type L to list all codes): 82
Changed type of partition 'Linux' to 'Linux swap / Solaris'
Command (m for help): p
Disk /dev/sdb: 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: dos
Disk identifier: 0x13fe498e
Device Boot Start End Blocks Id System
/dev/sdb1 2048 4196351 2097152 83 Linux
/dev/sdb2 4196352 8390655 2097152 8e Linux LVM
/dev/sdb3 8390656 12584959 2097152 82 Linux swap / Solaris
Command (m for help): w
The partition table has been altered!
Calling ioctl() 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.
[root@dev ~]# partprobe
[root@dev ~]# mkswap /dev/sdb3
Setting up swapspace version 1, size = 2097148 KiB
no label, UUID=d2fde43f-4e96-42a5-9ac8-8cb7fa6d18c5
[root@dev ~]# swapon /dev/sdb3
[root@dev ~]# swapon -s
Filename Type Size Used Priority
/dev/dm-1 partition 4063228 0 -2
/dev/sdb3 partition 2097148 0 -3
Check Swap memory
[root@dev ~]# free -m
total used free shared buff/cache available
Mem: 3789 829 417 33 2542 2648
Swap: 6015 0 6015
Reduce Swap memory
[root@dev ~]# swapoff /dev/sdb3
[root@dev ~]# free -m
total used free shared buff/cache available
Mem: 3789 828 417 33 2542 2648
Swap: 3967 0 3967
No comments:
Post a Comment