2

First time post on here. I'm studying for the LFCS course so I'm relatively new to Linux sysadmin, so apologies if this is an obvious question.

I'm having a very frustrating issue that has had me stuck for a few days. I've searched high and low on this site and across google and have yet to find an answer that relates to my exact problem.

I'm doing a little project on my own CentOS 7 VM , I'm setting up Kibana and Elastic search. Firstly - I'm setting up a partition on my HD for this, and have created a partition with no problem using fdisk. When i write the new partition to table , I always get the error that tables did not update correctly. But after running partprobe, this resolves this. Next it's time to put the file system on the new partition, but here is where I have the problem , i always get this error - /dev/sda1 is apparently in use by the system; will not make a filesystem here!

# lsblk
NAME   MAJ:MIN RM    SIZE RO TYPE MOUNTPOINT
sda      8:0    0   24.5G  0 disk
└─sda1   8:1    0 1023.8M  0 part
sdb      8:16   0    512M  0 disk [SWAP]

# mkfs -t ext4 /dev/sda1
mke2fs 1.42.9 (28-Dec-2013)
/dev/sda1 is apparently in use by the system; will not make a filesystem here!
#

I have read similar posts and many answers include checking to see if raid info is stored on the disk, but that is definitely not the case with my VM.

The disk is also unmounted and def does not have a filesystem on it :-

# file -sL /dev/sda1
/dev/sda1: data#

Any help or ideas anyone has would be gratefully received. I'm pulling my hair out here! Many Thanks :)

2 Answers2

1

Based on your response:

When I run the mount, the output does not mention /dev/sda1 the only part that is mentioned is the rest of that disk:

/dev/sda on / type ext4 (rw,relatime,data=ordered)

In this case, it looks like when you originally installed the operating system, you put a filesystem on /dev/sda with no partition table or any partitions - i.e: on the bare block device.

Now that you have added a partition table, you have likely overwritten / trashed the first part of your root filesystem - when you reboot you'll likely see an error.

Remember that /dev/sda refers to the whole device, from the beginning to end... /dev/sda1 refers to a smaller region of this same device. They are not two separate entities, but rather sda1 is a subset of sda.

According to the diagram below:

  • Your filesystem is on the green (bare block device)
  • You've just written the red partition table (I'm guessing MBR) over the beginning of your filesystem.
  • If you were to use mkfs on the orange section (aka a "partition"), then you would be further destroying your data that exists on the underlying block device (green).

block device layout

When you do an install, I recommend that you always make a partition table (MBR or GPT, it's up to you), and put your filesystems in a partition, not on the bare block device.


As a side note, if you had used partitions, then you could get rid of /dev/sdb, and put your swap on a partition that resides on /dev/sda...

Attie
  • 20,734
0

Its simple, what u have done is terminated the current terminal, so solution is : remove the particular harddisk ie SATA etc... and add it again with preferred disk size. It worked for me.