linux disk 마운트Linux2023. 8. 21. 11:21
Table of Contents
**마운트할 디렉토리 생성**
mkdir data
**마운트시킬 볼륨 확인**
[root@kimbh0132-205690 ~]# fdisk -l
Disk /dev/vda: 26.8 GB, 26843545600 bytes, 52428800 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 label type: dos
Disk identifier: 0x0000aebb
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 52428766 26213359+ 83 Linux
Disk /dev/vdb: 85.9 GB, 85899345920 bytes, 167772160 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
**파티션 설정**
root@kimbh0132-206594:/# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.37.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.
Created a new DOS disklabel with disk identifier 0x3b27ac3f.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-104857599, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-104857599, default 104857599):
Created a new partition 1 of type 'Linux' and of size 50 GiB.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
root@kimbh0132-206594:/# fdisk
~
Disk /dev/vdb: 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: dos
Disk identifier: 0x3b27ac3f
Device Boot Start End Sectors Size Id Type
/dev/vdb1 2048 104857599 104855552 50G 83 Linux
파티션이 생성된 모습...
**포멧**
ext4, xfs 등 원하는 형식으로 포멧한다. mkfs 명령어를 사용하여 ext4 형식으로 포멧진행
root@kimbh0132-206594:/# mkfs -t ext4 /dev/vdb1
mke2fs 1.46.5 (30-Dec-2021)
Creating filesystem with 13106944 4k blocks and 3276800 inodes
Filesystem UUID: d6ee5372-e043-4842-ae80-65174e8c37e2
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424
Allocating group tables: done
Writing inode tables: done
Creating journal (65536 blocks): done
Writing superblocks and filesystem accounting information: 0/400
done
**마운트 작업**
mount를 진행할 디렉토리를 생성하고 해당 디렉토리에 마운트 진행 /data 에 마운트 진행
root@kimbh0132-206594:/# mount /dev/vdb1 /data
**fstap 등록**
mount한 디스크가 재부팅시에도 자동으로 마운트 되도록 fstap에 등록해둔다 /etc/fstap에 아래와 같이 등록 디스크 이름 or 디스크 UUID / 마운트 포인트 / 파일 시스템 / 마운트 옵션 / 덤프(백업)유무 / fsck 검사 순서
root@kimbh0132-206594:/# cat /etc/fstab
LABEL=cloudimg-rootfs / ext4 discard,errors=remount-ro 0 1
LABEL=UEFI /boot/efi vfat umask=0077 0 1
/dev/vdb1 /data ext4 defaults 0 0 # 추가
만일 uuid로 마운트를 할것이라면 blkid를 사용하여 UUID 조회 후 /dev/vdb1/ 자리에 넣으면 된다.
root@kimbh0132-206594:/# blkid /dev/vdb1
/dev/vdb1: UUID="d6ee5372-e043-4842-ae80-65174e8c37e2" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="3b27ac3f-01"
@익은소세지 :: 익은소세지
포스팅이 좋았다면 "좋아요" 또는 "구독" 해주세요!