Sunday, March 26, 2017

RHEL7 - Remove unused disk - swap

How to remove remove unwanted disk from the system.

1. Find the disk you want to remove and see if it is on use
[root@bishal ~]# fdisk -l | grep sdh
Disk /dev/sdh: 1073 MB, 1073741824 bytes, 2097152 sectors
/dev/sdh1            2048     2097151     1047552   83  Linux

2. Find blkid of the disk
[root@bishal ~]# blkid /dev/sdh1
/dev/sdh1: UUID="97122ba6-8761-4521-9475-f4319d931b4f" TYPE="swap"

3. Check if there is entry to /etc/fstab
[root@bishal ~]# grep 97122ba6-8761-4521-9475-f4319d931b4f /etc/fstab
UUID="97122ba6-8761-4521-9475-f4319d931b4f"  swap       swap   defaults

4. From fstab entry we found that the disk is used as swap disk
[root@bishal ~]# swapon -s
Filename                                Type            Size    Used    Priority
/dev/sdf2                               partition       1048572 2824    -1
/dev/sda2                               partition       2097148 0       -2
/dev/sdh1                               partition       1047548 0       -3
[root@bishal ~]# free
              total        used        free      shared  buff/cache   available
Mem:        1868664      603308       97264        8028     1168092     1040552
Swap:       4193268        2824     4190444

5. Remove from swap and remove from fstab and verify it.
If it was a regular mount, unmount the partition, remove entry from fstab and remove partition using fdisk.
[root@bishal ~]# swapoff /dev/sdh1
[root@bishal ~]# vi /etc/fstab
[root@bishal ~]# swapon -s
Filename                                Type            Size    Used    Priority
/dev/sdf2                               partition       1048572 2824    -1
/dev/sda2                               partition       2097148 0       -2
[root@bishal ~]#
[root@bishal ~]# partprobe

Now, it is safe to remove your disk from VMware or from your physical system.

No comments:

Post a Comment