[LINUX] Mount the volume attached to CentOS 7

This is the procedure for mounting a new volume on CentOS7. Mount another volume on / var / lib / test.

table of contents

0. Installation environment

$ cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)

This time, mount / dev / sdb on the OS. Make sure that / dev / sdb is not mounted on the OS with df -h.

$ df -h
File system size used Remaining used%Mount position
devtmpfs                  452M     0  452M    0% /dev
tmpfs                     464M     0  464M    0% /dev/shm
tmpfs                     464M  6.8M  457M    2% /run
tmpfs                     464M     0  464M    0% /sys/fs/cgroup
/dev/mapper/centos-root    14G  1.2G   13G    9% /
/dev/sda1                1014M  136M  879M   14% /boot
tmpfs                      93M     0   93M    0% /run/user/0
tmpfs                      93M     0   93M    0% /run/user/1000

Check the volume to be mounted with the following command.

$ sudo fdisk -l

Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size(minimum/Recommendation):4096 bytes/4096 bytes


Disk /dev/sda: 17.2 GB, 17179869184 bytes, 33554432 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size(minimum/Recommendation):4096 bytes/4096 bytes
Disk label type: dos
Disk identifier: 0x000acab5

Device boot start / end block Id system
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200    33554431    15727616   8e  Linux LVM

Disk /dev/mapper/centos-root: 14.4 GB, 14382268416 bytes, 28090368 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size(minimum/Recommendation):4096 bytes/4096 bytes


Disk /dev/mapper/centos-swap: 1719 MB, 1719664640 bytes, 3358720 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size(minimum/Recommendation):4096 bytes/4096 bytes

1. Add partition

Add a partition with the following command.

$ sudo 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.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xcd0e06ca.

The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.

command(Help with m):

Use m to get help for the command.

command(Help with m): m
Command behavior
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

This time we will cut a new partition, so enter n.

command(Help with m): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended

Enter p.

Select (default p): p

Enter 1 to create a new partition.

Partition number(1-4, default 1): 1

Specify the starting position of the partition. Unless otherwise specified, press Enter without typing anything.

First sector(2048-20971519,Initial value 2048):
Use the initial value 2048

Specify the end position of the partition. Unless otherwise specified, press Enter without typing anything.

Last sector, +sectors or +size{K,M,G} (2048-20971519,Initial value 20971519):
Use the initial value 20971519
Partition 1 of type Linux and of size 10 GiB is set

Save your settings and exit.

command(Help with m): w
The partition table has changed!

ioctl()To reload the partition table.
The disks are syncing.

Check if the partition has been added.

$ sudo fdisk -l

Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size(minimum/Recommendation):4096 bytes/4096 bytes
Disk label type: dos
Disk identifier: 0xcd0e06ca

Device boot start / end block Id system
/dev/sdb1            2048    20971519    10484736   83  Linux

Disk /dev/sda: 17.2 GB, 17179869184 bytes, 33554432 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size(minimum/Recommendation):4096 bytes/4096 bytes
Disk label type: dos
Disk identifier: 0x000acab5

Device boot start / end block Id system
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200    33554431    15727616   8e  Linux LVM

Disk /dev/mapper/centos-root: 14.4 GB, 14382268416 bytes, 28090368 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size(minimum/Recommendation):4096 bytes/4096 bytes


Disk /dev/mapper/centos-swap: 1719 MB, 1719664640 bytes, 3358720 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size(minimum/Recommendation):4096 bytes/4096 bytes

2. Volume format

Format with the following command.

sudo mkfs -t xfs /dev/sdb1
meta-data=/dev/sdb1              isize=512    agcount=4, agsize=655296 blks
         =                       sectsz=4096  attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=2621184, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

3. Create a mounting folder

Create a mounting folder. This time create / var / lib / test.

$ sudo mkdir /var/lib/test

4. Mount settings

Check the UUID of sdb1 with the following command.

$ sudo blkid
/dev/sdb1: UUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" TYPE="xfs"  # /dev/Copy the UUID of sdb1
/dev/sda1: UUID="yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy" TYPE="xfs"
/dev/sda2: UUID="wwwwwwww-wwww-wwww-wwww-wwwwwwwwwwww" TYPE="LVM2_member"
/dev/mapper/centos-root: UUID="zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz" TYPE="xfs"
/dev/mapper/centos-swap: UUID="vvvvvvvv-vvvv-vvvv-vvvv-vvvvvvvvvvvv" TYPE="swap"

Copy the UUID you copied to / etc / fstab.

$ sudo vi /etc/fstab

Change before

#
# /etc/fstab
# Created by anaconda on Tue May  5 11:42:35 2020
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root /                       xfs     defaults        0 0
UUID=yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy /boot                   xfs     defaults        0 0  #Copy the line here
/dev/mapper/centos-swap swap                    swap    defaults        0 0

After change

#
# /etc/fstab
# Created by anaconda on Tue May  5 11:42:35 2020
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root /                       xfs     defaults        0 0
UUID=yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy /boot                   xfs     defaults        0 0
UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /var/lib/test           xfs     defaults        0 0  #Add here
/dev/mapper/centos-swap swap                    swap    defaults        0 0

Check if it is mounted.

$ sudo mount -a

If it is not set properly, the following will be displayed. Double check the settings in / etc / fstab.

$ sudo mount -a
mount: can't find UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

Make sure it is mounted.

$ df -h
File system size used Remaining used%Mount position
devtmpfs                  452M     0  452M    0% /dev
tmpfs                     464M     0  464M    0% /dev/shm
tmpfs                     464M  6.8M  457M    2% /run
tmpfs                     464M     0  464M    0% /sys/fs/cgroup
/dev/mapper/centos-root    14G  1.2G   13G    9% /
/dev/sda1                1014M  136M  879M   14% /boot
tmpfs                      93M     0   93M    0% /run/user/1000
/dev/sdb1                  10G   33M   10G    1% /var/lib/test

This completes the mount setting procedure.

Reference URL

Recommended Posts

Mount the volume attached to CentOS 7
Introducing Python 2.7 to CentOS 6.6
The road to Pythonista
[Blender] Print all ShapeKey names attached to the object
The road to Djangoist
Change the volume of Pepper according to the surrounding environment (sound)
The first thing to do after installing CentOS Stream minimally
Commands and files to check the version of CentOS Linux
Introduced Jupyter Notebook to CentOS 7
How to use the generator
Dot according to the image
The road to download Matplotlib
Switch from python2.7 to python3.6 (centos7)
How to use the decorator
How to increase the axis
How to start the program
The day Chainer runs on GPU CentOS edition (up to CPU)
Settings to be made when starting up the linux server centos7
I tried to expand the size of the logical volume with LVM
A script that returns 0, 1 attached to the first Python prime number