DEV Community

loading...

Mounting a new disk in Linux

Santhosh Balasa
Passionate Senior Full Stack Developer around 10+ yrs of IT experience.
・1 min read

-> How to mount a new disk in Linux ?

#Create a partition
sudo fdisk /dev/sdb

#Verify using lsblk
sdb      8:16   0    2G  0 disk
└─sdb1   8:17   0    2G  0 part /

#Create a filesystem
sudo mkfs -t ext4 /dev/sdb1

#Mount it 
sudo mount -t ext4 /dev/sdb1 /kafka

#Verify using lsblk
sdb      8:16   0    2G  0 disk
└─sdb1   8:17   0    2G  0 part /kafka
Enter fullscreen mode Exit fullscreen mode

-> How to bind a folder to this new disk and keep its data ?

sudo mount -t ext4 /dev/sdc1 /obs_parser

#Bind
sudo mount -o bind /vagrant /obs_parser

#Edit /etc/fstab entry (optional)
/vagrant /obs_parser none defaults,bind 0 0

#lsblk
sdc      8:32   0   41G  0 disk
└─sdc1   8:33   0   41G  0 part /obs_parser
Enter fullscreen mode Exit fullscreen mode

Discussion (0)