TA/Linux

volume mount

sftth 2022. 5. 5. 11:24

lsblk

  • there is disk which name is vdb. it need to partition and mount of the disk.
ubuntu@dintvmsonar01:~$ lsblk
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
loop0     7:0    0 55.5M  1 loop /snap/core18/1988
loop1     7:1    0 69.9M  1 loop /snap/lxd/19188
loop2     7:2    0 32.3M  1 loop /snap/snapd/11107
vda     252:0    0   50G  0 disk
├─vda1  252:1    0 49.9G  0 part /
├─vda14 252:14   0    4M  0 part
└─vda15 252:15   0  106M  0 part /boot/efi
vdb     252:16   0  500G  0 disk

fdisk

  • fdisk stands for fixed disk.
  • fdisk -l
root@dintvmsonar01:/home/ubuntu# fdisk -l
Disk /dev/loop0: 55.48 MiB, 58159104 bytes, 113592 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop1: 69.9 MiB, 73277440 bytes, 143120 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop2: 32.28 MiB, 33845248 bytes, 66104 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/vda: 50 GiB, 53687091200 bytes, 104857600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: E4B44124-37F9-4065-9358-C3642DFF5D78

Device      Start       End   Sectors  Size Type
/dev/vda1  227328 104857566 104630239 49.9G Linux filesystem
/dev/vda14   2048     10239      8192    4M BIOS boot
/dev/vda15  10240    227327    217088  106M EFI System

Partition table entries are not in disk order.


Disk /dev/vdb: 500 GiB, 536870912000 bytes, 1048576000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
  • fdisk /dev/vda
    • checking the /dev/vda status
root@dintvmsonar01:/home/ubuntu# fdisk /dev/vda

Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/vda: 50 GiB, 53687091200 bytes, 104857600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: E4B44124-37F9-4065-9358-C3642DFF5D78

Device      Start       End   Sectors  Size Type
/dev/vda1  227328 104857566 104630239 49.9G Linux filesystem
/dev/vda14   2048     10239      8192    4M BIOS boot
/dev/vda15  10240    227327    217088  106M EFI System

Partition table entries are not in disk order.

Command (m for help): q

root@dintvmsonar01:/home/ubuntu#

Mount

  • ls /dev/vd*
root@dintvmsonar01:~# ls /dev/vd*
/dev/vda  /dev/vda1  /dev/vda14  /dev/vda15  /dev/vdb
  • fdisk /dev/vdb
root@dintvmsonar01:~# fdisk /dev/vdb

Welcome to fdisk (util-linux 2.34).
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.
Created a new DOS disklabel with disk identifier 0x83800e9a.

Command (m for help):
  • Enter the p to check the  partition table
Command (m for help): p
Disk /dev/vdb: 500 GiB, 536870912000 bytes, 1048576000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x83800e9a

Command (m for help):
  • Enter the n to make new partition
Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p):
  • Enter the p to make primary partition
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-1048575999, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-1048575999, default 1048575999): +500G
Value out of range.
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-1048575999, default 1048575999): +499G

Created a new partition 1 of type 'Linux' and of size 499 GiB.

Command (m for help):
    •  Enter the p again to check the reuslt 
Command (m for help): p
Disk /dev/vdb: 500 GiB, 536870912000 bytes, 1048576000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x83800e9a

Device     Boot Start        End    Sectors  Size Id Type
/dev/vdb1        2048 1046480895 1046478848  499G 83 Linux
  • Save and Close
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

lsblk

root@dintvmsonar01:~# lsblk
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
loop0     7:0    0 55.5M  1 loop /snap/core18/1988
loop1     7:1    0 69.9M  1 loop /snap/lxd/19188
loop2     7:2    0 32.3M  1 loop /snap/snapd/11107
vda     252:0    0   50G  0 disk
├─vda1  252:1    0 49.9G  0 part /
├─vda14 252:14   0    4M  0 part
└─vda15 252:15   0  106M  0 part /boot/efi
vdb     252:16   0  500G  0 disk
└─vdb1  252:17   0  499G  0 part

File system format

Command

  • mkfs.[file system] [option] [disk partition]
  • mkfs -t [file system] [option] [disk partition]
  • mkfs : make file system 
  • -t [file system] : define file system type
  • -f : force file system type

File format

  • mkfs -t ext4 /dev/vdb1
root@dintvmsonar01:~# mkfs -t ext4 /dev/vdb1
mke2fs 1.45.5 (07-Jan-2020)
Discarding device blocks: done
Creating filesystem with 130809856 4k blocks and 32702464 inodes
Filesystem UUID: 7a38a8ba-e5f3-4a1d-9979-0c1a753cf3f7
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
        102400000

Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done

Mount

  • mkdir /data
drwxr-xr-x  20 root root  4096 May  5 02:52 ./
drwxr-xr-x  20 root root  4096 May  5 02:52 ../
lrwxrwxrwx   1 root root     7 Mar  4  2021 bin -> usr/bin/
drwxr-xr-x   4 root root  4096 Mar  4  2021 boot/
drwxr-xr-x   2 root root  4096 May  5 02:52 data/
drwxr-xr-x  16 root root  3820 May  5 02:37 dev/
drwxr-xr-x  91 root root  4096 May  4 14:39 etc/
drwxr-xr-x   3 root root  4096 May  4 14:39 home/
<생략>
  • mount /dev/vdb1 /data
root@dintvmsonar01:/# mount
<생략>
/dev/vdb1 on /data type ext4 (rw,relatime)
  • Note - release mount: unmount /data

fstab

  • regist mount permanently
  • fstab : file system table
  • blkid /dev/vdb1
root@dintvmsonar01:/# blkid /dev/vdb1
/dev/vdb1: UUID="7a38a8ba-e5f3-4a1d-9979-0c1a753cf3f7" TYPE="ext4" PARTUUID="83800e9a-01"
  • vi /etc/fstab
LABEL=cloudimg-rootfs   /        ext4   defaults        0 1
LABEL=UEFI      /boot/efi       vfat    defaults        0 1
UUID=7a38a8ba-e5f3-4a1d-9979-0c1a753cf3f7 /data ext4 defaults 0 0
  • reboot
  • df -h
ubuntu@dintvmsonar01:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            7.9G     0  7.9G   0% /dev
tmpfs           1.6G  1.1M  1.6G   1% /run
/dev/vda1        49G  1.7G   47G   4% /
tmpfs           7.9G     0  7.9G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           7.9G     0  7.9G   0% /sys/fs/cgroup
/dev/vdb1       491G   73M  466G   1% /data
/dev/vda15      105M  7.8M   97M   8% /boot/efi
/dev/loop0       56M   56M     0 100% /snap/core18/1988
/dev/loop2       33M   33M     0 100% /snap/snapd/11107
/dev/loop1       70M   70M     0 100% /snap/lxd/19188
/dev/loop3       56M   56M     0 100% /snap/core18/2344
/dev/loop4       45M   45M     0 100% /snap/snapd/15534
/dev/loop5       62M   62M     0 100% /snap/core20/1434
/dev/loop6       68M   68M     0 100% /snap/lxd/22753
tmpfs           1.6G     0  1.6G   0% /run/user/1000

Ref

https://it-serial.tistory.com/50 ~ 52

 

[Linux] df 명령어 & 마운트 자동 등록(fstab) & UUID란? ⑤

● df 명령어 (disk free) # df [옵션] [경로] : 현재 마운트 된 디스크 (크기, 사용량 등)정보 출력하는 명령어 (옵션, 경로 둘다 안적어도 명령어 실행 가능) (옵션, 경로 안쓰고 사용 시에 모든 디스

it-serial.tistory.com

Done