Disk has been put in server, I need to just mount it, how do I do it?

Joined
Apr 16, 2023
Messages
149
Reaction score
16
Credits
1,460
LOL if this is really stupid question. I'm really scared to do this. The disk is called "sdc". I just need to mount it on / . I've read lots of blogs but I'm scared to try them out. Can you give me a easy hands on guide.
 


I doubt you want to mount it at "/". That would wipe out your entire Linux install.
It won't erase it, but none of your commands would work, they would be hidden.

There are ways to do this from the GUI, but this is the command line way.

fdisk /dev/sdc
Press "g" - this will create a gpt partition table.
Press "w", this will write the table to the disk, and then kick you out of fdisk.

do this again...
fdisk /dev/sdc
Press "n" - this will create a new partition.
If you just accept the default and press enter a couple of times, this will create one large single partition.
Press "w" to write the new partition to the disk.

The disk has a partition table, but it isn't formatted yet. You need to decide what file-system format you want to use.
For ext4... mkfs.ext4 /dev/sdc1
For xfs... mkfs.xfs /dev/sdc1

Now you have a formatted partition that you can mount.

Typically you might mount this under /mnt like this.
mount /dev/sdc1 /mnt

But you can make a directory called anything.
cd /
mkdir /mydisk
mount /dev/sdc1 /mydisk


Now you can cd /mydisk and copy files here.

To unmount the disk
cd /
umount /mydisk
 
If you want to make this permanent, you can add this to the /etc/fstab file

I'll show the "easy" way first. Just make a new line at the bottom of your /etc/fstab file.

/dev/sdc1 /mydisk ext4 defaults 0 0

( Change ext4 to xfs if you formatted the partition to xfs )

That'll work, but it's not really the recommended way.
Here is the "right" way.

blkid /dev/sdc1

You'll see some output similar to this...

/dev/sdc1: UUID="b7356ad1-1218-4ac8-a416-4068027e0d01" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="6396560d-c6de-ee4e-9cdc-cb809b8d1798"

The part you care about is the UUID. Yours will be different from the example here.
Now put this at the bottom of your /etc/fstab file.

UUID=4176d238-9934-4ec8-aaca-10e75fa331cf /mydisk ext4 defaults 0 0

Obviously change the UUID value to whatever yours actually is.

If you don't get any output from the blkid command, you will have to use sudo or su before you run it.
 

Staff online

Members online


Top